1 line
5.3 KiB
JSON
1 line
5.3 KiB
JSON
{"ast":null,"code":"import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport * as React from 'react';\n/**\n * Cache `value` related LabeledValue & options.\n */\nexport default (function (labeledValues, valueOptions) {\n var cacheRef = React.useRef({\n values: new Map(),\n options: new Map()\n });\n var filledLabeledValues = React.useMemo(function () {\n var _cacheRef$current = cacheRef.current,\n prevValueCache = _cacheRef$current.values,\n prevOptionCache = _cacheRef$current.options;\n\n // Fill label by cache\n var patchedValues = labeledValues.map(function (item) {\n if (item.label === undefined) {\n var _prevValueCache$get;\n return _objectSpread(_objectSpread({}, item), {}, {\n label: (_prevValueCache$get = prevValueCache.get(item.value)) === null || _prevValueCache$get === void 0 ? void 0 : _prevValueCache$get.label\n });\n }\n return item;\n });\n\n // Refresh cache\n var valueCache = new Map();\n var optionCache = new Map();\n patchedValues.forEach(function (item) {\n valueCache.set(item.value, item);\n optionCache.set(item.value, valueOptions.get(item.value) || prevOptionCache.get(item.value));\n });\n cacheRef.current.values = valueCache;\n cacheRef.current.options = optionCache;\n return patchedValues;\n }, [labeledValues, valueOptions]);\n var getOption = React.useCallback(function (val) {\n return valueOptions.get(val) || cacheRef.current.options.get(val);\n }, [valueOptions]);\n return [filledLabeledValues, getOption];\n});","map":{"version":3,"names":["_objectSpread","React","labeledValues","valueOptions","cacheRef","useRef","values","Map","options","filledLabeledValues","useMemo","_cacheRef$current","current","prevValueCache","prevOptionCache","patchedValues","map","item","label","undefined","_prevValueCache$get","get","value","valueCache","optionCache","forEach","set","getOption","useCallback","val"],"sources":["C:/Users/Аришина)/source/repos/PromoCursed/node_modules/rc-select/es/hooks/useCache.js"],"sourcesContent":["import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport * as React from 'react';\n/**\n * Cache `value` related LabeledValue & options.\n */\nexport default (function (labeledValues, valueOptions) {\n var cacheRef = React.useRef({\n values: new Map(),\n options: new Map()\n });\n var filledLabeledValues = React.useMemo(function () {\n var _cacheRef$current = cacheRef.current,\n prevValueCache = _cacheRef$current.values,\n prevOptionCache = _cacheRef$current.options;\n\n // Fill label by cache\n var patchedValues = labeledValues.map(function (item) {\n if (item.label === undefined) {\n var _prevValueCache$get;\n return _objectSpread(_objectSpread({}, item), {}, {\n label: (_prevValueCache$get = prevValueCache.get(item.value)) === null || _prevValueCache$get === void 0 ? void 0 : _prevValueCache$get.label\n });\n }\n return item;\n });\n\n // Refresh cache\n var valueCache = new Map();\n var optionCache = new Map();\n patchedValues.forEach(function (item) {\n valueCache.set(item.value, item);\n optionCache.set(item.value, valueOptions.get(item.value) || prevOptionCache.get(item.value));\n });\n cacheRef.current.values = valueCache;\n cacheRef.current.options = optionCache;\n return patchedValues;\n }, [labeledValues, valueOptions]);\n var getOption = React.useCallback(function (val) {\n return valueOptions.get(val) || cacheRef.current.options.get(val);\n }, [valueOptions]);\n return [filledLabeledValues, getOption];\n});"],"mappings":"AAAA,OAAOA,aAAa,MAAM,0CAA0C;AACpE,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B;AACA;AACA;AACA,gBAAgB,UAAUC,aAAa,EAAEC,YAAY,EAAE;EACrD,IAAIC,QAAQ,GAAGH,KAAK,CAACI,MAAM,CAAC;IAC1BC,MAAM,EAAE,IAAIC,GAAG,CAAC,CAAC;IACjBC,OAAO,EAAE,IAAID,GAAG,CAAC;EACnB,CAAC,CAAC;EACF,IAAIE,mBAAmB,GAAGR,KAAK,CAACS,OAAO,CAAC,YAAY;IAClD,IAAIC,iBAAiB,GAAGP,QAAQ,CAACQ,OAAO;MACtCC,cAAc,GAAGF,iBAAiB,CAACL,MAAM;MACzCQ,eAAe,GAAGH,iBAAiB,CAACH,OAAO;;IAE7C;IACA,IAAIO,aAAa,GAAGb,aAAa,CAACc,GAAG,CAAC,UAAUC,IAAI,EAAE;MACpD,IAAIA,IAAI,CAACC,KAAK,KAAKC,SAAS,EAAE;QAC5B,IAAIC,mBAAmB;QACvB,OAAOpB,aAAa,CAAC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