1 line
7.8 KiB
JSON
1 line
7.8 KiB
JSON
|
{"ast":null,"code":"import { SEARCH_MARK } from \"../hooks/useSearchOptions\";\nexport var VALUE_SPLIT = '__RC_CASCADER_SPLIT__';\nexport var SHOW_PARENT = 'SHOW_PARENT';\nexport var SHOW_CHILD = 'SHOW_CHILD';\n\n/**\n * Will convert value to string, and join with `VALUE_SPLIT`\n */\nexport function toPathKey(value) {\n return value.join(VALUE_SPLIT);\n}\n\n/**\n * Batch convert value to string, and join with `VALUE_SPLIT`\n */\nexport function toPathKeys(value) {\n return value.map(toPathKey);\n}\nexport function toPathValueStr(pathKey) {\n return pathKey.split(VALUE_SPLIT);\n}\nexport function fillFieldNames(fieldNames) {\n var _ref = fieldNames || {},\n label = _ref.label,\n value = _ref.value,\n children = _ref.children;\n var val = value || 'value';\n return {\n label: label || 'label',\n value: val,\n key: val,\n children: children || 'children'\n };\n}\nexport function isLeaf(option, fieldNames) {\n var _option$isLeaf, _option;\n return (_option$isLeaf = option.isLeaf) !== null && _option$isLeaf !== void 0 ? _option$isLeaf : !((_option = option[fieldNames.children]) !== null && _option !== void 0 && _option.length);\n}\nexport function scrollIntoParentView(element) {\n var parent = element.parentElement;\n if (!parent) {\n return;\n }\n var elementToParent = element.offsetTop - parent.offsetTop; // offsetParent may not be parent.\n if (elementToParent - parent.scrollTop < 0) {\n parent.scrollTo({\n top: elementToParent\n });\n } else if (elementToParent + element.offsetHeight - parent.scrollTop > parent.offsetHeight) {\n parent.scrollTo({\n top: elementToParent + element.offsetHeight - parent.offsetHeight\n });\n }\n}\nexport function getFullPathKeys(options, fieldNames) {\n return options.map(function (item) {\n var _item$SEARCH_MARK;\n return (_item$SEARCH_MARK = item[SEARCH_MARK]) === null || _item$SEARCH_MARK === void 0 ? void 0 : _item$SEARCH_MARK.map(function (opt) {\n return opt[fieldNames.value];\n });\n });\n}\nfunction isMultipleValue(value) {\n return Array.isArray(value) && Array.isArray(value[0]);\n}\nexport function toRawValues(value) {\n if (!value) {\n return [];\n }\n if (isMultipleValue(value)) {\n return value;\n }\n return (value.length === 0 ? [] : [value]).map(function (val) {\n return Array.isArray(val) ? val : [val];\n });\n}","map":{"version":3,"names":["SEARCH_MARK","VALUE_SPLIT","SHOW_PARENT","SHOW_CHILD","toPathKey","value","join","toPathKeys","map","toPathValueStr","pathKey","split","fillFieldNames","fieldNames","_ref","label","children","val","key","isLeaf","option","_option$isLeaf","_option","length","scrollIntoParentView","element","parent","parentElement","elementToParent","offsetTop","scrollTop","scrollTo","top","offsetHeight","getFullPathKeys","options","item","_item$SEARCH_MARK","opt","isMultipleValue","Array","isArray","toRawValues"],"sources":["C:/Users/Аришина)/Desktop/promo/node_modules/rc-cascader/es/utils/commonUtil.js"],"sourcesContent":["import { SEARCH_MARK } from \"../hooks/useSearchOptions\";\nexport var VALUE_SPLIT = '__RC_CASCADER_SPLIT__';\nexport var SHOW_PARENT = 'SHOW_PARENT';\nexport var SHOW_CHILD = 'SHOW_CHILD';\n\n/**\n * Will convert value to string, and join with `VALUE_SPLIT`\n */\nexport function toPathKey(value) {\n return value.join(VALUE_SPLIT);\n}\n\n/**\n * Batch convert value to string, and join with `VALUE_SPLIT`\n */\nexport function toPathKeys(value) {\n return value.map(toPathKey);\n}\nexport function toPathValueStr(pathKey) {\n return pathKey.split(VALUE_SPLIT);\n}\nexport function fillFieldNames(fieldNames) {\n var _ref = fieldNames || {},\n label = _ref.label,\n value = _ref.value,\n children = _ref.children;\n var val = value || 'value';\n return {\n label: label || 'label',\n value: val,\n key: val,\n children: children || 'children'\n };\n}\nexport function isLeaf(option, fieldNames) {\n var _option$isLeaf, _option;\n return (_option$isLeaf = option.isLeaf) !== null && _option$isLeaf !== void 0 ? _option$isLe
|