ff091d4be6b318fd713cf07b10ec0403.json
10.3 KB
{"ast":null,"code":"function _slicedToArray(arr, i) {\n return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();\n}\n\nfunction _nonIterableRest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\n\nfunction _unsupportedIterableToArray(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return _arrayLikeToArray(o, minLen);\n var n = Object.prototype.toString.call(o).slice(8, -1);\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(o);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);\n}\n\nfunction _arrayLikeToArray(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n\n for (var i = 0, arr2 = new Array(len); i < len; i++) {\n arr2[i] = arr[i];\n }\n\n return arr2;\n}\n\nfunction _iterableToArrayLimit(arr, i) {\n if (typeof Symbol === \"undefined\" || !(Symbol.iterator in Object(arr))) return;\n var _arr = [];\n var _n = true;\n var _d = false;\n var _e = undefined;\n\n try {\n for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {\n _arr.push(_s.value);\n\n if (i && _arr.length === i) break;\n }\n } catch (err) {\n _d = true;\n _e = err;\n } finally {\n try {\n if (!_n && _i[\"return\"] != null) _i[\"return\"]();\n } finally {\n if (_d) throw _e;\n }\n }\n\n return _arr;\n}\n\nfunction _arrayWithHoles(arr) {\n if (Array.isArray(arr)) return arr;\n}\n\nimport * as React from 'react';\nexport default function useControlledState(defaultStateValue, option) {\n var _ref = option || {},\n defaultValue = _ref.defaultValue,\n value = _ref.value,\n onChange = _ref.onChange,\n postState = _ref.postState;\n\n var _React$useState = React.useState(function () {\n if (value !== undefined) {\n return value;\n }\n\n if (defaultValue !== undefined) {\n return typeof defaultValue === 'function' ? defaultValue() : defaultValue;\n }\n\n return typeof defaultStateValue === 'function' ? defaultStateValue() : defaultStateValue;\n }),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n innerValue = _React$useState2[0],\n setInnerValue = _React$useState2[1];\n\n var mergedValue = value !== undefined ? value : innerValue;\n\n if (postState) {\n mergedValue = postState(mergedValue);\n }\n\n function triggerChange(newValue) {\n setInnerValue(newValue);\n\n if (mergedValue !== newValue && onChange) {\n onChange(newValue, mergedValue);\n }\n } // Effect of reset value to `undefined`\n\n\n var firstRenderRef = React.useRef(true);\n React.useEffect(function () {\n if (firstRenderRef.current) {\n firstRenderRef.current = false;\n return;\n }\n\n if (value === undefined) {\n setInnerValue(value);\n }\n }, [value]);\n return [mergedValue, triggerChange];\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-util/es/hooks/useMergedState.js"],"names":["_slicedToArray","arr","i","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","o","minLen","_arrayLikeToArray","n","Object","prototype","toString","call","slice","constructor","name","Array","from","test","len","length","arr2","Symbol","iterator","_arr","_n","_d","_e","undefined","_i","_s","next","done","push","value","err","isArray","React","useControlledState","defaultStateValue","option","_ref","defaultValue","onChange","postState","_React$useState","useState","_React$useState2","innerValue","setInnerValue","mergedValue","triggerChange","newValue","firstRenderRef","useRef","useEffect","current"],"mappings":"AAAA,SAASA,cAAT,CAAwBC,GAAxB,EAA6BC,CAA7B,EAAgC;AAAE,SAAOC,eAAe,CAACF,GAAD,CAAf,IAAwBG,qBAAqB,CAACH,GAAD,EAAMC,CAAN,CAA7C,IAAyDG,2BAA2B,CAACJ,GAAD,EAAMC,CAAN,CAApF,IAAgGI,gBAAgB,EAAvH;AAA4H;;AAE9J,SAASA,gBAAT,GAA4B;AAAE,QAAM,IAAIC,SAAJ,CAAc,2IAAd,CAAN;AAAmK;;AAEjM,SAASF,2BA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,cAAc,CAACG,OAAf,GAAyB,KAAzB;AACA;AACD;;AAED,QAAItB,KAAK,KAAKN,SAAd,EAAyB;AACvBqB,MAAAA,aAAa,CAACf,KAAD,CAAb;AACD;AACF,GATD,EASG,CAACA,KAAD,CATH;AAUA,SAAO,CAACgB,WAAD,EAAcC,aAAd,CAAP;AACD","sourcesContent":["function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nfunction _iterableToArrayLimit(arr, i) { if (typeof Symbol === \"undefined\" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nimport * as React from 'react';\nexport default function useControlledState(defaultStateValue, option) {\n var _ref = option || {},\n defaultValue = _ref.defaultValue,\n value = _ref.value,\n onChange = _ref.onChange,\n postState = _ref.postState;\n\n var _React$useState = React.useState(function () {\n if (value !== undefined) {\n return value;\n }\n\n if (defaultValue !== undefined) {\n return typeof defaultValue === 'function' ? defaultValue() : defaultValue;\n }\n\n return typeof defaultStateValue === 'function' ? defaultStateValue() : defaultStateValue;\n }),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n innerValue = _React$useState2[0],\n setInnerValue = _React$useState2[1];\n\n var mergedValue = value !== undefined ? value : innerValue;\n\n if (postState) {\n mergedValue = postState(mergedValue);\n }\n\n function triggerChange(newValue) {\n setInnerValue(newValue);\n\n if (mergedValue !== newValue && onChange) {\n onChange(newValue, mergedValue);\n }\n } // Effect of reset value to `undefined`\n\n\n var firstRenderRef = React.useRef(true);\n React.useEffect(function () {\n if (firstRenderRef.current) {\n firstRenderRef.current = false;\n return;\n }\n\n if (value === undefined) {\n setInnerValue(value);\n }\n }, [value]);\n return [mergedValue, triggerChange];\n}"]},"metadata":{},"sourceType":"module"}