5304e0676301588ca41aa992b067fb5d.json
15.3 KB
{"ast":null,"code":"import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport get from \"rc-util/es/utils/get\";\nimport set from \"rc-util/es/utils/set\";\nimport { toArray } from './typeUtil';\n/**\n * Convert name to internal supported format.\n * This function should keep since we still thinking if need support like `a.b.c` format.\n * 'a' => ['a']\n * 123 => [123]\n * ['a', 123] => ['a', 123]\n */\n\nexport function getNamePath(path) {\n return toArray(path);\n}\nexport function getValue(store, namePath) {\n var value = get(store, namePath);\n return value;\n}\nexport function setValue(store, namePath, value) {\n var newStore = set(store, namePath, value);\n return newStore;\n}\nexport function cloneByNamePathList(store, namePathList) {\n var newStore = {};\n namePathList.forEach(function (namePath) {\n var value = getValue(store, namePath);\n newStore = setValue(newStore, namePath, value);\n });\n return newStore;\n}\nexport function containsNamePath(namePathList, namePath) {\n return namePathList && namePathList.some(function (path) {\n return matchNamePath(path, namePath);\n });\n}\n\nfunction isObject(obj) {\n return _typeof(obj) === 'object' && obj !== null && Object.getPrototypeOf(obj) === Object.prototype;\n}\n/**\n * Copy values into store and return a new values object\n * ({ a: 1, b: { c: 2 } }, { a: 4, b: { d: 5 } }) => { a: 4, b: { c: 2, d: 5 } }\n */\n\n\nfunction internalSetValues(store, values) {\n var newStore = Array.isArray(store) ? _toConsumableArray(store) : _objectSpread({}, store);\n\n if (!values) {\n return newStore;\n }\n\n Object.keys(values).forEach(function (key) {\n var prevValue = newStore[key];\n var value = values[key]; // If both are object (but target is not array), we use recursion to set deep value\n\n var recursive = isObject(prevValue) && isObject(value);\n newStore[key] = recursive ? internalSetValues(prevValue, value || {}) : value;\n });\n return newStore;\n}\n\nexport function setValues(store) {\n for (var _len = arguments.length, restValues = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n restValues[_key - 1] = arguments[_key];\n }\n\n return restValues.reduce(function (current, newStore) {\n return internalSetValues(current, newStore);\n }, store);\n}\nexport function matchNamePath(namePath, changedNamePath) {\n if (!namePath || !changedNamePath || namePath.length !== changedNamePath.length) {\n return false;\n }\n\n return namePath.every(function (nameUnit, i) {\n return changedNamePath[i] === nameUnit;\n });\n}\nexport function isSimilar(source, target) {\n if (source === target) {\n return true;\n }\n\n if (!source && target || source && !target) {\n return false;\n }\n\n if (!source || !target || _typeof(source) !== 'object' || _typeof(target) !== 'object') {\n return false;\n }\n\n var sourceKeys = Object.keys(source);\n var targetKeys = Object.keys(target);\n var keys = new Set([].concat(_toConsumableArray(sourceKeys), _toConsumableArray(targetKeys)));\n return _toConsumableArray(keys).every(function (key) {\n var sourceValue = source[key];\n var targetValue = target[key];\n\n if (typeof sourceValue === 'function' && typeof targetValue === 'function') {\n return true;\n }\n\n return sourceValue === targetValue;\n });\n}\nexport function defaultGetValueFromEvent(valuePropName) {\n var event = arguments.length <= 1 ? undefined : arguments[1];\n\n if (event && event.target && valuePropName in event.target) {\n return event.target[valuePropName];\n }\n\n return event;\n}\n/**\n * Moves an array item from one position in an array to another.\n *\n * Note: This is a pure function so a new array will be returned, instead\n * of altering the array argument.\n *\n * @param array Array in which to move an item. (required)\n * @param moveIndex The index of the item to move. (required)\n * @param toIndex The index to move item at moveIndex to. (required)\n */\n\nexport function move(array, moveIndex, toIndex) {\n var length = array.length;\n\n if (moveIndex < 0 || moveIndex >= length || toIndex < 0 || toIndex >= length) {\n return array;\n }\n\n var item = array[moveIndex];\n var diff = moveIndex - toIndex;\n\n if (diff > 0) {\n // move left\n return [].concat(_toConsumableArray(array.slice(0, toIndex)), [item], _toConsumableArray(array.slice(toIndex, moveIndex)), _toConsumableArray(array.slice(moveIndex + 1, length)));\n }\n\n if (diff < 0) {\n // move right\n return [].concat(_toConsumableArray(array.slice(0, moveIndex)), _toConsumableArray(array.slice(moveIndex + 1, toIndex + 1)), [item], _toConsumableArray(array.slice(toIndex + 1, length)));\n }\n\n return array;\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-field-form/es/utils/valueUtil.js"],"names":["_objectSpread","_toConsumableArray","_typeof","get","set","toArray","getNamePath","path","getValue","store","namePath","value","setValue","newStore","cloneByNamePathList","namePathList","forEach","containsNamePath","some","matchNamePath","isObject","obj","Object","getPrototypeOf","prototype","internalSetValues","values","Array","isArray","keys","key","prevValue","recursive","setValues","_len","arguments","length","restValues","_key","reduce","current","changedNamePath","every","nameUnit","i","isSimilar","source","target","sourceKeys","targetKeys","Set","concat","sourceValue","targetValue","defaultGetValueFromEvent","valuePropName","event","undefined","move","array","moveIndex","toIndex","item","diff","slice"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,0CAA1B;AACA,OAAOC,kBAAP,MAA+B,8CAA/B;AACA,OAAOC,OAAP,MAAoB,mCAApB;AACA,OAAOC,GAAP,MAAgB,sBAAhB;AACA,OAAOC,GAAP,MAAgB,sBAAhB;AACA,SAASC,OAAT,QAAwB,YAAxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,SAASC,WAAT,CAAqBC,IAArB,EAA2B;AAChC,SAAOF,OAAO,CAACE,IAAD,CAAd;AACD;AACD,OAAO,SAASC,QAAT,CAAkBC,KAAlB,EAAyBC,QAAzB,EAAmC;AACxC,MAAIC,KAAK,GAAGR,GAAG,CAACM,KAAD,EAAQC,QAAR,CAAf;AACA,SAAOC,KAAP;AACD;AACD,OAAO,SAASC,QAAT,CAAkBH,KAAlB,EAAyBC,QAAzB,EAAmCC,KAAnC,EAA0C;AAC/C,MAAIE,QAAQ,GAAGT,GAAG,CAACK,KAAD,EAAQC,QAAR,EAAkBC,KAAlB,CAAlB;AACA,SAAOE,QAAP;AACD;AACD,OAAO,SAASC,mBAAT,CAA6BL,KAA7B,EAAoCM,YAApC,EAAkD;AACvD,MAAIF,QAAQ,GAAG,EAAf;AACAE,EAAAA,YAAY,CAACC,OAAb,CAAqB,UAAUN,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umableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport get from \"rc-util/es/utils/get\";\nimport set from \"rc-util/es/utils/set\";\nimport { toArray } from './typeUtil';\n/**\n * Convert name to internal supported format.\n * This function should keep since we still thinking if need support like `a.b.c` format.\n * 'a' => ['a']\n * 123 => [123]\n * ['a', 123] => ['a', 123]\n */\n\nexport function getNamePath(path) {\n return toArray(path);\n}\nexport function getValue(store, namePath) {\n var value = get(store, namePath);\n return value;\n}\nexport function setValue(store, namePath, value) {\n var newStore = set(store, namePath, value);\n return newStore;\n}\nexport function cloneByNamePathList(store, namePathList) {\n var newStore = {};\n namePathList.forEach(function (namePath) {\n var value = getValue(store, namePath);\n newStore = setValue(newStore, namePath, value);\n });\n return newStore;\n}\nexport function containsNamePath(namePathList, namePath) {\n return namePathList && namePathList.some(function (path) {\n return matchNamePath(path, namePath);\n });\n}\n\nfunction isObject(obj) {\n return _typeof(obj) === 'object' && obj !== null && Object.getPrototypeOf(obj) === Object.prototype;\n}\n/**\n * Copy values into store and return a new values object\n * ({ a: 1, b: { c: 2 } }, { a: 4, b: { d: 5 } }) => { a: 4, b: { c: 2, d: 5 } }\n */\n\n\nfunction internalSetValues(store, values) {\n var newStore = Array.isArray(store) ? _toConsumableArray(store) : _objectSpread({}, store);\n\n if (!values) {\n return newStore;\n }\n\n Object.keys(values).forEach(function (key) {\n var prevValue = newStore[key];\n var value = values[key]; // If both are object (but target is not array), we use recursion to set deep value\n\n var recursive = isObject(prevValue) && isObject(value);\n newStore[key] = recursive ? internalSetValues(prevValue, value || {}) : value;\n });\n return newStore;\n}\n\nexport function setValues(store) {\n for (var _len = arguments.length, restValues = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n restValues[_key - 1] = arguments[_key];\n }\n\n return restValues.reduce(function (current, newStore) {\n return internalSetValues(current, newStore);\n }, store);\n}\nexport function matchNamePath(namePath, changedNamePath) {\n if (!namePath || !changedNamePath || namePath.length !== changedNamePath.length) {\n return false;\n }\n\n return namePath.every(function (nameUnit, i) {\n return changedNamePath[i] === nameUnit;\n });\n}\nexport function isSimilar(source, target) {\n if (source === target) {\n return true;\n }\n\n if (!source && target || source && !target) {\n return false;\n }\n\n if (!source || !target || _typeof(source) !== 'object' || _typeof(target) !== 'object') {\n return false;\n }\n\n var sourceKeys = Object.keys(source);\n var targetKeys = Object.keys(target);\n var keys = new Set([].concat(_toConsumableArray(sourceKeys), _toConsumableArray(targetKeys)));\n return _toConsumableArray(keys).every(function (key) {\n var sourceValue = source[key];\n var targetValue = target[key];\n\n if (typeof sourceValue === 'function' && typeof targetValue === 'function') {\n return true;\n }\n\n return sourceValue === targetValue;\n });\n}\nexport function defaultGetValueFromEvent(valuePropName) {\n var event = arguments.length <= 1 ? undefined : arguments[1];\n\n if (event && event.target && valuePropName in event.target) {\n return event.target[valuePropName];\n }\n\n return event;\n}\n/**\n * Moves an array item from one position in an array to another.\n *\n * Note: This is a pure function so a new array will be returned, instead\n * of altering the array argument.\n *\n * @param array Array in which to move an item. (required)\n * @param moveIndex The index of the item to move. (required)\n * @param toIndex The index to move item at moveIndex to. (required)\n */\n\nexport function move(array, moveIndex, toIndex) {\n var length = array.length;\n\n if (moveIndex < 0 || moveIndex >= length || toIndex < 0 || toIndex >= length) {\n return array;\n }\n\n var item = array[moveIndex];\n var diff = moveIndex - toIndex;\n\n if (diff > 0) {\n // move left\n return [].concat(_toConsumableArray(array.slice(0, toIndex)), [item], _toConsumableArray(array.slice(toIndex, moveIndex)), _toConsumableArray(array.slice(moveIndex + 1, length)));\n }\n\n if (diff < 0) {\n // move right\n return [].concat(_toConsumableArray(array.slice(0, moveIndex)), _toConsumableArray(array.slice(moveIndex + 1, toIndex + 1)), [item], _toConsumableArray(array.slice(toIndex + 1, length)));\n }\n\n return array;\n}"]},"metadata":{},"sourceType":"module"}