0dc458062c006da087dc199655451671.json
24.4 KB
{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _toArray from \"@babel/runtime/helpers/esm/toArray\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport warning from \"rc-util/es/warning\";\nimport { toArray } from './commonUtil';\n\nfunction getKey(data, index) {\n var key = data.key;\n var value;\n\n if ('value' in data) {\n value = data.value;\n }\n\n if (key !== null && key !== undefined) {\n return key;\n }\n\n if (value !== undefined) {\n return value;\n }\n\n return \"rc-index-key-\".concat(index);\n}\n/**\n * Flat options into flatten list.\n * We use `optionOnly` here is aim to avoid user use nested option group.\n * Here is simply set `key` to the index if not provided.\n */\n\n\nexport function flattenOptions(options) {\n var flattenList = [];\n\n function dig(list, isGroupOption) {\n list.forEach(function (data) {\n if (isGroupOption || !('options' in data)) {\n // Option\n flattenList.push({\n key: getKey(data, flattenList.length),\n groupOption: isGroupOption,\n data: data\n });\n } else {\n // Option Group\n flattenList.push({\n key: getKey(data, flattenList.length),\n group: true,\n data: data\n });\n dig(data.options, true);\n }\n });\n }\n\n dig(options, false);\n return flattenList;\n}\n/**\n * Inject `props` into `option` for legacy usage\n */\n\nfunction injectPropsWithOption(option) {\n var newOption = _objectSpread({}, option);\n\n if (!('props' in newOption)) {\n Object.defineProperty(newOption, 'props', {\n get: function get() {\n warning(false, 'Return type is option instead of Option instance. Please read value directly instead of reading from `props`.');\n return newOption;\n }\n });\n }\n\n return newOption;\n}\n\nexport function findValueOption(values, options) {\n var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},\n _ref$prevValueOptions = _ref.prevValueOptions,\n prevValueOptions = _ref$prevValueOptions === void 0 ? [] : _ref$prevValueOptions;\n\n var optionMap = new Map();\n options.forEach(function (flattenItem) {\n if (!flattenItem.group) {\n var data = flattenItem.data; // Check if match\n\n optionMap.set(data.value, data);\n }\n });\n return values.map(function (val) {\n var option = optionMap.get(val); // Fallback to try to find prev options\n\n if (!option) {\n option = _objectSpread({}, prevValueOptions.find(function (opt) {\n return opt._INTERNAL_OPTION_VALUE_ === val;\n }));\n }\n\n return injectPropsWithOption(option);\n });\n}\nexport var getLabeledValue = function getLabeledValue(value, _ref2) {\n var options = _ref2.options,\n prevValue = _ref2.prevValue,\n labelInValue = _ref2.labelInValue,\n optionLabelProp = _ref2.optionLabelProp;\n var item = findValueOption([value], options)[0];\n var result = {\n value: value\n };\n var prevValItem;\n var prevValues = toArray(prevValue);\n\n if (labelInValue) {\n prevValItem = prevValues.find(function (prevItem) {\n if (_typeof(prevItem) === 'object' && 'value' in prevItem) {\n return prevItem.value === value;\n } // [Legacy] Support `key` as `value`\n\n\n return prevItem.key === value;\n });\n }\n\n if (prevValItem && _typeof(prevValItem) === 'object' && 'label' in prevValItem) {\n result.label = prevValItem.label;\n\n if (item && typeof prevValItem.label === 'string' && typeof item[optionLabelProp] === 'string' && prevValItem.label.trim() !== item[optionLabelProp].trim()) {\n warning(false, '`label` of `value` is not same as `label` in Select options.');\n }\n } else if (item && optionLabelProp in item) {\n result.label = item[optionLabelProp];\n } else {\n result.label = value;\n } // Used for motion control\n\n\n result.key = result.value;\n return result;\n};\n\nfunction toRawString(content) {\n return toArray(content).join('');\n}\n/** Filter single option if match the search text */\n\n\nfunction getFilterFunction(optionFilterProp) {\n return function (searchValue, option) {\n var lowerSearchText = searchValue.toLowerCase(); // Group label search\n\n if ('options' in option) {\n return toRawString(option.label).toLowerCase().includes(lowerSearchText);\n } // Option value search\n\n\n var rawValue = option[optionFilterProp];\n var value = toRawString(rawValue).toLowerCase();\n return value.includes(lowerSearchText);\n };\n}\n/** Filter options and return a new options by the search text */\n\n\nexport function filterOptions(searchValue, options, _ref3) {\n var optionFilterProp = _ref3.optionFilterProp,\n filterOption = _ref3.filterOption;\n var filteredOptions = [];\n var filterFunc;\n\n if (filterOption === false) {\n return _toConsumableArray(options);\n }\n\n if (typeof filterOption === 'function') {\n filterFunc = filterOption;\n } else {\n filterFunc = getFilterFunction(optionFilterProp);\n }\n\n options.forEach(function (item) {\n // Group should check child options\n if ('options' in item) {\n // Check group first\n var matchGroup = filterFunc(searchValue, item);\n\n if (matchGroup) {\n filteredOptions.push(item);\n } else {\n // Check option\n var subOptions = item.options.filter(function (subItem) {\n return filterFunc(searchValue, subItem);\n });\n\n if (subOptions.length) {\n filteredOptions.push(_objectSpread(_objectSpread({}, item), {}, {\n options: subOptions\n }));\n }\n }\n\n return;\n }\n\n if (filterFunc(searchValue, injectPropsWithOption(item))) {\n filteredOptions.push(item);\n }\n });\n return filteredOptions;\n}\nexport function getSeparatedContent(text, tokens) {\n if (!tokens || !tokens.length) {\n return null;\n }\n\n var match = false;\n\n function separate(str, _ref4) {\n var _ref5 = _toArray(_ref4),\n token = _ref5[0],\n restTokens = _ref5.slice(1);\n\n if (!token) {\n return [str];\n }\n\n var list = str.split(token);\n match = match || list.length > 1;\n return list.reduce(function (prevList, unitStr) {\n return [].concat(_toConsumableArray(prevList), _toConsumableArray(separate(unitStr, restTokens)));\n }, []).filter(function (unit) {\n return unit;\n });\n }\n\n var list = separate(text, tokens);\n return match ? list : null;\n}\nexport function isValueDisabled(value, options) {\n var option = findValueOption([value], options)[0];\n return option.disabled;\n}\n/**\n * `tags` mode should fill un-list item into the option list\n */\n\nexport function fillOptionsWithMissingValue(options, value, optionLabelProp, labelInValue) {\n var values = toArray(value).slice().sort();\n\n var cloneOptions = _toConsumableArray(options); // Convert options value to set\n\n\n var optionValues = new Set();\n options.forEach(function (opt) {\n if (opt.options) {\n opt.options.forEach(function (subOpt) {\n optionValues.add(subOpt.value);\n });\n } else {\n optionValues.add(opt.value);\n }\n }); // Fill missing value\n\n values.forEach(function (item) {\n var val = labelInValue ? item.value : item;\n\n if (!optionValues.has(val)) {\n var _ref6;\n\n cloneOptions.push(labelInValue ? (_ref6 = {}, _defineProperty(_ref6, optionLabelProp, item.label), _defineProperty(_ref6, \"value\", val), _ref6) : {\n value: val\n });\n }\n });\n return cloneOptions;\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-select/es/utils/valueUtil.js"],"names":["_defineProperty","_toArray","_toConsumableArray","_typeof","_objectSpread","warning","toArray","getKey","data","index","key","value","undefined","concat","flattenOptions","options","flattenList","dig","list","isGroupOption","forEach","push","length","groupOption","group","injectPropsWithOption","option","newOption","Object","defineProperty","get","findValueOption","values","_ref","arguments","_ref$prevValueOptions","prevValueOptions","optionMap","Map","flattenItem","set","map","val","find","opt","_INTERNAL_OPTION_VALUE_","getLabeledValue","_ref2","prevValue","labelInValue","optionLabelProp","item","result","prevValItem","prevValues","prevItem","label","trim","toRawString","content","join","getFilterFunction","optionFilterProp","searchValue","lowerSearchText","toLowerCase","includes","rawValue","filterOptions","_ref3","filterOption","filteredOptions","filterFunc","matchGroup","subOptions","filter","subItem","getSeparatedContent","text","tokens","match","separate","str","_ref4","_ref5","token","restTokens","slice","split","reduce","prevList","unitStr","unit","isValueDisabled","disabled","fillOptionsWithMissingValue","sort","cloneOptions","optionValues","Set","subOpt","add","has","_ref6"],"mappings":"AAAA,OAAOA,eAAP,MAA4B,2CAA5B;AACA,OAAOC,QAAP,MAAqB,oCAArB;AACA,OAAOC,kBAAP,MAA+B,8CAA/B;AACA,OAAOC,OAAP,MAAoB,mCAApB;AACA,OAAOC,aAAP,MAA0B,0CAA1B;AACA,OAAOC,OAAP,MAAoB,oBAApB;AACA,SAASC,OAAT,QAAwB,cAAxB;;AAEA,SAASC,MAAT,CAAgBC,IAAhB,EAAsBC,KAAtB,EAA6B;AAC3B,MAAIC,GAAG,GAAGF,IAAI,CAACE,GAAf;AACA,MAAIC,KAAJ;;AAEA,MAAI,WAAWH,IAAf,EAAqB;AACnBG,IAAAA,KAAK,GAAGH,IAAI,CAACG,KAAb;AACD;;AAED,MAAID,GAAG,KAAK,IAAR,IAAgBA,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ime/helpers/esm/defineProperty\";\nimport _toArray from \"@babel/runtime/helpers/esm/toArray\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport warning from \"rc-util/es/warning\";\nimport { toArray } from './commonUtil';\n\nfunction getKey(data, index) {\n var key = data.key;\n var value;\n\n if ('value' in data) {\n value = data.value;\n }\n\n if (key !== null && key !== undefined) {\n return key;\n }\n\n if (value !== undefined) {\n return value;\n }\n\n return \"rc-index-key-\".concat(index);\n}\n/**\n * Flat options into flatten list.\n * We use `optionOnly` here is aim to avoid user use nested option group.\n * Here is simply set `key` to the index if not provided.\n */\n\n\nexport function flattenOptions(options) {\n var flattenList = [];\n\n function dig(list, isGroupOption) {\n list.forEach(function (data) {\n if (isGroupOption || !('options' in data)) {\n // Option\n flattenList.push({\n key: getKey(data, flattenList.length),\n groupOption: isGroupOption,\n data: data\n });\n } else {\n // Option Group\n flattenList.push({\n key: getKey(data, flattenList.length),\n group: true,\n data: data\n });\n dig(data.options, true);\n }\n });\n }\n\n dig(options, false);\n return flattenList;\n}\n/**\n * Inject `props` into `option` for legacy usage\n */\n\nfunction injectPropsWithOption(option) {\n var newOption = _objectSpread({}, option);\n\n if (!('props' in newOption)) {\n Object.defineProperty(newOption, 'props', {\n get: function get() {\n warning(false, 'Return type is option instead of Option instance. Please read value directly instead of reading from `props`.');\n return newOption;\n }\n });\n }\n\n return newOption;\n}\n\nexport function findValueOption(values, options) {\n var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},\n _ref$prevValueOptions = _ref.prevValueOptions,\n prevValueOptions = _ref$prevValueOptions === void 0 ? [] : _ref$prevValueOptions;\n\n var optionMap = new Map();\n options.forEach(function (flattenItem) {\n if (!flattenItem.group) {\n var data = flattenItem.data; // Check if match\n\n optionMap.set(data.value, data);\n }\n });\n return values.map(function (val) {\n var option = optionMap.get(val); // Fallback to try to find prev options\n\n if (!option) {\n option = _objectSpread({}, prevValueOptions.find(function (opt) {\n return opt._INTERNAL_OPTION_VALUE_ === val;\n }));\n }\n\n return injectPropsWithOption(option);\n });\n}\nexport var getLabeledValue = function getLabeledValue(value, _ref2) {\n var options = _ref2.options,\n prevValue = _ref2.prevValue,\n labelInValue = _ref2.labelInValue,\n optionLabelProp = _ref2.optionLabelProp;\n var item = findValueOption([value], options)[0];\n var result = {\n value: value\n };\n var prevValItem;\n var prevValues = toArray(prevValue);\n\n if (labelInValue) {\n prevValItem = prevValues.find(function (prevItem) {\n if (_typeof(prevItem) === 'object' && 'value' in prevItem) {\n return prevItem.value === value;\n } // [Legacy] Support `key` as `value`\n\n\n return prevItem.key === value;\n });\n }\n\n if (prevValItem && _typeof(prevValItem) === 'object' && 'label' in prevValItem) {\n result.label = prevValItem.label;\n\n if (item && typeof prevValItem.label === 'string' && typeof item[optionLabelProp] === 'string' && prevValItem.label.trim() !== item[optionLabelProp].trim()) {\n warning(false, '`label` of `value` is not same as `label` in Select options.');\n }\n } else if (item && optionLabelProp in item) {\n result.label = item[optionLabelProp];\n } else {\n result.label = value;\n } // Used for motion control\n\n\n result.key = result.value;\n return result;\n};\n\nfunction toRawString(content) {\n return toArray(content).join('');\n}\n/** Filter single option if match the search text */\n\n\nfunction getFilterFunction(optionFilterProp) {\n return function (searchValue, option) {\n var lowerSearchText = searchValue.toLowerCase(); // Group label search\n\n if ('options' in option) {\n return toRawString(option.label).toLowerCase().includes(lowerSearchText);\n } // Option value search\n\n\n var rawValue = option[optionFilterProp];\n var value = toRawString(rawValue).toLowerCase();\n return value.includes(lowerSearchText);\n };\n}\n/** Filter options and return a new options by the search text */\n\n\nexport function filterOptions(searchValue, options, _ref3) {\n var optionFilterProp = _ref3.optionFilterProp,\n filterOption = _ref3.filterOption;\n var filteredOptions = [];\n var filterFunc;\n\n if (filterOption === false) {\n return _toConsumableArray(options);\n }\n\n if (typeof filterOption === 'function') {\n filterFunc = filterOption;\n } else {\n filterFunc = getFilterFunction(optionFilterProp);\n }\n\n options.forEach(function (item) {\n // Group should check child options\n if ('options' in item) {\n // Check group first\n var matchGroup = filterFunc(searchValue, item);\n\n if (matchGroup) {\n filteredOptions.push(item);\n } else {\n // Check option\n var subOptions = item.options.filter(function (subItem) {\n return filterFunc(searchValue, subItem);\n });\n\n if (subOptions.length) {\n filteredOptions.push(_objectSpread(_objectSpread({}, item), {}, {\n options: subOptions\n }));\n }\n }\n\n return;\n }\n\n if (filterFunc(searchValue, injectPropsWithOption(item))) {\n filteredOptions.push(item);\n }\n });\n return filteredOptions;\n}\nexport function getSeparatedContent(text, tokens) {\n if (!tokens || !tokens.length) {\n return null;\n }\n\n var match = false;\n\n function separate(str, _ref4) {\n var _ref5 = _toArray(_ref4),\n token = _ref5[0],\n restTokens = _ref5.slice(1);\n\n if (!token) {\n return [str];\n }\n\n var list = str.split(token);\n match = match || list.length > 1;\n return list.reduce(function (prevList, unitStr) {\n return [].concat(_toConsumableArray(prevList), _toConsumableArray(separate(unitStr, restTokens)));\n }, []).filter(function (unit) {\n return unit;\n });\n }\n\n var list = separate(text, tokens);\n return match ? list : null;\n}\nexport function isValueDisabled(value, options) {\n var option = findValueOption([value], options)[0];\n return option.disabled;\n}\n/**\n * `tags` mode should fill un-list item into the option list\n */\n\nexport function fillOptionsWithMissingValue(options, value, optionLabelProp, labelInValue) {\n var values = toArray(value).slice().sort();\n\n var cloneOptions = _toConsumableArray(options); // Convert options value to set\n\n\n var optionValues = new Set();\n options.forEach(function (opt) {\n if (opt.options) {\n opt.options.forEach(function (subOpt) {\n optionValues.add(subOpt.value);\n });\n } else {\n optionValues.add(opt.value);\n }\n }); // Fill missing value\n\n values.forEach(function (item) {\n var val = labelInValue ? item.value : item;\n\n if (!optionValues.has(val)) {\n var _ref6;\n\n cloneOptions.push(labelInValue ? (_ref6 = {}, _defineProperty(_ref6, optionLabelProp, item.label), _defineProperty(_ref6, \"value\", val), _ref6) : {\n value: val\n });\n }\n });\n return cloneOptions;\n}"]},"metadata":{},"sourceType":"module"}