df4fb86f3f4cf8ccaa885b6ad73598b2.json
14.5 KB
{"ast":null,"code":"import _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport { flattenTreeData } from \"rc-tree/es/utils/treeUtil\";\nimport { fillLegacyProps } from './legacyUtil';\nexport function toArray(value) {\n if (Array.isArray(value)) {\n return value;\n }\n\n return value !== undefined ? [value] : [];\n}\nexport function findValueOption(values, options) {\n var optionMap = new Map();\n options.forEach(function (flattenItem) {\n var data = flattenItem.data;\n optionMap.set(data.value, data);\n });\n return values.map(function (val) {\n return fillLegacyProps(optionMap.get(val));\n });\n}\nexport function isValueDisabled(value, options) {\n var option = findValueOption([value], options)[0];\n\n if (option) {\n return option.disabled;\n }\n\n return false;\n}\nexport function isCheckDisabled(node) {\n return node.disabled || node.disableCheckbox || node.checkable === false;\n}\n\nfunction getLevel(_ref) {\n var parent = _ref.parent;\n var level = 0;\n var current = parent;\n\n while (current) {\n current = current.parent;\n level += 1;\n }\n\n return level;\n}\n/**\n * Before reuse `rc-tree` logic, we need to add key since TreeSelect use `value` instead of `key`.\n */\n\n\nexport function flattenOptions(options) {\n // Add missing key\n function fillKey(list) {\n return (list || []).map(function (node) {\n var value = node.value,\n key = node.key,\n children = node.children;\n\n var clone = _objectSpread(_objectSpread({}, node), {}, {\n key: 'key' in node ? key : value\n });\n\n if (children) {\n clone.children = fillKey(children);\n }\n\n return clone;\n });\n }\n\n var flattenList = flattenTreeData(fillKey(options), true);\n return flattenList.map(function (node) {\n return {\n key: node.data.key,\n data: node.data,\n level: getLevel(node)\n };\n });\n}\n\nfunction getDefaultFilterOption(optionFilterProp) {\n return function (searchValue, dataNode) {\n var value = dataNode[optionFilterProp];\n return String(value).toLowerCase().includes(String(searchValue).toLowerCase());\n };\n}\n/** Filter options and return a new options by the search text */\n\n\nexport function filterOptions(searchValue, options, _ref2) {\n var optionFilterProp = _ref2.optionFilterProp,\n filterOption = _ref2.filterOption;\n\n if (filterOption === false) {\n return options;\n }\n\n var filterOptionFunc;\n\n if (typeof filterOption === 'function') {\n filterOptionFunc = filterOption;\n } else {\n filterOptionFunc = getDefaultFilterOption(optionFilterProp);\n }\n\n function dig(list) {\n var keepAll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n return list.map(function (dataNode) {\n var children = dataNode.children;\n var match = keepAll || filterOptionFunc(searchValue, fillLegacyProps(dataNode));\n var childList = dig(children || [], match);\n\n if (match || childList.length) {\n return _objectSpread(_objectSpread({}, dataNode), {}, {\n children: childList\n });\n }\n\n return null;\n }).filter(function (node) {\n return node;\n });\n }\n\n return dig(options);\n}\nexport function getRawValueLabeled(values, prevValue, getEntityByValue, getLabelProp) {\n var valueMap = new Map();\n toArray(prevValue).forEach(function (item) {\n if (item && _typeof(item) === 'object' && 'value' in item) {\n valueMap.set(item.value, item);\n }\n });\n return values.map(function (val) {\n var item = {\n value: val\n };\n var entity = getEntityByValue(val, 'select', true);\n var label = entity ? getLabelProp(entity.data) : val;\n\n if (valueMap.has(val)) {\n var labeledValue = valueMap.get(val);\n item.label = 'label' in labeledValue ? labeledValue.label : label;\n\n if ('halfChecked' in labeledValue) {\n item.halfChecked = labeledValue.halfChecked;\n }\n } else {\n item.label = label;\n }\n\n return item;\n });\n}\nexport function addValue(rawValues, value) {\n var values = new Set(rawValues);\n values.add(value);\n return Array.from(values);\n}\nexport function removeValue(rawValues, value) {\n var values = new Set(rawValues);\n values.delete(value);\n return Array.from(values);\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-tree-select/es/utils/valueUtil.js"],"names":["_typeof","_objectSpread","flattenTreeData","fillLegacyProps","toArray","value","Array","isArray","undefined","findValueOption","values","options","optionMap","Map","forEach","flattenItem","data","set","map","val","get","isValueDisabled","option","disabled","isCheckDisabled","node","disableCheckbox","checkable","getLevel","_ref","parent","level","current","flattenOptions","fillKey","list","key","children","clone","flattenList","getDefaultFilterOption","optionFilterProp","searchValue","dataNode","String","toLowerCase","includes","filterOptions","_ref2","filterOption","filterOptionFunc","dig","keepAll","arguments","length","match","childList","filter","getRawValueLabeled","prevValue","getEntityByValue","getLabelProp","valueMap","item","entity","label","has","labeledValue","halfChecked","addValue","rawValues","Set","add","from","removeValue","delete"],"mappings":"AAAA,OAAOA,OAAP,MAAoB,mCAApB;AACA,OAAOC,aAAP,MAA0B,0CAA1B;AACA,SAASC,eAAT,QAAgC,2BAAhC;AACA,SAASC,eAAT,QAAgC,cAAhC;AACA,OAAO,SAASC,OAAT,CAAiBC,KAAjB,EAAwB;AAC7B,MAAIC,KAAK,CAACC,OAAN,CAAcF,KAAd,CAAJ,EAA0B;AACxB,WAAOA,KAAP;AACD;;AAED,SAAOA,KAAK,KAAKG,SAAV,GAAsB,CAACH,KAAD,CAAtB,GAAgC,EAAvC;AACD;AACD,OAAO,SAASI,eAAT,CAAyBC,MAAzB,EAAiCC,OAAjC,EAA0C;AAC/C,MAAIC,SAAS,GAAG,IAAIC,GAAJ,EAAhB;AACAF,EAAAA,OAAO,CAACG,OAAR,CAAgB,UAAUC,WAAV,EAAuB;AACrC,QAAIC,IAAI,GAAGD,WAAW,CAACC,IAAvB;AACAJ,IAAAA,SAAS,CAACK,GAAV,CAAcD,IAAI,CAACX,KAAnB,EAA0BW,IAA1B;AACD,GAHD;AAIA,SAAON,MAAM,CAACQ,GAAP,CAAW,UAAUC,GAAV,EAAe;AAC/B,WAAOhB,eAAe,CAACS,SAAS,CAACQ,GAAV,CAAcD,GAAd,CAAD,CAAtB;AACD,GAFM,CAAP;AAGD;AACD,OAAO,SAASE,eAAT,CAAyBhB,KAAzB,EAAgCM,OAAhC,EAAyC;AAC9C,MAAIW,MAAM,GAAGb,eAAe,CAAC,CAACJ,KAAD,CAAD,EAAUM,OAAV,CAAf,CAAkC,CAAlC,CAAb;;AAEA,MAAIW,MAAJ,EAAY;AACV,WAAOA,MAAM,CAACC,QAAd;AACD;;AAED,SAAO,KAAP;AACD;AACD,OA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AR,CAAf,GAA+BG,GAAjD;;AAEA,QAAI2C,QAAQ,CAACI,GAAT,CAAa/C,GAAb,CAAJ,EAAuB;AACrB,UAAIgD,YAAY,GAAGL,QAAQ,CAAC1C,GAAT,CAAaD,GAAb,CAAnB;AACA4C,MAAAA,IAAI,CAACE,KAAL,GAAa,WAAWE,YAAX,GAA0BA,YAAY,CAACF,KAAvC,GAA+CA,KAA5D;;AAEA,UAAI,iBAAiBE,YAArB,EAAmC;AACjCJ,QAAAA,IAAI,CAACK,WAAL,GAAmBD,YAAY,CAACC,WAAhC;AACD;AACF,KAPD,MAOO;AACLL,MAAAA,IAAI,CAACE,KAAL,GAAaA,KAAb;AACD;;AAED,WAAOF,IAAP;AACD,GAnBM,CAAP;AAoBD;AACD,OAAO,SAASM,QAAT,CAAkBC,SAAlB,EAA6BjE,KAA7B,EAAoC;AACzC,MAAIK,MAAM,GAAG,IAAI6D,GAAJ,CAAQD,SAAR,CAAb;AACA5D,EAAAA,MAAM,CAAC8D,GAAP,CAAWnE,KAAX;AACA,SAAOC,KAAK,CAACmE,IAAN,CAAW/D,MAAX,CAAP;AACD;AACD,OAAO,SAASgE,WAAT,CAAqBJ,SAArB,EAAgCjE,KAAhC,EAAuC;AAC5C,MAAIK,MAAM,GAAG,IAAI6D,GAAJ,CAAQD,SAAR,CAAb;AACA5D,EAAAA,MAAM,CAACiE,MAAP,CAActE,KAAd;AACA,SAAOC,KAAK,CAACmE,IAAN,CAAW/D,MAAX,CAAP;AACD","sourcesContent":["import _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport { flattenTreeData } from \"rc-tree/es/utils/treeUtil\";\nimport { fillLegacyProps } from './legacyUtil';\nexport function toArray(value) {\n if (Array.isArray(value)) {\n return value;\n }\n\n return value !== undefined ? [value] : [];\n}\nexport function findValueOption(values, options) {\n var optionMap = new Map();\n options.forEach(function (flattenItem) {\n var data = flattenItem.data;\n optionMap.set(data.value, data);\n });\n return values.map(function (val) {\n return fillLegacyProps(optionMap.get(val));\n });\n}\nexport function isValueDisabled(value, options) {\n var option = findValueOption([value], options)[0];\n\n if (option) {\n return option.disabled;\n }\n\n return false;\n}\nexport function isCheckDisabled(node) {\n return node.disabled || node.disableCheckbox || node.checkable === false;\n}\n\nfunction getLevel(_ref) {\n var parent = _ref.parent;\n var level = 0;\n var current = parent;\n\n while (current) {\n current = current.parent;\n level += 1;\n }\n\n return level;\n}\n/**\n * Before reuse `rc-tree` logic, we need to add key since TreeSelect use `value` instead of `key`.\n */\n\n\nexport function flattenOptions(options) {\n // Add missing key\n function fillKey(list) {\n return (list || []).map(function (node) {\n var value = node.value,\n key = node.key,\n children = node.children;\n\n var clone = _objectSpread(_objectSpread({}, node), {}, {\n key: 'key' in node ? key : value\n });\n\n if (children) {\n clone.children = fillKey(children);\n }\n\n return clone;\n });\n }\n\n var flattenList = flattenTreeData(fillKey(options), true);\n return flattenList.map(function (node) {\n return {\n key: node.data.key,\n data: node.data,\n level: getLevel(node)\n };\n });\n}\n\nfunction getDefaultFilterOption(optionFilterProp) {\n return function (searchValue, dataNode) {\n var value = dataNode[optionFilterProp];\n return String(value).toLowerCase().includes(String(searchValue).toLowerCase());\n };\n}\n/** Filter options and return a new options by the search text */\n\n\nexport function filterOptions(searchValue, options, _ref2) {\n var optionFilterProp = _ref2.optionFilterProp,\n filterOption = _ref2.filterOption;\n\n if (filterOption === false) {\n return options;\n }\n\n var filterOptionFunc;\n\n if (typeof filterOption === 'function') {\n filterOptionFunc = filterOption;\n } else {\n filterOptionFunc = getDefaultFilterOption(optionFilterProp);\n }\n\n function dig(list) {\n var keepAll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n return list.map(function (dataNode) {\n var children = dataNode.children;\n var match = keepAll || filterOptionFunc(searchValue, fillLegacyProps(dataNode));\n var childList = dig(children || [], match);\n\n if (match || childList.length) {\n return _objectSpread(_objectSpread({}, dataNode), {}, {\n children: childList\n });\n }\n\n return null;\n }).filter(function (node) {\n return node;\n });\n }\n\n return dig(options);\n}\nexport function getRawValueLabeled(values, prevValue, getEntityByValue, getLabelProp) {\n var valueMap = new Map();\n toArray(prevValue).forEach(function (item) {\n if (item && _typeof(item) === 'object' && 'value' in item) {\n valueMap.set(item.value, item);\n }\n });\n return values.map(function (val) {\n var item = {\n value: val\n };\n var entity = getEntityByValue(val, 'select', true);\n var label = entity ? getLabelProp(entity.data) : val;\n\n if (valueMap.has(val)) {\n var labeledValue = valueMap.get(val);\n item.label = 'label' in labeledValue ? labeledValue.label : label;\n\n if ('halfChecked' in labeledValue) {\n item.halfChecked = labeledValue.halfChecked;\n }\n } else {\n item.label = label;\n }\n\n return item;\n });\n}\nexport function addValue(rawValues, value) {\n var values = new Set(rawValues);\n values.add(value);\n return Array.from(values);\n}\nexport function removeValue(rawValues, value) {\n var values = new Set(rawValues);\n values.delete(value);\n return Array.from(values);\n}"]},"metadata":{},"sourceType":"module"}