f9028c813ead220fe99d0b3cc0994c82.json
7.36 KB
{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\nimport * as React from 'react';\nimport usePatchElement from '../../_util/hooks/usePatchElement';\nimport HookModal from './HookModal';\nimport { withConfirm, withInfo, withSuccess, withError, withWarn } from '../confirm';\nvar uuid = 0;\nvar ElementsHolder = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function (_props, ref) {\n var _usePatchElement = usePatchElement(),\n _usePatchElement2 = _slicedToArray(_usePatchElement, 2),\n elements = _usePatchElement2[0],\n patchElement = _usePatchElement2[1];\n\n React.useImperativeHandle(ref, function () {\n return {\n patchElement: patchElement\n };\n }, []);\n return /*#__PURE__*/React.createElement(React.Fragment, null, elements);\n}));\nexport default function useModal() {\n var holderRef = React.useRef(null);\n var getConfirmFunc = React.useCallback(function (withFunc) {\n return function hookConfirm(config) {\n var _a;\n\n uuid += 1;\n var modalRef = /*#__PURE__*/React.createRef();\n var closeFunc;\n var modal = /*#__PURE__*/React.createElement(HookModal, {\n key: \"modal-\".concat(uuid),\n config: withFunc(config),\n ref: modalRef,\n afterClose: function afterClose() {\n closeFunc();\n }\n });\n closeFunc = (_a = holderRef.current) === null || _a === void 0 ? void 0 : _a.patchElement(modal);\n return {\n destroy: function destroy() {\n if (modalRef.current) {\n modalRef.current.destroy();\n }\n },\n update: function update(newConfig) {\n if (modalRef.current) {\n modalRef.current.update(newConfig);\n }\n }\n };\n };\n }, []);\n var fns = React.useMemo(function () {\n return {\n info: getConfirmFunc(withInfo),\n success: getConfirmFunc(withSuccess),\n error: getConfirmFunc(withError),\n warning: getConfirmFunc(withWarn),\n confirm: getConfirmFunc(withConfirm)\n };\n }, []); // eslint-disable-next-line react/jsx-key\n\n return [fns, /*#__PURE__*/React.createElement(ElementsHolder, {\n ref: holderRef\n })];\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/antd/es/modal/useModal/index.js"],"names":["_slicedToArray","React","usePatchElement","HookModal","withConfirm","withInfo","withSuccess","withError","withWarn","uuid","ElementsHolder","memo","forwardRef","_props","ref","_usePatchElement","_usePatchElement2","elements","patchElement","useImperativeHandle","createElement","Fragment","useModal","holderRef","useRef","getConfirmFunc","useCallback","withFunc","hookConfirm","config","_a","modalRef","createRef","closeFunc","modal","key","concat","afterClose","current","destroy","update","newConfig","fns","useMemo","info","success","error","warning","confirm"],"mappings":"AAAA,OAAOA,cAAP,MAA2B,sCAA3B;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,OAAOC,eAAP,MAA4B,mCAA5B;AACA,OAAOC,SAAP,MAAsB,aAAtB;AACA,SAASC,WAAT,EAAsBC,QAAtB,EAAgCC,WAAhC,EAA6CC,SAA7C,EAAwDC,QAAxD,QAAwE,YAAxE;AACA,IAAIC,IAAI,GAAG,CAAX;AACA,IAAIC,cAAc,GAAG,aAAaT,KAAK,CAACU,IAAN,EAAY,aAAaV,KAAK,CAACW,UAAN,CAAiB,UAAUC,MAAV,EAAkBC,GAAlB,EAAuB;AACjG,MAAIC,gBAAgB,GAAGb,eAAe,EAAtC;AAAA,MACIc,iBAAiB,GAAGhB,cAAc,CAACe,gBAAD,EAAmB,CAAnB,CADtC;AAAA,MAEIE,QAAQ,GAAGD,iBAAiB,CAAC,CAAD,CAFhC;AAAA,MAGIE,YAAY,GAAGF,iBAAiB,CAAC,CAAD,CAHpC;;AAKAf,EAAAA,KAAK,CAACkB,mBAAN,CAA0BL,GAA1B,EAA+B,YAAY;AACzC,WAAO;AACLI,MAAAA,YAAY,EAAEA;AADT,KAAP;AAGD,GAJD,EAIG,EAJH;AAKA,SAAO,aAAajB,KAAK,CAACmB,aAAN,CAAoBnB,KAAK,CAACoB,QAA1B,EAAoC,IAApC,EAA0CJ,QAA1C,CAApB;AACD,CAZ0D,CAAzB,CAAlC;AAaA,eAAe,SAASK,QAAT,GAAoB;AACjC,MAAIC,SAAS,GAAGtB,KAAK,CAACuB,MAAN,CAA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,YAAY;AAClC,WAAO;AACLC,MAAAA,IAAI,EAAEnB,cAAc,CAACpB,QAAD,CADf;AAELwC,MAAAA,OAAO,EAAEpB,cAAc,CAACnB,WAAD,CAFlB;AAGLwC,MAAAA,KAAK,EAAErB,cAAc,CAAClB,SAAD,CAHhB;AAILwC,MAAAA,OAAO,EAAEtB,cAAc,CAACjB,QAAD,CAJlB;AAKLwC,MAAAA,OAAO,EAAEvB,cAAc,CAACrB,WAAD;AALlB,KAAP;AAOD,GARS,EAQP,EARO,CAAV,CAhCiC,CAwCzB;;AAER,SAAO,CAACsC,GAAD,EAAM,aAAazC,KAAK,CAACmB,aAAN,CAAoBV,cAApB,EAAoC;AAC5DI,IAAAA,GAAG,EAAES;AADuD,GAApC,CAAnB,CAAP;AAGD","sourcesContent":["import _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\nimport * as React from 'react';\nimport usePatchElement from '../../_util/hooks/usePatchElement';\nimport HookModal from './HookModal';\nimport { withConfirm, withInfo, withSuccess, withError, withWarn } from '../confirm';\nvar uuid = 0;\nvar ElementsHolder = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function (_props, ref) {\n var _usePatchElement = usePatchElement(),\n _usePatchElement2 = _slicedToArray(_usePatchElement, 2),\n elements = _usePatchElement2[0],\n patchElement = _usePatchElement2[1];\n\n React.useImperativeHandle(ref, function () {\n return {\n patchElement: patchElement\n };\n }, []);\n return /*#__PURE__*/React.createElement(React.Fragment, null, elements);\n}));\nexport default function useModal() {\n var holderRef = React.useRef(null);\n var getConfirmFunc = React.useCallback(function (withFunc) {\n return function hookConfirm(config) {\n var _a;\n\n uuid += 1;\n var modalRef = /*#__PURE__*/React.createRef();\n var closeFunc;\n var modal = /*#__PURE__*/React.createElement(HookModal, {\n key: \"modal-\".concat(uuid),\n config: withFunc(config),\n ref: modalRef,\n afterClose: function afterClose() {\n closeFunc();\n }\n });\n closeFunc = (_a = holderRef.current) === null || _a === void 0 ? void 0 : _a.patchElement(modal);\n return {\n destroy: function destroy() {\n if (modalRef.current) {\n modalRef.current.destroy();\n }\n },\n update: function update(newConfig) {\n if (modalRef.current) {\n modalRef.current.update(newConfig);\n }\n }\n };\n };\n }, []);\n var fns = React.useMemo(function () {\n return {\n info: getConfirmFunc(withInfo),\n success: getConfirmFunc(withSuccess),\n error: getConfirmFunc(withError),\n warning: getConfirmFunc(withWarn),\n confirm: getConfirmFunc(withConfirm)\n };\n }, []); // eslint-disable-next-line react/jsx-key\n\n return [fns, /*#__PURE__*/React.createElement(ElementsHolder, {\n ref: holderRef\n })];\n}"]},"metadata":{},"sourceType":"module"}