1 line
6.2 KiB
JSON
1 line
6.2 KiB
JSON
{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport { useRef, useState, useEffect } from 'react';\n/**\n * Execute code before next frame but async\n */\nexport function useLayoutState(defaultState) {\n var stateRef = useRef(defaultState);\n var _useState = useState({}),\n _useState2 = _slicedToArray(_useState, 2),\n forceUpdate = _useState2[1];\n var lastPromiseRef = useRef(null);\n var updateBatchRef = useRef([]);\n function setFrameState(updater) {\n updateBatchRef.current.push(updater);\n var promise = Promise.resolve();\n lastPromiseRef.current = promise;\n promise.then(function () {\n if (lastPromiseRef.current === promise) {\n var prevBatch = updateBatchRef.current;\n var prevState = stateRef.current;\n updateBatchRef.current = [];\n prevBatch.forEach(function (batchUpdater) {\n stateRef.current = batchUpdater(stateRef.current);\n });\n lastPromiseRef.current = null;\n if (prevState !== stateRef.current) {\n forceUpdate({});\n }\n }\n });\n }\n useEffect(function () {\n return function () {\n lastPromiseRef.current = null;\n };\n }, []);\n return [stateRef.current, setFrameState];\n}\n\n/** Lock frame, when frame pass reset the lock. */\nexport function useTimeoutLock(defaultState) {\n var frameRef = useRef(defaultState || null);\n var timeoutRef = useRef();\n function cleanUp() {\n window.clearTimeout(timeoutRef.current);\n }\n function setState(newState) {\n frameRef.current = newState;\n cleanUp();\n timeoutRef.current = window.setTimeout(function () {\n frameRef.current = null;\n timeoutRef.current = undefined;\n }, 100);\n }\n function getState() {\n return frameRef.current;\n }\n useEffect(function () {\n return cleanUp;\n }, []);\n return [setState, getState];\n}","map":{"version":3,"names":["_slicedToArray","useRef","useState","useEffect","useLayoutState","defaultState","stateRef","_useState","_useState2","forceUpdate","lastPromiseRef","updateBatchRef","setFrameState","updater","current","push","promise","Promise","resolve","then","prevBatch","prevState","forEach","batchUpdater","useTimeoutLock","frameRef","timeoutRef","cleanUp","window","clearTimeout","setState","newState","setTimeout","undefined","getState"],"sources":["C:/Users/Аришина)/Desktop/promo/node_modules/rc-table/es/hooks/useFrame.js"],"sourcesContent":["import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport { useRef, useState, useEffect } from 'react';\n/**\n * Execute code before next frame but async\n */\nexport function useLayoutState(defaultState) {\n var stateRef = useRef(defaultState);\n var _useState = useState({}),\n _useState2 = _slicedToArray(_useState, 2),\n forceUpdate = _useState2[1];\n var lastPromiseRef = useRef(null);\n var updateBatchRef = useRef([]);\n function setFrameState(updater) {\n updateBatchRef.current.push(updater);\n var promise = Promise.resolve();\n lastPromiseRef.current = promise;\n promise.then(function () {\n if (lastPromiseRef.current === promise) {\n var prevBatch = updateBatchRef.current;\n var prevState = stateRef.current;\n updateBatchRef.current = [];\n prevBatch.forEach(function (batchUpdater) {\n stateRef.current = batchUpdater(stateRef.current);\n });\n lastPromiseRef.current = null;\n if (prevState !== stateRef.current) {\n forceUpdate({});\n }\n }\n });\n }\n useEffect(function () {\n return function () {\n lastPromiseRef.current = null;\n };\n }, []);\n return [stateRef.current, setFrameState];\n}\n\n/** Lock frame, when frame pass reset the lock. */\nexport function useTimeoutLock(defaultState) {\n var frameRef = useRef(defaultState || null);\n var timeoutRef = useRef();\n function cleanUp() {\n window.clearTimeout(timeoutRef.current);\n }\n function setState(newState) {\n frameRef.current = newState;\n cleanUp();\n timeoutRef.current = window.setTimeout(function () {\n frameRef.current = null;\n timeoutRef.current = undefined;\n }, 100);\n }\n function getState() {\n return frameRef.current;\n }\n useEffect(function () {\n return cleanUp;\n }, []);\n return [setState, getState];\n}"],"mappings":"AAAA,OAAOA,cAAc,MAAM,0CAA0C;AACrE,SAASC,MAAM,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AACnD;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACC,YAAY,EAAE;EAC3C,IAAIC,QAAQ,GAAGL,MAAM,CAACI,YAAY,CAAC;EACnC,IAAIE,SAAS,GAAGL,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC1BM,UAAU,GAAGR,cAAc,CAACO,SAAS,E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