948c57d306522b159e2d1a95174c3941.json
3.22 KB
{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nexport default function useTextValueMapping(_ref) {\n var valueTexts = _ref.valueTexts,\n onTextChange = _ref.onTextChange;\n\n var _React$useState = React.useState(''),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n text = _React$useState2[0],\n setInnerText = _React$useState2[1];\n\n var valueTextsRef = React.useRef([]);\n valueTextsRef.current = valueTexts;\n\n function triggerTextChange(value) {\n setInnerText(value);\n onTextChange(value);\n }\n\n function resetText() {\n setInnerText(valueTextsRef.current[0]);\n }\n\n React.useEffect(function () {\n if (valueTexts.every(function (valText) {\n return valText !== text;\n })) {\n resetText();\n }\n }, [valueTexts.join('||')]);\n return [text, triggerTextChange, resetText];\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-picker/es/hooks/useTextValueMapping.js"],"names":["_slicedToArray","React","useTextValueMapping","_ref","valueTexts","onTextChange","_React$useState","useState","_React$useState2","text","setInnerText","valueTextsRef","useRef","current","triggerTextChange","value","resetText","useEffect","every","valText","join"],"mappings":"AAAA,OAAOA,cAAP,MAA2B,0CAA3B;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,eAAe,SAASC,mBAAT,CAA6BC,IAA7B,EAAmC;AAChD,MAAIC,UAAU,GAAGD,IAAI,CAACC,UAAtB;AAAA,MACIC,YAAY,GAAGF,IAAI,CAACE,YADxB;;AAGA,MAAIC,eAAe,GAAGL,KAAK,CAACM,QAAN,CAAe,EAAf,CAAtB;AAAA,MACIC,gBAAgB,GAAGR,cAAc,CAACM,eAAD,EAAkB,CAAlB,CADrC;AAAA,MAEIG,IAAI,GAAGD,gBAAgB,CAAC,CAAD,CAF3B;AAAA,MAGIE,YAAY,GAAGF,gBAAgB,CAAC,CAAD,CAHnC;;AAKA,MAAIG,aAAa,GAAGV,KAAK,CAACW,MAAN,CAAa,EAAb,CAApB;AACAD,EAAAA,aAAa,CAACE,OAAd,GAAwBT,UAAxB;;AAEA,WAASU,iBAAT,CAA2BC,KAA3B,EAAkC;AAChCL,IAAAA,YAAY,CAACK,KAAD,CAAZ;AACAV,IAAAA,YAAY,CAACU,KAAD,CAAZ;AACD;;AAED,WAASC,SAAT,GAAqB;AACnBN,IAAAA,YAAY,CAACC,aAAa,CAACE,OAAd,CAAsB,CAAtB,CAAD,CAAZ;AACD;;AAEDZ,EAAAA,KAAK,CAACgB,SAAN,CAAgB,YAAY;AAC1B,QAAIb,UAAU,CAACc,KAAX,CAAiB,UAAUC,OAAV,EAAmB;AACtC,aAAOA,OAAO,KAAKV,IAAnB;AACD,KAFG,CAAJ,EAEI;AACFO,MAAAA,SAAS;AACV;AACF,GAND,EAMG,CAACZ,UAAU,CAACgB,IAAX,CAAgB,IAAhB,CAAD,CANH;AAOA,SAAO,CAACX,IAAD,EAAOK,iBAAP,EAA0BE,SAA1B,CAAP;AACD","sourcesContent":["import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nexport default function useTextValueMapping(_ref) {\n var valueTexts = _ref.valueTexts,\n onTextChange = _ref.onTextChange;\n\n var _React$useState = React.useState(''),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n text = _React$useState2[0],\n setInnerText = _React$useState2[1];\n\n var valueTextsRef = React.useRef([]);\n valueTextsRef.current = valueTexts;\n\n function triggerTextChange(value) {\n setInnerText(value);\n onTextChange(value);\n }\n\n function resetText() {\n setInnerText(valueTextsRef.current[0]);\n }\n\n React.useEffect(function () {\n if (valueTexts.every(function (valText) {\n return valText !== text;\n })) {\n resetText();\n }\n }, [valueTexts.join('||')]);\n return [text, triggerTextChange, resetText];\n}"]},"metadata":{},"sourceType":"module"}