05e2214d0b1970b472b527d3fd0cf58c.json
4.66 KB
{"ast":null,"code":"import * as React from 'react';\nexport function isDisabled(dataNode, skipType) {\n if (!dataNode) {\n return true;\n }\n\n var _dataNode$data = dataNode.data,\n disabled = _dataNode$data.disabled,\n disableCheckbox = _dataNode$data.disableCheckbox;\n\n switch (skipType) {\n case 'select':\n return disabled;\n\n case 'checkbox':\n return disabled || disableCheckbox;\n }\n\n return false;\n}\nexport default function useKeyValueMapping(cacheKeyMap, cacheValueMap) {\n var getEntityByKey = React.useCallback(function (key) {\n var skipType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'select';\n var ignoreDisabledCheck = arguments.length > 2 ? arguments[2] : undefined;\n var dataNode = cacheKeyMap.get(key);\n\n if (!ignoreDisabledCheck && isDisabled(dataNode, skipType)) {\n return null;\n }\n\n return dataNode;\n }, [cacheKeyMap]);\n var getEntityByValue = React.useCallback(function (value) {\n var skipType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'select';\n var ignoreDisabledCheck = arguments.length > 2 ? arguments[2] : undefined;\n var dataNode = cacheValueMap.get(value);\n\n if (!ignoreDisabledCheck && isDisabled(dataNode, skipType)) {\n return null;\n }\n\n return dataNode;\n }, [cacheValueMap]);\n return [getEntityByKey, getEntityByValue];\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-tree-select/es/hooks/useKeyValueMapping.js"],"names":["React","isDisabled","dataNode","skipType","_dataNode$data","data","disabled","disableCheckbox","useKeyValueMapping","cacheKeyMap","cacheValueMap","getEntityByKey","useCallback","key","arguments","length","undefined","ignoreDisabledCheck","get","getEntityByValue","value"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,OAAO,SAASC,UAAT,CAAoBC,QAApB,EAA8BC,QAA9B,EAAwC;AAC7C,MAAI,CAACD,QAAL,EAAe;AACb,WAAO,IAAP;AACD;;AAED,MAAIE,cAAc,GAAGF,QAAQ,CAACG,IAA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GAAGQ,aAAa,CAACQ,GAAd,CAAkBE,KAAlB,CAAf;;AAEA,QAAI,CAACH,mBAAD,IAAwBhB,UAAU,CAACC,QAAD,EAAWC,QAAX,CAAtC,EAA4D;AAC1D,aAAO,IAAP;AACD;;AAED,WAAOD,QAAP;AACD,GAVsB,EAUpB,CAACQ,aAAD,CAVoB,CAAvB;AAWA,SAAO,CAACC,cAAD,EAAiBQ,gBAAjB,CAAP;AACD","sourcesContent":["import * as React from 'react';\nexport function isDisabled(dataNode, skipType) {\n if (!dataNode) {\n return true;\n }\n\n var _dataNode$data = dataNode.data,\n disabled = _dataNode$data.disabled,\n disableCheckbox = _dataNode$data.disableCheckbox;\n\n switch (skipType) {\n case 'select':\n return disabled;\n\n case 'checkbox':\n return disabled || disableCheckbox;\n }\n\n return false;\n}\nexport default function useKeyValueMapping(cacheKeyMap, cacheValueMap) {\n var getEntityByKey = React.useCallback(function (key) {\n var skipType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'select';\n var ignoreDisabledCheck = arguments.length > 2 ? arguments[2] : undefined;\n var dataNode = cacheKeyMap.get(key);\n\n if (!ignoreDisabledCheck && isDisabled(dataNode, skipType)) {\n return null;\n }\n\n return dataNode;\n }, [cacheKeyMap]);\n var getEntityByValue = React.useCallback(function (value) {\n var skipType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'select';\n var ignoreDisabledCheck = arguments.length > 2 ? arguments[2] : undefined;\n var dataNode = cacheValueMap.get(value);\n\n if (!ignoreDisabledCheck && isDisabled(dataNode, skipType)) {\n return null;\n }\n\n return dataNode;\n }, [cacheValueMap]);\n return [getEntityByKey, getEntityByValue];\n}"]},"metadata":{},"sourceType":"module"}