@contember/react-utils 2.1.0-alpha.37 → 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,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const MULTIPLE_SPACES_REG_EXP = / +/g;
|
|
5
|
+
function normalize(text) {
|
|
6
|
+
return text.replace(MULTIPLE_SPACES_REG_EXP, " ").trim();
|
|
7
|
+
}
|
|
8
|
+
function getChildrenAsLabel(node) {
|
|
9
|
+
if (typeof node === "string" || typeof node === "number") {
|
|
10
|
+
return String(node);
|
|
11
|
+
} else if (node === null || node === void 0 || typeof node === "boolean") {
|
|
12
|
+
return void 0;
|
|
13
|
+
} else if (Array.isArray(node)) {
|
|
14
|
+
return normalize(node.map(getChildrenAsLabel).join(""));
|
|
15
|
+
} else {
|
|
16
|
+
let label = [];
|
|
17
|
+
React.Children.map(node, (child) => {
|
|
18
|
+
if (child === null || child === void 0 || typeof child === "boolean") ;
|
|
19
|
+
else if (typeof child === "string") {
|
|
20
|
+
label.push(child);
|
|
21
|
+
} else if (typeof child === "number" || typeof child === "bigint") {
|
|
22
|
+
label.push(String(child));
|
|
23
|
+
} else if (Array.isArray(child)) {
|
|
24
|
+
const childLabel = getChildrenAsLabel(child);
|
|
25
|
+
if (childLabel) {
|
|
26
|
+
label.push(childLabel);
|
|
27
|
+
}
|
|
28
|
+
} else if (typeof child === "object") {
|
|
29
|
+
const props = "props" in child ? child.props : null;
|
|
30
|
+
if (props && "children" in props) {
|
|
31
|
+
const childLabel = getChildrenAsLabel(props.children);
|
|
32
|
+
if (childLabel) {
|
|
33
|
+
label.push(childLabel);
|
|
34
|
+
}
|
|
35
|
+
} else if ("children" in child) {
|
|
36
|
+
const childLabel = getChildrenAsLabel(child.children);
|
|
37
|
+
if (childLabel) {
|
|
38
|
+
label.push(childLabel);
|
|
39
|
+
}
|
|
40
|
+
} else ;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return label.length > 0 ? label.join("") : void 0;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function useChildrenAsLabel(node) {
|
|
47
|
+
return React.useMemo(() => getChildrenAsLabel(node), [node]);
|
|
48
|
+
}
|
|
49
|
+
exports.getChildrenAsLabel = getChildrenAsLabel;
|
|
50
|
+
exports.useChildrenAsLabel = useChildrenAsLabel;
|
|
51
|
+
//# sourceMappingURL=useChildrenAsLabel.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChildrenAsLabel.cjs","sources":["../../../../../packages/react-utils/src/hooks/useChildrenAsLabel.ts"],"sourcesContent":["import { Children, ReactNode, useMemo } from 'react'\n\nconst MULTIPLE_SPACES_REG_EXP = / +/g\n\nfunction normalize(text: string): string {\n\treturn text.replace(MULTIPLE_SPACES_REG_EXP, ' ').trim()\n}\n\n/**\n * Walks through the children and returns a string representation of the text content.\n *\n * @param node - The children to walk through.\n * @returns String representation of the text content or undefined if there is no text content.\n */\nexport function getChildrenAsLabel(node: ReactNode): string | undefined {\n\tif (typeof node === 'string' || typeof node === 'number') {\n\t\treturn String(node)\n\t} else if (node === null || node === undefined || typeof node === 'boolean') {\n\t\treturn undefined\n\t} else if (Array.isArray(node)) {\n\t\treturn normalize(node.map(getChildrenAsLabel).join(''))\n\t} else {\n\t\tlet label: (string | number)[] = []\n\n\t\tChildren.map(node, child => {\n\t\t\tif (child === null || child === undefined || typeof child === 'boolean') {\n\t\t\t} else if (typeof child === 'string') {\n\t\t\t\tlabel.push(child)\n\t\t\t} else if (typeof child === 'number' || typeof child === 'bigint') {\n\t\t\t\tlabel.push(String(child))\n\t\t\t} else if (Array.isArray(child)) {\n\t\t\t\tconst childLabel = getChildrenAsLabel(child)\n\n\t\t\t\tif (childLabel) {\n\t\t\t\t\tlabel.push(childLabel)\n\t\t\t\t}\n\t\t\t} else if (typeof child === 'object') {\n\t\t\t\t// ReactElement | ReactPortal | Iterable\n\t\t\t\tconst props = 'props' in child ? child.props as Record<string, unknown> : null\n\t\t\t\tif (props && 'children' in props) {\n\t\t\t\t\tconst childLabel = getChildrenAsLabel(props.children as ReactNode)\n\n\t\t\t\t\tif (childLabel) {\n\t\t\t\t\t\tlabel.push(childLabel)\n\t\t\t\t\t}\n\t\t\t\t} else if ('children' in child) {\n\t\t\t\t\t// ReactPortal\n\t\t\t\t\tconst childLabel = getChildrenAsLabel(child.children)\n\n\t\t\t\t\tif (childLabel) {\n\t\t\t\t\t\tlabel.push(childLabel)\n\t\t\t\t\t}\n\t\t\t\t} else if (import.meta.env.DEV) {\n\t\t\t\t\tconsole.warn('Unsupported child:', child)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\n\t\treturn label.length > 0 ? label.join('') : undefined\n\t}\n}\n\n/**\n * Walks through the children and returns a string representation of the text content.\n *\n * @param node - The children to walk through.\n * @returns String representation of the text content or undefined if there is no text content.\n */\nexport function useChildrenAsLabel(node: ReactNode): string | undefined {\n\treturn useMemo(() => getChildrenAsLabel(node), [node])\n}\n"],"names":["Children","useMemo"],"mappings":";;;AAEA,MAAM,0BAA0B;AAEhC,SAAS,UAAU,MAAsB;AACxC,SAAO,KAAK,QAAQ,yBAAyB,GAAG,EAAE,KAAA;AACnD;AAQO,SAAS,mBAAmB,MAAqC;AACvE,MAAI,OAAO,SAAS,YAAY,OAAO,SAAS,UAAU;AACzD,WAAO,OAAO,IAAI;AAAA,EACnB,WAAW,SAAS,QAAQ,SAAS,UAAa,OAAO,SAAS,WAAW;AAC5E,WAAO;AAAA,EACR,WAAW,MAAM,QAAQ,IAAI,GAAG;AAC/B,WAAO,UAAU,KAAK,IAAI,kBAAkB,EAAE,KAAK,EAAE,CAAC;AAAA,EACvD,OAAO;AACN,QAAI,QAA6B,CAAA;AAEjCA,UAAAA,SAAS,IAAI,MAAM,CAAA,UAAS;AAC3B,UAAI,UAAU,QAAQ,UAAU,UAAa,OAAO,UAAU,UAAW;AAAA,eAC9D,OAAO,UAAU,UAAU;AACrC,cAAM,KAAK,KAAK;AAAA,MACjB,WAAW,OAAO,UAAU,YAAY,OAAO,UAAU,UAAU;AAClE,cAAM,KAAK,OAAO,KAAK,CAAC;AAAA,MACzB,WAAW,MAAM,QAAQ,KAAK,GAAG;AAChC,cAAM,aAAa,mBAAmB,KAAK;AAE3C,YAAI,YAAY;AACf,gBAAM,KAAK,UAAU;AAAA,QACtB;AAAA,MACD,WAAW,OAAO,UAAU,UAAU;AAErC,cAAM,QAAQ,WAAW,QAAQ,MAAM,QAAmC;AAC1E,YAAI,SAAS,cAAc,OAAO;AACjC,gBAAM,aAAa,mBAAmB,MAAM,QAAqB;AAEjE,cAAI,YAAY;AACf,kBAAM,KAAK,UAAU;AAAA,UACtB;AAAA,QACD,WAAW,cAAc,OAAO;AAE/B,gBAAM,aAAa,mBAAmB,MAAM,QAAQ;AAEpD,cAAI,YAAY;AACf,kBAAM,KAAK,UAAU;AAAA,UACtB;AAAA,QACD;MAGD;AAAA,IACD,CAAC;AAED,WAAO,MAAM,SAAS,IAAI,MAAM,KAAK,EAAE,IAAI;AAAA,EAC5C;AACD;AAQO,SAAS,mBAAmB,MAAqC;AACvE,SAAOC,MAAAA,QAAQ,MAAM,mBAAmB,IAAI,GAAG,CAAC,IAAI,CAAC;AACtD;;;"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Children, useMemo } from "react";
|
|
2
|
+
const MULTIPLE_SPACES_REG_EXP = / +/g;
|
|
3
|
+
function normalize(text) {
|
|
4
|
+
return text.replace(MULTIPLE_SPACES_REG_EXP, " ").trim();
|
|
5
|
+
}
|
|
6
|
+
function getChildrenAsLabel(node) {
|
|
7
|
+
if (typeof node === "string" || typeof node === "number") {
|
|
8
|
+
return String(node);
|
|
9
|
+
} else if (node === null || node === void 0 || typeof node === "boolean") {
|
|
10
|
+
return void 0;
|
|
11
|
+
} else if (Array.isArray(node)) {
|
|
12
|
+
return normalize(node.map(getChildrenAsLabel).join(""));
|
|
13
|
+
} else {
|
|
14
|
+
let label = [];
|
|
15
|
+
Children.map(node, (child) => {
|
|
16
|
+
if (child === null || child === void 0 || typeof child === "boolean") ;
|
|
17
|
+
else if (typeof child === "string") {
|
|
18
|
+
label.push(child);
|
|
19
|
+
} else if (typeof child === "number" || typeof child === "bigint") {
|
|
20
|
+
label.push(String(child));
|
|
21
|
+
} else if (Array.isArray(child)) {
|
|
22
|
+
const childLabel = getChildrenAsLabel(child);
|
|
23
|
+
if (childLabel) {
|
|
24
|
+
label.push(childLabel);
|
|
25
|
+
}
|
|
26
|
+
} else if (typeof child === "object") {
|
|
27
|
+
const props = "props" in child ? child.props : null;
|
|
28
|
+
if (props && "children" in props) {
|
|
29
|
+
const childLabel = getChildrenAsLabel(props.children);
|
|
30
|
+
if (childLabel) {
|
|
31
|
+
label.push(childLabel);
|
|
32
|
+
}
|
|
33
|
+
} else if ("children" in child) {
|
|
34
|
+
const childLabel = getChildrenAsLabel(child.children);
|
|
35
|
+
if (childLabel) {
|
|
36
|
+
label.push(childLabel);
|
|
37
|
+
}
|
|
38
|
+
} else ;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return label.length > 0 ? label.join("") : void 0;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function useChildrenAsLabel(node) {
|
|
45
|
+
return useMemo(() => getChildrenAsLabel(node), [node]);
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
getChildrenAsLabel,
|
|
49
|
+
useChildrenAsLabel
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=useChildrenAsLabel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChildrenAsLabel.js","sources":["../../../../../packages/react-utils/src/hooks/useChildrenAsLabel.ts"],"sourcesContent":["import { Children, ReactNode, useMemo } from 'react'\n\nconst MULTIPLE_SPACES_REG_EXP = / +/g\n\nfunction normalize(text: string): string {\n\treturn text.replace(MULTIPLE_SPACES_REG_EXP, ' ').trim()\n}\n\n/**\n * Walks through the children and returns a string representation of the text content.\n *\n * @param node - The children to walk through.\n * @returns String representation of the text content or undefined if there is no text content.\n */\nexport function getChildrenAsLabel(node: ReactNode): string | undefined {\n\tif (typeof node === 'string' || typeof node === 'number') {\n\t\treturn String(node)\n\t} else if (node === null || node === undefined || typeof node === 'boolean') {\n\t\treturn undefined\n\t} else if (Array.isArray(node)) {\n\t\treturn normalize(node.map(getChildrenAsLabel).join(''))\n\t} else {\n\t\tlet label: (string | number)[] = []\n\n\t\tChildren.map(node, child => {\n\t\t\tif (child === null || child === undefined || typeof child === 'boolean') {\n\t\t\t} else if (typeof child === 'string') {\n\t\t\t\tlabel.push(child)\n\t\t\t} else if (typeof child === 'number' || typeof child === 'bigint') {\n\t\t\t\tlabel.push(String(child))\n\t\t\t} else if (Array.isArray(child)) {\n\t\t\t\tconst childLabel = getChildrenAsLabel(child)\n\n\t\t\t\tif (childLabel) {\n\t\t\t\t\tlabel.push(childLabel)\n\t\t\t\t}\n\t\t\t} else if (typeof child === 'object') {\n\t\t\t\t// ReactElement | ReactPortal | Iterable\n\t\t\t\tconst props = 'props' in child ? child.props as Record<string, unknown> : null\n\t\t\t\tif (props && 'children' in props) {\n\t\t\t\t\tconst childLabel = getChildrenAsLabel(props.children as ReactNode)\n\n\t\t\t\t\tif (childLabel) {\n\t\t\t\t\t\tlabel.push(childLabel)\n\t\t\t\t\t}\n\t\t\t\t} else if ('children' in child) {\n\t\t\t\t\t// ReactPortal\n\t\t\t\t\tconst childLabel = getChildrenAsLabel(child.children)\n\n\t\t\t\t\tif (childLabel) {\n\t\t\t\t\t\tlabel.push(childLabel)\n\t\t\t\t\t}\n\t\t\t\t} else if (import.meta.env.DEV) {\n\t\t\t\t\tconsole.warn('Unsupported child:', child)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\n\t\treturn label.length > 0 ? label.join('') : undefined\n\t}\n}\n\n/**\n * Walks through the children and returns a string representation of the text content.\n *\n * @param node - The children to walk through.\n * @returns String representation of the text content or undefined if there is no text content.\n */\nexport function useChildrenAsLabel(node: ReactNode): string | undefined {\n\treturn useMemo(() => getChildrenAsLabel(node), [node])\n}\n"],"names":[],"mappings":";AAEA,MAAM,0BAA0B;AAEhC,SAAS,UAAU,MAAsB;AACxC,SAAO,KAAK,QAAQ,yBAAyB,GAAG,EAAE,KAAA;AACnD;AAQO,SAAS,mBAAmB,MAAqC;AACvE,MAAI,OAAO,SAAS,YAAY,OAAO,SAAS,UAAU;AACzD,WAAO,OAAO,IAAI;AAAA,EACnB,WAAW,SAAS,QAAQ,SAAS,UAAa,OAAO,SAAS,WAAW;AAC5E,WAAO;AAAA,EACR,WAAW,MAAM,QAAQ,IAAI,GAAG;AAC/B,WAAO,UAAU,KAAK,IAAI,kBAAkB,EAAE,KAAK,EAAE,CAAC;AAAA,EACvD,OAAO;AACN,QAAI,QAA6B,CAAA;AAEjC,aAAS,IAAI,MAAM,CAAA,UAAS;AAC3B,UAAI,UAAU,QAAQ,UAAU,UAAa,OAAO,UAAU,UAAW;AAAA,eAC9D,OAAO,UAAU,UAAU;AACrC,cAAM,KAAK,KAAK;AAAA,MACjB,WAAW,OAAO,UAAU,YAAY,OAAO,UAAU,UAAU;AAClE,cAAM,KAAK,OAAO,KAAK,CAAC;AAAA,MACzB,WAAW,MAAM,QAAQ,KAAK,GAAG;AAChC,cAAM,aAAa,mBAAmB,KAAK;AAE3C,YAAI,YAAY;AACf,gBAAM,KAAK,UAAU;AAAA,QACtB;AAAA,MACD,WAAW,OAAO,UAAU,UAAU;AAErC,cAAM,QAAQ,WAAW,QAAQ,MAAM,QAAmC;AAC1E,YAAI,SAAS,cAAc,OAAO;AACjC,gBAAM,aAAa,mBAAmB,MAAM,QAAqB;AAEjE,cAAI,YAAY;AACf,kBAAM,KAAK,UAAU;AAAA,UACtB;AAAA,QACD,WAAW,cAAc,OAAO;AAE/B,gBAAM,aAAa,mBAAmB,MAAM,QAAQ;AAEpD,cAAI,YAAY;AACf,kBAAM,KAAK,UAAU;AAAA,UACtB;AAAA,QACD;MAGD;AAAA,IACD,CAAC;AAED,WAAO,MAAM,SAAS,IAAI,MAAM,KAAK,EAAE,IAAI;AAAA,EAC5C;AACD;AAQO,SAAS,mBAAmB,MAAqC;AACvE,SAAO,QAAQ,MAAM,mBAAmB,IAAI,GAAG,CAAC,IAAI,CAAC;AACtD;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
function setRef(ref, instance) {
|
|
5
|
+
if (ref) {
|
|
6
|
+
if (typeof ref === "function") {
|
|
7
|
+
ref(instance);
|
|
8
|
+
} else if (instance) {
|
|
9
|
+
ref.current = instance;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function useComposeRef(...refs) {
|
|
14
|
+
const initialRefs = React.useRef(refs);
|
|
15
|
+
const composeRef = React.useMemo(() => {
|
|
16
|
+
function composedRefCallback(instance) {
|
|
17
|
+
initialRefs.current.forEach((ref) => setRef(ref, instance));
|
|
18
|
+
setCurrent(instance);
|
|
19
|
+
}
|
|
20
|
+
function setCurrent(instance) {
|
|
21
|
+
if (instance) {
|
|
22
|
+
composedRefCallback.current = instance;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
composedRefCallback.current = null;
|
|
26
|
+
return composedRefCallback;
|
|
27
|
+
}, []);
|
|
28
|
+
return composeRef;
|
|
29
|
+
}
|
|
30
|
+
exports.useComposeRef = useComposeRef;
|
|
31
|
+
//# sourceMappingURL=useComposeRef.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useComposeRef.cjs","sources":["../../../../../packages/react-utils/src/hooks/useComposeRef.ts"],"sourcesContent":["import { MutableRefObject, RefCallback, useMemo, useRef } from 'react'\n\nexport type MaybeRef<T> = ((instance: T | null) => void) | MutableRefObject<T | null> | null | undefined\nexport type ComposedRefCallback<T> = RefCallback<T> & { current: T | null }\n\nfunction setRef<T>(ref: MaybeRef<T>, instance: T | null): void {\n\tif (ref) {\n\t\tif (typeof ref === 'function') {\n\t\t\tref(instance)\n\t\t} else if (instance) {\n\t\t\tref.current = instance\n\t\t}\n\t}\n}\n\n/**\n * Fills any number of refs with an instance\n *\n * Useful when you need to use outer ref and inner in the same time, e.g. passing element\n * back to forwardedRef an also using the same value within the component locally.\n *\n * @param refs - Rest parameter of refs to fill with instance\n * @returns Returns a function similar to a RefCallback\n */\nexport function useComposeRef<T>(...refs: MaybeRef<T>[]): ComposedRefCallback<T> {\n\tconst initialRefs = useRef(refs)\n\n\tconst composeRef: ComposedRefCallback<T> = useMemo(() => {\n\t\tfunction composedRefCallback(instance: T | null) {\n\t\t\tinitialRefs.current.forEach(ref => setRef(ref, instance))\n\t\t\tsetCurrent(instance)\n\t\t}\n\n\t\tfunction setCurrent(instance: T | null) {\n\t\t\tif (instance) {\n\t\t\t\tcomposedRefCallback.current = instance\n\t\t\t}\n\t\t}\n\n\t\tcomposedRefCallback.current = null as T | null\n\n\t\treturn composedRefCallback\n\t}, [])\n\n\treturn composeRef\n}\n"],"names":["useRef","useMemo"],"mappings":";;;AAKA,SAAS,OAAU,KAAkB,UAA0B;AAC9D,MAAI,KAAK;AACR,QAAI,OAAO,QAAQ,YAAY;AAC9B,UAAI,QAAQ;AAAA,IACb,WAAW,UAAU;AACpB,UAAI,UAAU;AAAA,IACf;AAAA,EACD;AACD;AAWO,SAAS,iBAAoB,MAA6C;AAChF,QAAM,cAAcA,MAAAA,OAAO,IAAI;AAE/B,QAAM,aAAqCC,MAAAA,QAAQ,MAAM;AACxD,aAAS,oBAAoB,UAAoB;AAChD,kBAAY,QAAQ,QAAQ,CAAA,QAAO,OAAO,KAAK,QAAQ,CAAC;AACxD,iBAAW,QAAQ;AAAA,IACpB;AAEA,aAAS,WAAW,UAAoB;AACvC,UAAI,UAAU;AACb,4BAAoB,UAAU;AAAA,MAC/B;AAAA,IACD;AAEA,wBAAoB,UAAU;AAE9B,WAAO;AAAA,EACR,GAAG,CAAA,CAAE;AAEL,SAAO;AACR;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useRef, useMemo } from "react";
|
|
2
|
+
function setRef(ref, instance) {
|
|
3
|
+
if (ref) {
|
|
4
|
+
if (typeof ref === "function") {
|
|
5
|
+
ref(instance);
|
|
6
|
+
} else if (instance) {
|
|
7
|
+
ref.current = instance;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function useComposeRef(...refs) {
|
|
12
|
+
const initialRefs = useRef(refs);
|
|
13
|
+
const composeRef = useMemo(() => {
|
|
14
|
+
function composedRefCallback(instance) {
|
|
15
|
+
initialRefs.current.forEach((ref) => setRef(ref, instance));
|
|
16
|
+
setCurrent(instance);
|
|
17
|
+
}
|
|
18
|
+
function setCurrent(instance) {
|
|
19
|
+
if (instance) {
|
|
20
|
+
composedRefCallback.current = instance;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
composedRefCallback.current = null;
|
|
24
|
+
return composedRefCallback;
|
|
25
|
+
}, []);
|
|
26
|
+
return composeRef;
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
useComposeRef
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=useComposeRef.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useComposeRef.js","sources":["../../../../../packages/react-utils/src/hooks/useComposeRef.ts"],"sourcesContent":["import { MutableRefObject, RefCallback, useMemo, useRef } from 'react'\n\nexport type MaybeRef<T> = ((instance: T | null) => void) | MutableRefObject<T | null> | null | undefined\nexport type ComposedRefCallback<T> = RefCallback<T> & { current: T | null }\n\nfunction setRef<T>(ref: MaybeRef<T>, instance: T | null): void {\n\tif (ref) {\n\t\tif (typeof ref === 'function') {\n\t\t\tref(instance)\n\t\t} else if (instance) {\n\t\t\tref.current = instance\n\t\t}\n\t}\n}\n\n/**\n * Fills any number of refs with an instance\n *\n * Useful when you need to use outer ref and inner in the same time, e.g. passing element\n * back to forwardedRef an also using the same value within the component locally.\n *\n * @param refs - Rest parameter of refs to fill with instance\n * @returns Returns a function similar to a RefCallback\n */\nexport function useComposeRef<T>(...refs: MaybeRef<T>[]): ComposedRefCallback<T> {\n\tconst initialRefs = useRef(refs)\n\n\tconst composeRef: ComposedRefCallback<T> = useMemo(() => {\n\t\tfunction composedRefCallback(instance: T | null) {\n\t\t\tinitialRefs.current.forEach(ref => setRef(ref, instance))\n\t\t\tsetCurrent(instance)\n\t\t}\n\n\t\tfunction setCurrent(instance: T | null) {\n\t\t\tif (instance) {\n\t\t\t\tcomposedRefCallback.current = instance\n\t\t\t}\n\t\t}\n\n\t\tcomposedRefCallback.current = null as T | null\n\n\t\treturn composedRefCallback\n\t}, [])\n\n\treturn composeRef\n}\n"],"names":[],"mappings":";AAKA,SAAS,OAAU,KAAkB,UAA0B;AAC9D,MAAI,KAAK;AACR,QAAI,OAAO,QAAQ,YAAY;AAC9B,UAAI,QAAQ;AAAA,IACb,WAAW,UAAU;AACpB,UAAI,UAAU;AAAA,IACf;AAAA,EACD;AACD;AAWO,SAAS,iBAAoB,MAA6C;AAChF,QAAM,cAAc,OAAO,IAAI;AAE/B,QAAM,aAAqC,QAAQ,MAAM;AACxD,aAAS,oBAAoB,UAAoB;AAChD,kBAAY,QAAQ,QAAQ,CAAA,QAAO,OAAO,KAAK,QAAQ,CAAC;AACxD,iBAAW,QAAQ;AAAA,IACpB;AAEA,aAAS,WAAW,UAAoB;AACvC,UAAI,UAAU;AACb,4BAAoB,UAAU;AAAA,MAC/B;AAAA,IACD;AAEA,wBAAoB,UAAU;AAE9B,WAAO;AAAA,EACR,GAAG,CAAA,CAAE;AAEL,SAAO;AACR;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const useConstantLengthInvariant = (items, message) => {
|
|
4
|
+
};
|
|
5
|
+
exports.useConstantLengthInvariant = useConstantLengthInvariant;
|
|
6
|
+
//# sourceMappingURL=useConstantLengthInvariant.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useConstantLengthInvariant.cjs","sources":["../../../../../packages/react-utils/src/hooks/useConstantLengthInvariant.ts"],"sourcesContent":["import { usePreviousValue } from './usePreviousValue'\n\n// This entire hook should get optimized away for prod\nexport const useConstantLengthInvariant = <Item>(items: Item[], message?: string) => {\n\tif (import.meta.env.DEV) {\n\t\tconst previous = usePreviousValue(items)\n\t\tif (previous.length !== items.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invariant violation: ${message || 'Changing the length of an array whose length must remain constant between renders.'}`,\n\t\t\t)\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;AAGO,MAAM,6BAA6B,CAAO,OAAe,YAAqB;AASrF;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useConstantLengthInvariant.js","sources":["../../../../../packages/react-utils/src/hooks/useConstantLengthInvariant.ts"],"sourcesContent":["import { usePreviousValue } from './usePreviousValue'\n\n// This entire hook should get optimized away for prod\nexport const useConstantLengthInvariant = <Item>(items: Item[], message?: string) => {\n\tif (import.meta.env.DEV) {\n\t\tconst previous = usePreviousValue(items)\n\t\tif (previous.length !== items.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invariant violation: ${message || 'Changing the length of an array whose length must remain constant between renders.'}`,\n\t\t\t)\n\t\t}\n\t}\n}\n"],"names":[],"mappings":"AAGO,MAAM,6BAA6B,CAAO,OAAe,YAAqB;AASrF;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const useConstantValueInvariant = (value, message) => {
|
|
4
|
+
};
|
|
5
|
+
exports.useConstantValueInvariant = useConstantValueInvariant;
|
|
6
|
+
//# sourceMappingURL=useConstantValueInvariant.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useConstantValueInvariant.cjs","sources":["../../../../../packages/react-utils/src/hooks/useConstantValueInvariant.ts"],"sourcesContent":["import { usePreviousValue } from './usePreviousValue'\n\n// This entire hook should get optimized away for prod\nexport const useConstantValueInvariant = <Value>(value: Value, message?: string) => {\n\tif (import.meta.env.DEV) {\n\t\tconst previous = usePreviousValue(value)\n\t\tif (previous !== value) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invariant violation: ${message || 'Changing a value which must remain constant between renders.'}`,\n\t\t\t)\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;AAGO,MAAM,4BAA4B,CAAQ,OAAc,YAAqB;AASpF;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useConstantValueInvariant.js","sources":["../../../../../packages/react-utils/src/hooks/useConstantValueInvariant.ts"],"sourcesContent":["import { usePreviousValue } from './usePreviousValue'\n\n// This entire hook should get optimized away for prod\nexport const useConstantValueInvariant = <Value>(value: Value, message?: string) => {\n\tif (import.meta.env.DEV) {\n\t\tconst previous = usePreviousValue(value)\n\t\tif (previous !== value) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invariant violation: ${message || 'Changing a value which must remain constant between renders.'}`,\n\t\t\t)\n\t\t}\n\t}\n}\n"],"names":[],"mappings":"AAGO,MAAM,4BAA4B,CAAQ,OAAc,YAAqB;AASpF;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const useDebounce = (value, debounceMs) => {
|
|
5
|
+
const [debounced, setDebounced] = React.useState(value);
|
|
6
|
+
React.useEffect(() => {
|
|
7
|
+
const handle = window.setTimeout(() => setDebounced(value), debounceMs);
|
|
8
|
+
return () => {
|
|
9
|
+
window.clearTimeout(handle);
|
|
10
|
+
};
|
|
11
|
+
}, [value, debounceMs]);
|
|
12
|
+
return debounced;
|
|
13
|
+
};
|
|
14
|
+
exports.useDebounce = useDebounce;
|
|
15
|
+
//# sourceMappingURL=useDebounce.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDebounce.cjs","sources":["../../../../../packages/react-utils/src/hooks/useDebounce.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\n\nexport const useDebounce = <T>(value: T, debounceMs: number): T => {\n\tconst [debounced, setDebounced] = useState(value)\n\tuseEffect(() => {\n\t\tconst handle = window.setTimeout(() => setDebounced(value), debounceMs)\n\t\treturn () => {\n\t\t\twindow.clearTimeout(handle)\n\t\t}\n\t}, [value, debounceMs])\n\treturn debounced\n}\n"],"names":["useState","useEffect"],"mappings":";;;AAEO,MAAM,cAAc,CAAI,OAAU,eAA0B;AAClE,QAAM,CAAC,WAAW,YAAY,IAAIA,MAAAA,SAAS,KAAK;AAChDC,QAAAA,UAAU,MAAM;AACf,UAAM,SAAS,OAAO,WAAW,MAAM,aAAa,KAAK,GAAG,UAAU;AACtE,WAAO,MAAM;AACZ,aAAO,aAAa,MAAM;AAAA,IAC3B;AAAA,EACD,GAAG,CAAC,OAAO,UAAU,CAAC;AACtB,SAAO;AACR;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useState, useEffect } from "react";
|
|
2
|
+
const useDebounce = (value, debounceMs) => {
|
|
3
|
+
const [debounced, setDebounced] = useState(value);
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
const handle = window.setTimeout(() => setDebounced(value), debounceMs);
|
|
6
|
+
return () => {
|
|
7
|
+
window.clearTimeout(handle);
|
|
8
|
+
};
|
|
9
|
+
}, [value, debounceMs]);
|
|
10
|
+
return debounced;
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
useDebounce
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=useDebounce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDebounce.js","sources":["../../../../../packages/react-utils/src/hooks/useDebounce.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\n\nexport const useDebounce = <T>(value: T, debounceMs: number): T => {\n\tconst [debounced, setDebounced] = useState(value)\n\tuseEffect(() => {\n\t\tconst handle = window.setTimeout(() => setDebounced(value), debounceMs)\n\t\treturn () => {\n\t\t\twindow.clearTimeout(handle)\n\t\t}\n\t}, [value, debounceMs])\n\treturn debounced\n}\n"],"names":[],"mappings":";AAEO,MAAM,cAAc,CAAI,OAAU,eAA0B;AAClE,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,YAAU,MAAM;AACf,UAAM,SAAS,OAAO,WAAW,MAAM,aAAa,KAAK,GAAG,UAAU;AACtE,WAAO,MAAM;AACZ,aAAO,aAAa,MAAM;AAAA,IAC3B;AAAA,EACD,GAAG,CAAC,OAAO,UAAU,CAAC;AACtB,SAAO;AACR;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const useDebounceCallback = (cb, debounceMs) => {
|
|
5
|
+
const timerRef = React.useRef(void 0);
|
|
6
|
+
const cbRef = React.useRef(cb);
|
|
7
|
+
cbRef.current = cb;
|
|
8
|
+
React.useEffect(() => {
|
|
9
|
+
return () => clearTimeout(timerRef.current);
|
|
10
|
+
}, []);
|
|
11
|
+
return React.useCallback(() => {
|
|
12
|
+
timerRef.current && clearTimeout(timerRef.current);
|
|
13
|
+
timerRef.current = setTimeout(() => {
|
|
14
|
+
cbRef.current();
|
|
15
|
+
}, debounceMs);
|
|
16
|
+
}, [debounceMs]);
|
|
17
|
+
};
|
|
18
|
+
exports.useDebounceCallback = useDebounceCallback;
|
|
19
|
+
//# sourceMappingURL=useDebounceCallback.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDebounceCallback.cjs","sources":["../../../../../packages/react-utils/src/hooks/useDebounceCallback.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react'\n\nexport const useDebounceCallback = (cb: () => any, debounceMs: number) => {\n\tconst timerRef = useRef<ReturnType<typeof setTimeout>>(undefined)\n\tconst cbRef = useRef(cb)\n\tcbRef.current = cb\n\n\tuseEffect(() => {\n\t\treturn () => clearTimeout(timerRef.current)\n\t}, [])\n\n\treturn useCallback(() => {\n\t\ttimerRef.current && clearTimeout(timerRef.current)\n\n\t\ttimerRef.current = setTimeout(() => {\n\t\t\tcbRef.current()\n\t\t}, debounceMs)\n\t}, [debounceMs])\n}\n"],"names":["useRef","useEffect","useCallback"],"mappings":";;;AAEO,MAAM,sBAAsB,CAAC,IAAe,eAAuB;AACzE,QAAM,WAAWA,MAAAA,OAAsC,MAAS;AAChE,QAAM,QAAQA,MAAAA,OAAO,EAAE;AACvB,QAAM,UAAU;AAEhBC,QAAAA,UAAU,MAAM;AACf,WAAO,MAAM,aAAa,SAAS,OAAO;AAAA,EAC3C,GAAG,CAAA,CAAE;AAEL,SAAOC,MAAAA,YAAY,MAAM;AACxB,aAAS,WAAW,aAAa,SAAS,OAAO;AAEjD,aAAS,UAAU,WAAW,MAAM;AACnC,YAAM,QAAA;AAAA,IACP,GAAG,UAAU;AAAA,EACd,GAAG,CAAC,UAAU,CAAC;AAChB;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useRef, useEffect, useCallback } from "react";
|
|
2
|
+
const useDebounceCallback = (cb, debounceMs) => {
|
|
3
|
+
const timerRef = useRef(void 0);
|
|
4
|
+
const cbRef = useRef(cb);
|
|
5
|
+
cbRef.current = cb;
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
return () => clearTimeout(timerRef.current);
|
|
8
|
+
}, []);
|
|
9
|
+
return useCallback(() => {
|
|
10
|
+
timerRef.current && clearTimeout(timerRef.current);
|
|
11
|
+
timerRef.current = setTimeout(() => {
|
|
12
|
+
cbRef.current();
|
|
13
|
+
}, debounceMs);
|
|
14
|
+
}, [debounceMs]);
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
useDebounceCallback
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=useDebounceCallback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDebounceCallback.js","sources":["../../../../../packages/react-utils/src/hooks/useDebounceCallback.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react'\n\nexport const useDebounceCallback = (cb: () => any, debounceMs: number) => {\n\tconst timerRef = useRef<ReturnType<typeof setTimeout>>(undefined)\n\tconst cbRef = useRef(cb)\n\tcbRef.current = cb\n\n\tuseEffect(() => {\n\t\treturn () => clearTimeout(timerRef.current)\n\t}, [])\n\n\treturn useCallback(() => {\n\t\ttimerRef.current && clearTimeout(timerRef.current)\n\n\t\ttimerRef.current = setTimeout(() => {\n\t\t\tcbRef.current()\n\t\t}, debounceMs)\n\t}, [debounceMs])\n}\n"],"names":[],"mappings":";AAEO,MAAM,sBAAsB,CAAC,IAAe,eAAuB;AACzE,QAAM,WAAW,OAAsC,MAAS;AAChE,QAAM,QAAQ,OAAO,EAAE;AACvB,QAAM,UAAU;AAEhB,YAAU,MAAM;AACf,WAAO,MAAM,aAAa,SAAS,OAAO;AAAA,EAC3C,GAAG,CAAA,CAAE;AAEL,SAAO,YAAY,MAAM;AACxB,aAAS,WAAW,aAAa,SAAS,OAAO;AAEjD,aAAS,UAAU,WAAW,MAAM;AACnC,YAAM,QAAA;AAAA,IACP,GAAG,UAAU;AAAA,EACd,GAAG,CAAC,UAAU,CAAC;AAChB;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
function useDocumentTitle(title, formatter) {
|
|
5
|
+
const initialTitle = React.useRef(document.title).current;
|
|
6
|
+
React.useEffect(() => {
|
|
7
|
+
if (title) {
|
|
8
|
+
if (formatter) {
|
|
9
|
+
document.title = formatter(title, initialTitle);
|
|
10
|
+
} else {
|
|
11
|
+
document.title = title;
|
|
12
|
+
}
|
|
13
|
+
} else {
|
|
14
|
+
document.title = initialTitle;
|
|
15
|
+
}
|
|
16
|
+
return () => {
|
|
17
|
+
document.title = initialTitle;
|
|
18
|
+
};
|
|
19
|
+
}, [formatter, initialTitle, title]);
|
|
20
|
+
}
|
|
21
|
+
exports.useDocumentTitle = useDocumentTitle;
|
|
22
|
+
//# sourceMappingURL=useDocumentTitle.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDocumentTitle.cjs","sources":["../../../../../packages/react-utils/src/hooks/useDocumentTitle.ts"],"sourcesContent":["import { useEffect, useRef } from 'react'\n\nexport function useDocumentTitle(title: string | null | undefined, formatter?: (title: string, initialTitle: string) => string) {\n\tconst initialTitle = useRef(document.title).current\n\n\tuseEffect(() => {\n\t\tif (title) {\n\t\t\tif (formatter) {\n\t\t\t\tdocument.title = formatter(title, initialTitle)\n\t\t\t} else {\n\t\t\t\tdocument.title = title\n\t\t\t}\n\t\t} else {\n\t\t\tdocument.title = initialTitle\n\t\t}\n\n\t\treturn () => {\n\t\t\tdocument.title = initialTitle\n\t\t}\n\t}, [formatter, initialTitle, title])\n}\n"],"names":["useRef","useEffect"],"mappings":";;;AAEO,SAAS,iBAAiB,OAAkC,WAA6D;AAC/H,QAAM,eAAeA,MAAAA,OAAO,SAAS,KAAK,EAAE;AAE5CC,QAAAA,UAAU,MAAM;AACf,QAAI,OAAO;AACV,UAAI,WAAW;AACd,iBAAS,QAAQ,UAAU,OAAO,YAAY;AAAA,MAC/C,OAAO;AACN,iBAAS,QAAQ;AAAA,MAClB;AAAA,IACD,OAAO;AACN,eAAS,QAAQ;AAAA,IAClB;AAEA,WAAO,MAAM;AACZ,eAAS,QAAQ;AAAA,IAClB;AAAA,EACD,GAAG,CAAC,WAAW,cAAc,KAAK,CAAC;AACpC;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useRef, useEffect } from "react";
|
|
2
|
+
function useDocumentTitle(title, formatter) {
|
|
3
|
+
const initialTitle = useRef(document.title).current;
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
if (title) {
|
|
6
|
+
if (formatter) {
|
|
7
|
+
document.title = formatter(title, initialTitle);
|
|
8
|
+
} else {
|
|
9
|
+
document.title = title;
|
|
10
|
+
}
|
|
11
|
+
} else {
|
|
12
|
+
document.title = initialTitle;
|
|
13
|
+
}
|
|
14
|
+
return () => {
|
|
15
|
+
document.title = initialTitle;
|
|
16
|
+
};
|
|
17
|
+
}, [formatter, initialTitle, title]);
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
useDocumentTitle
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=useDocumentTitle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDocumentTitle.js","sources":["../../../../../packages/react-utils/src/hooks/useDocumentTitle.ts"],"sourcesContent":["import { useEffect, useRef } from 'react'\n\nexport function useDocumentTitle(title: string | null | undefined, formatter?: (title: string, initialTitle: string) => string) {\n\tconst initialTitle = useRef(document.title).current\n\n\tuseEffect(() => {\n\t\tif (title) {\n\t\t\tif (formatter) {\n\t\t\t\tdocument.title = formatter(title, initialTitle)\n\t\t\t} else {\n\t\t\t\tdocument.title = title\n\t\t\t}\n\t\t} else {\n\t\t\tdocument.title = initialTitle\n\t\t}\n\n\t\treturn () => {\n\t\t\tdocument.title = initialTitle\n\t\t}\n\t}, [formatter, initialTitle, title])\n}\n"],"names":[],"mappings":";AAEO,SAAS,iBAAiB,OAAkC,WAA6D;AAC/H,QAAM,eAAe,OAAO,SAAS,KAAK,EAAE;AAE5C,YAAU,MAAM;AACf,QAAI,OAAO;AACV,UAAI,WAAW;AACd,iBAAS,QAAQ,UAAU,OAAO,YAAY;AAAA,MAC/C,OAAO;AACN,iBAAS,QAAQ;AAAA,MAClB;AAAA,IACD,OAAO;AACN,eAAS,QAAQ;AAAA,IAClB;AAEA,WAAO,MAAM;AACZ,eAAS,QAAQ;AAAA,IAClB;AAAA,EACD,GAAG,CAAC,WAAW,cAAc,KAAK,CAAC;AACpC;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const equal = require("fast-deep-equal/es6/index.js");
|
|
4
|
+
const React = require("react");
|
|
5
|
+
function useExpectSameValueReference(next, shouldThrow = false) {
|
|
6
|
+
const previous = React.useRef(next);
|
|
7
|
+
if (next !== previous.current && typeof next === "object" && typeof previous.current === "object" && equal(next, previous.current)) {
|
|
8
|
+
if (shouldThrow) {
|
|
9
|
+
throw new Error("Expecting same reference for same values");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
previous.current = next;
|
|
13
|
+
}
|
|
14
|
+
exports.useExpectSameValueReference = useExpectSameValueReference;
|
|
15
|
+
//# sourceMappingURL=useExpectSameValueReference.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useExpectSameValueReference.cjs","sources":["../../../../../packages/react-utils/src/hooks/useExpectSameValueReference.ts"],"sourcesContent":["import deepEqual from 'fast-deep-equal/es6/index.js'\nimport { useRef } from 'react'\n\n/**\n * Checks whether the next value is the same reference as the previous one\n *\n * If not, it checks whether the values are deeply equal. If not, it logs an error.\n *\n * @param next - Value to be checked.\n * @param shouldThrow - If true, it throws an error instead of logging it. Defaults to false.\n * @returns void\n * -\n * @example\n * ```ts\n * useExpectSameValueReference(style)\n * ```\n * @example\n * ```ts\n * useExpectSameValueReference(style, true)\n * ```\n * @example\n * ```ts\n * useExpectSameValueReference(style, import.meta.env.DEV)\n * ```\n */\nexport function useExpectSameValueReference<T>(next: T, shouldThrow: boolean = false) {\n\tconst previous = useRef(next)\n\n\tif (\n\t\tnext !== previous.current\n\t\t&& typeof next === 'object'\n\t\t&& typeof previous.current === 'object'\n\t\t&& deepEqual(next, previous.current)\n\t) {\n\t\tif (import.meta.env.DEV) {\n\t\t\tconsole.error(\n\t\t\t\t'Previous and next values do not match in reference although match in value. '\n\t\t\t\t\t+ 'Try declaring constants outside of the component scope. '\n\t\t\t\t\t+ 'Otherwise try to memoize callbacks with useCallback, '\n\t\t\t\t\t+ 'useReferentiallyStableCallback useEvent, useRef or useMemo.',\n\t\t\t\t{\n\t\t\t\t\tprevious: previous.current,\n\t\t\t\t\tnext,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\n\t\tif (shouldThrow) {\n\t\t\tthrow new Error('Expecting same reference for same values')\n\t\t}\n\t}\n\n\tprevious.current = next\n}\n"],"names":["useRef","deepEqual"],"mappings":";;;;AAyBO,SAAS,4BAA+B,MAAS,cAAuB,OAAO;AACrF,QAAM,WAAWA,MAAAA,OAAO,IAAI;AAE5B,MACC,SAAS,SAAS,WACf,OAAO,SAAS,YAChB,OAAO,SAAS,YAAY,YAC5BC,MAAU,MAAM,SAAS,OAAO,GAClC;AAcD,QAAI,aAAa;AAChB,YAAM,IAAI,MAAM,0CAA0C;AAAA,IAC3D;AAAA,EACD;AAEA,WAAS,UAAU;AACpB;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import equal from "fast-deep-equal/es6/index.js";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
function useExpectSameValueReference(next, shouldThrow = false) {
|
|
4
|
+
const previous = useRef(next);
|
|
5
|
+
if (next !== previous.current && typeof next === "object" && typeof previous.current === "object" && equal(next, previous.current)) {
|
|
6
|
+
if (shouldThrow) {
|
|
7
|
+
throw new Error("Expecting same reference for same values");
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
previous.current = next;
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
useExpectSameValueReference
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=useExpectSameValueReference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useExpectSameValueReference.js","sources":["../../../../../packages/react-utils/src/hooks/useExpectSameValueReference.ts"],"sourcesContent":["import deepEqual from 'fast-deep-equal/es6/index.js'\nimport { useRef } from 'react'\n\n/**\n * Checks whether the next value is the same reference as the previous one\n *\n * If not, it checks whether the values are deeply equal. If not, it logs an error.\n *\n * @param next - Value to be checked.\n * @param shouldThrow - If true, it throws an error instead of logging it. Defaults to false.\n * @returns void\n * -\n * @example\n * ```ts\n * useExpectSameValueReference(style)\n * ```\n * @example\n * ```ts\n * useExpectSameValueReference(style, true)\n * ```\n * @example\n * ```ts\n * useExpectSameValueReference(style, import.meta.env.DEV)\n * ```\n */\nexport function useExpectSameValueReference<T>(next: T, shouldThrow: boolean = false) {\n\tconst previous = useRef(next)\n\n\tif (\n\t\tnext !== previous.current\n\t\t&& typeof next === 'object'\n\t\t&& typeof previous.current === 'object'\n\t\t&& deepEqual(next, previous.current)\n\t) {\n\t\tif (import.meta.env.DEV) {\n\t\t\tconsole.error(\n\t\t\t\t'Previous and next values do not match in reference although match in value. '\n\t\t\t\t\t+ 'Try declaring constants outside of the component scope. '\n\t\t\t\t\t+ 'Otherwise try to memoize callbacks with useCallback, '\n\t\t\t\t\t+ 'useReferentiallyStableCallback useEvent, useRef or useMemo.',\n\t\t\t\t{\n\t\t\t\t\tprevious: previous.current,\n\t\t\t\t\tnext,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\n\t\tif (shouldThrow) {\n\t\t\tthrow new Error('Expecting same reference for same values')\n\t\t}\n\t}\n\n\tprevious.current = next\n}\n"],"names":["deepEqual"],"mappings":";;AAyBO,SAAS,4BAA+B,MAAS,cAAuB,OAAO;AACrF,QAAM,WAAW,OAAO,IAAI;AAE5B,MACC,SAAS,SAAS,WACf,OAAO,SAAS,YAChB,OAAO,SAAS,YAAY,YAC5BA,MAAU,MAAM,SAAS,OAAO,GAClC;AAcD,QAAI,aAAa;AAChB,YAAM,IAAI,MAAM,0CAA0C;AAAA,IAC3D;AAAA,EACD;AAEA,WAAS,UAAU;AACpB;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const useForceRender = () => {
|
|
5
|
+
const [, forceRender] = React.useReducer((s) => s + 1, 0);
|
|
6
|
+
return forceRender;
|
|
7
|
+
};
|
|
8
|
+
exports.useForceRender = useForceRender;
|
|
9
|
+
//# sourceMappingURL=useForceRender.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useForceRender.cjs","sources":["../../../../../packages/react-utils/src/hooks/useForceRender.ts"],"sourcesContent":["import { useReducer } from 'react'\n\nexport const useForceRender = () => {\n\tconst [, forceRender] = useReducer((s: number) => s + 1, 0)\n\treturn forceRender\n}\n"],"names":["useReducer"],"mappings":";;;AAEO,MAAM,iBAAiB,MAAM;AACnC,QAAM,CAAA,EAAG,WAAW,IAAIA,MAAAA,WAAW,CAAC,MAAc,IAAI,GAAG,CAAC;AAC1D,SAAO;AACR;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useForceRender.js","sources":["../../../../../packages/react-utils/src/hooks/useForceRender.ts"],"sourcesContent":["import { useReducer } from 'react'\n\nexport const useForceRender = () => {\n\tconst [, forceRender] = useReducer((s: number) => s + 1, 0)\n\treturn forceRender\n}\n"],"names":[],"mappings":";AAEO,MAAM,iBAAiB,MAAM;AACnC,QAAM,CAAA,EAAG,WAAW,IAAI,WAAW,CAAC,MAAc,IAAI,GAAG,CAAC;AAC1D,SAAO;AACR;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const count = { current: 360 };
|
|
5
|
+
function nextId() {
|
|
6
|
+
count.current += 1;
|
|
7
|
+
return `:${count.current.toString(36)}:`;
|
|
8
|
+
}
|
|
9
|
+
function useId() {
|
|
10
|
+
return React.useMemo(() => nextId(), []);
|
|
11
|
+
}
|
|
12
|
+
exports.useId = useId;
|
|
13
|
+
//# sourceMappingURL=useId.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useId.cjs","sources":["../../../../../packages/react-utils/src/hooks/useId.ts"],"sourcesContent":["import { useMemo, useRef } from 'react'\n\nconst count = { current: 360 }\n\nfunction nextId() {\n\tcount.current += 1\n\n\treturn `:${count.current.toString(36)}:`\n}\n\n/**\n * Returns a unique ID string\n * @internal\n *\n * NOTE: This hook is a temporary solution until we stop supporting React < 18\n *\n * @returns a unique id\n */\nexport function useId() {\n\treturn useMemo(() => nextId(), [])\n}\n"],"names":["useMemo"],"mappings":";;;AAEA,MAAM,QAAQ,EAAE,SAAS,IAAA;AAEzB,SAAS,SAAS;AACjB,QAAM,WAAW;AAEjB,SAAO,IAAI,MAAM,QAAQ,SAAS,EAAE,CAAC;AACtC;AAUO,SAAS,QAAQ;AACvB,SAAOA,cAAQ,MAAM,OAAA,GAAU,EAAE;AAClC;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
const count = { current: 360 };
|
|
3
|
+
function nextId() {
|
|
4
|
+
count.current += 1;
|
|
5
|
+
return `:${count.current.toString(36)}:`;
|
|
6
|
+
}
|
|
7
|
+
function useId() {
|
|
8
|
+
return useMemo(() => nextId(), []);
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
useId
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=useId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useId.js","sources":["../../../../../packages/react-utils/src/hooks/useId.ts"],"sourcesContent":["import { useMemo, useRef } from 'react'\n\nconst count = { current: 360 }\n\nfunction nextId() {\n\tcount.current += 1\n\n\treturn `:${count.current.toString(36)}:`\n}\n\n/**\n * Returns a unique ID string\n * @internal\n *\n * NOTE: This hook is a temporary solution until we stop supporting React < 18\n *\n * @returns a unique id\n */\nexport function useId() {\n\treturn useMemo(() => nextId(), [])\n}\n"],"names":[],"mappings":";AAEA,MAAM,QAAQ,EAAE,SAAS,IAAA;AAEzB,SAAS,SAAS;AACjB,QAAM,WAAW;AAEjB,SAAO,IAAI,MAAM,QAAQ,SAAS,EAAE,CAAC;AACtC;AAUO,SAAS,QAAQ;AACvB,SAAO,QAAQ,MAAM,OAAA,GAAU,EAAE;AAClC;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const useIsMounted = () => {
|
|
5
|
+
const isMountedRef = React.useRef(true);
|
|
6
|
+
React.useEffect(
|
|
7
|
+
() => {
|
|
8
|
+
isMountedRef.current = true;
|
|
9
|
+
return () => {
|
|
10
|
+
isMountedRef.current = false;
|
|
11
|
+
};
|
|
12
|
+
},
|
|
13
|
+
[]
|
|
14
|
+
);
|
|
15
|
+
return isMountedRef;
|
|
16
|
+
};
|
|
17
|
+
exports.useIsMounted = useIsMounted;
|
|
18
|
+
//# sourceMappingURL=useIsMounted.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIsMounted.cjs","sources":["../../../../../packages/react-utils/src/hooks/useIsMounted.ts"],"sourcesContent":["import { useEffect, useRef } from 'react'\n\nexport const useIsMounted = () => {\n\tconst isMountedRef = useRef(true)\n\tuseEffect(\n\t\t() => {\n\t\t\tisMountedRef.current = true\n\t\t\treturn () => {\n\t\t\t\tisMountedRef.current = false\n\t\t\t}\n\t\t},\n\t\t[],\n\t)\n\treturn isMountedRef\n}\n"],"names":["useRef","useEffect"],"mappings":";;;AAEO,MAAM,eAAe,MAAM;AACjC,QAAM,eAAeA,MAAAA,OAAO,IAAI;AAChCC,QAAAA;AAAAA,IACC,MAAM;AACL,mBAAa,UAAU;AACvB,aAAO,MAAM;AACZ,qBAAa,UAAU;AAAA,MACxB;AAAA,IACD;AAAA,IACA,CAAA;AAAA,EAAC;AAEF,SAAO;AACR;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useRef, useEffect } from "react";
|
|
2
|
+
const useIsMounted = () => {
|
|
3
|
+
const isMountedRef = useRef(true);
|
|
4
|
+
useEffect(
|
|
5
|
+
() => {
|
|
6
|
+
isMountedRef.current = true;
|
|
7
|
+
return () => {
|
|
8
|
+
isMountedRef.current = false;
|
|
9
|
+
};
|
|
10
|
+
},
|
|
11
|
+
[]
|
|
12
|
+
);
|
|
13
|
+
return isMountedRef;
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
useIsMounted
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=useIsMounted.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIsMounted.js","sources":["../../../../../packages/react-utils/src/hooks/useIsMounted.ts"],"sourcesContent":["import { useEffect, useRef } from 'react'\n\nexport const useIsMounted = () => {\n\tconst isMountedRef = useRef(true)\n\tuseEffect(\n\t\t() => {\n\t\t\tisMountedRef.current = true\n\t\t\treturn () => {\n\t\t\t\tisMountedRef.current = false\n\t\t\t}\n\t\t},\n\t\t[],\n\t)\n\treturn isMountedRef\n}\n"],"names":[],"mappings":";AAEO,MAAM,eAAe,MAAM;AACjC,QAAM,eAAe,OAAO,IAAI;AAChC;AAAA,IACC,MAAM;AACL,mBAAa,UAAU;AACvB,aAAO,MAAM;AACZ,qBAAa,UAAU;AAAA,MACxB;AAAA,IACD;AAAA,IACA,CAAA;AAAA,EAAC;AAEF,SAAO;AACR;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const compareObjects = (a, b) => {
|
|
5
|
+
if (a === b) {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
const aEntries = Object.entries(a);
|
|
9
|
+
if (aEntries.length !== Object.keys(b).length) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
for (const [key, val] of aEntries) {
|
|
13
|
+
if (!(key in b) || b[key] !== val) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
};
|
|
19
|
+
const useObjectMemo = (value) => {
|
|
20
|
+
const valueRef = React.useRef(value);
|
|
21
|
+
if (!compareObjects(valueRef.current, value)) {
|
|
22
|
+
valueRef.current = value;
|
|
23
|
+
}
|
|
24
|
+
return valueRef.current;
|
|
25
|
+
};
|
|
26
|
+
exports.useObjectMemo = useObjectMemo;
|
|
27
|
+
//# sourceMappingURL=useObjectMemo.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useObjectMemo.cjs","sources":["../../../../../packages/react-utils/src/hooks/useObjectMemo.ts"],"sourcesContent":["import { useRef } from 'react'\n\nconst compareObjects = (a: object, b: object): boolean => {\n\tif (a === b) {\n\t\treturn true\n\t}\n\tconst aEntries = Object.entries(a)\n\tif (aEntries.length !== Object.keys(b).length) {\n\t\treturn false\n\t}\n\tfor (const [key, val] of aEntries) {\n\t\tif (!(key in b) || (b as any)[key] !== val) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nexport const useObjectMemo = <A extends object>(value: A): A => {\n\tconst valueRef = useRef(value)\n\tif (!compareObjects(valueRef.current, value)) {\n\t\tvalueRef.current = value\n\t}\n\treturn valueRef.current\n}\n"],"names":["useRef"],"mappings":";;;AAEA,MAAM,iBAAiB,CAAC,GAAW,MAAuB;AACzD,MAAI,MAAM,GAAG;AACZ,WAAO;AAAA,EACR;AACA,QAAM,WAAW,OAAO,QAAQ,CAAC;AACjC,MAAI,SAAS,WAAW,OAAO,KAAK,CAAC,EAAE,QAAQ;AAC9C,WAAO;AAAA,EACR;AACA,aAAW,CAAC,KAAK,GAAG,KAAK,UAAU;AAClC,QAAI,EAAE,OAAO,MAAO,EAAU,GAAG,MAAM,KAAK;AAC3C,aAAO;AAAA,IACR;AAAA,EACD;AACA,SAAO;AACR;AAEO,MAAM,gBAAgB,CAAmB,UAAgB;AAC/D,QAAM,WAAWA,MAAAA,OAAO,KAAK;AAC7B,MAAI,CAAC,eAAe,SAAS,SAAS,KAAK,GAAG;AAC7C,aAAS,UAAU;AAAA,EACpB;AACA,SAAO,SAAS;AACjB;;"}
|