cbba038041320a600c4995869b14a05d.json
8.19 KB
{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/extends\";\nimport _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\nimport * as React from 'react';\nimport ConfirmDialog from '../ConfirmDialog';\nimport defaultLocale from '../../locale/default';\nimport LocaleReceiver from '../../locale-provider/LocaleReceiver';\nimport { ConfigContext } from '../../config-provider';\n\nvar HookModal = function HookModal(_ref, ref) {\n var afterClose = _ref.afterClose,\n config = _ref.config;\n\n var _React$useState = React.useState(true),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n visible = _React$useState2[0],\n setVisible = _React$useState2[1];\n\n var _React$useState3 = React.useState(config),\n _React$useState4 = _slicedToArray(_React$useState3, 2),\n innerConfig = _React$useState4[0],\n setInnerConfig = _React$useState4[1];\n\n var _React$useContext = React.useContext(ConfigContext),\n direction = _React$useContext.direction,\n getPrefixCls = _React$useContext.getPrefixCls;\n\n var prefixCls = getPrefixCls('modal');\n var rootPrefixCls = getPrefixCls();\n\n function close() {\n setVisible(false);\n\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var triggerCancel = args.some(function (param) {\n return param && param.triggerCancel;\n });\n\n if (innerConfig.onCancel && triggerCancel) {\n innerConfig.onCancel();\n }\n }\n\n React.useImperativeHandle(ref, function () {\n return {\n destroy: close,\n update: function update(newConfig) {\n setInnerConfig(function (originConfig) {\n return _extends(_extends({}, originConfig), newConfig);\n });\n }\n };\n });\n return /*#__PURE__*/React.createElement(LocaleReceiver, {\n componentName: \"Modal\",\n defaultLocale: defaultLocale.Modal\n }, function (modalLocale) {\n return /*#__PURE__*/React.createElement(ConfirmDialog, _extends({\n prefixCls: prefixCls,\n rootPrefixCls: rootPrefixCls\n }, innerConfig, {\n close: close,\n visible: visible,\n afterClose: afterClose,\n okText: innerConfig.okText || (innerConfig.okCancel ? modalLocale.okText : modalLocale.justOkText),\n direction: direction,\n cancelText: innerConfig.cancelText || modalLocale.cancelText\n }));\n });\n};\n\nexport default /*#__PURE__*/React.forwardRef(HookModal);","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/antd/es/modal/useModal/HookModal.js"],"names":["_extends","_slicedToArray","React","ConfirmDialog","defaultLocale","LocaleReceiver","ConfigContext","HookModal","_ref","ref","afterClose","config","_React$useState","useState","_React$useState2","visible","setVisible","_React$useState3","_React$useState4","innerConfig","setInnerConfig","_React$useContext","useContext","direction","getPrefixCls","prefixCls","rootPrefixCls","close","_len","arguments","length","args","Array","_key","triggerCancel","some","param","onCancel","useImperativeHandle","destroy","update","newConfig","originConfig","createElement","componentName","Modal","modalLocale","okText","okCancel","justOkText","cancelText","forwardRef"],"mappings":"AAAA,OAAOA,QAAP,MAAqB,gCAArB;AACA,OAAOC,cAAP,MAA2B,sCAA3B;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,OAAOC,aAAP,MAA0B,sBAA1B;AACA,OAAOC,cAAP,MAA2B,sCAA3B;AACA,SAASC,aAAT,QAA8B,uBAA9B;;AAEA,IAAIC,SAAS,GAAG,SAASA,SAAT,CAAmBC,IAAnB,EAAyBC,GAAzB,EAA8B;AAC5C,MAAIC,UAAU,GAAGF,IAAI,CAACE,UAAtB;AAAA,MACIC,MAAM,GAAGH,IAAI,CAACG,MADlB;;AAGA,MAAIC,eAAe,GAAGV,KAAK,CAACW,QAAN,CAAe,IAAf,CAAtB;AAAA,MACIC,gBAAgB,GAAGb,cAAc,CAACW,eAAD,EAAkB,CAAlB,CADrC;AAAA,MAEIG,OAAO,GAAGD,gBAAgB,CAAC,CAAD,CAF9B;AAAA,MAGIE,UAAU,GAAGF,gBAAgB,CAAC,CAAD,CAHjC;;AAKA,MAAIG,gBAAgB,GAAGf,KAAK,CAACW,QAAN,CAAeF,MAAf,CAAvB;AAAA,MACIO,gBAAgB,GAAGjB,cAAc,CAACgB,gBAAD,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,EAAK0C,YAAL,CAAT,EAA6BD,SAA7B,CAAf;AACD,SAFa,CAAd;AAGD;AANI,KAAP;AAQD,GATD;AAUA,SAAO,aAAavC,KAAK,CAACyC,aAAN,CAAoBtC,cAApB,EAAoC;AACtDuC,IAAAA,aAAa,EAAE,OADuC;AAEtDxC,IAAAA,aAAa,EAAEA,aAAa,CAACyC;AAFyB,GAApC,EAGjB,UAAUC,WAAV,EAAuB;AACxB,WAAO,aAAa5C,KAAK,CAACyC,aAAN,CAAoBxC,aAApB,EAAmCH,QAAQ,CAAC;AAC9DyB,MAAAA,SAAS,EAAEA,SADmD;AAE9DC,MAAAA,aAAa,EAAEA;AAF+C,KAAD,EAG5DP,WAH4D,EAG/C;AACdQ,MAAAA,KAAK,EAAEA,KADO;AAEdZ,MAAAA,OAAO,EAAEA,OAFK;AAGdL,MAAAA,UAAU,EAAEA,UAHE;AAIdqC,MAAAA,MAAM,EAAE5B,WAAW,CAAC4B,MAAZ,KAAuB5B,WAAW,CAAC6B,QAAZ,GAAuBF,WAAW,CAACC,MAAnC,GAA4CD,WAAW,CAACG,UAA/E,CAJM;AAKd1B,MAAAA,SAAS,EAAEA,SALG;AAMd2B,MAAAA,UAAU,EAAE/B,WAAW,CAAC+B,UAAZ,IAA0BJ,WAAW,CAACI;AANpC,KAH+C,CAA3C,CAApB;AAWD,GAfmB,CAApB;AAgBD,CA/DD;;AAiEA,eAAe,aAAahD,KAAK,CAACiD,UAAN,CAAiB5C,SAAjB,CAA5B","sourcesContent":["import _extends from \"@babel/runtime/helpers/extends\";\nimport _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\nimport * as React from 'react';\nimport ConfirmDialog from '../ConfirmDialog';\nimport defaultLocale from '../../locale/default';\nimport LocaleReceiver from '../../locale-provider/LocaleReceiver';\nimport { ConfigContext } from '../../config-provider';\n\nvar HookModal = function HookModal(_ref, ref) {\n var afterClose = _ref.afterClose,\n config = _ref.config;\n\n var _React$useState = React.useState(true),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n visible = _React$useState2[0],\n setVisible = _React$useState2[1];\n\n var _React$useState3 = React.useState(config),\n _React$useState4 = _slicedToArray(_React$useState3, 2),\n innerConfig = _React$useState4[0],\n setInnerConfig = _React$useState4[1];\n\n var _React$useContext = React.useContext(ConfigContext),\n direction = _React$useContext.direction,\n getPrefixCls = _React$useContext.getPrefixCls;\n\n var prefixCls = getPrefixCls('modal');\n var rootPrefixCls = getPrefixCls();\n\n function close() {\n setVisible(false);\n\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var triggerCancel = args.some(function (param) {\n return param && param.triggerCancel;\n });\n\n if (innerConfig.onCancel && triggerCancel) {\n innerConfig.onCancel();\n }\n }\n\n React.useImperativeHandle(ref, function () {\n return {\n destroy: close,\n update: function update(newConfig) {\n setInnerConfig(function (originConfig) {\n return _extends(_extends({}, originConfig), newConfig);\n });\n }\n };\n });\n return /*#__PURE__*/React.createElement(LocaleReceiver, {\n componentName: \"Modal\",\n defaultLocale: defaultLocale.Modal\n }, function (modalLocale) {\n return /*#__PURE__*/React.createElement(ConfirmDialog, _extends({\n prefixCls: prefixCls,\n rootPrefixCls: rootPrefixCls\n }, innerConfig, {\n close: close,\n visible: visible,\n afterClose: afterClose,\n okText: innerConfig.okText || (innerConfig.okCancel ? modalLocale.okText : modalLocale.justOkText),\n direction: direction,\n cancelText: innerConfig.cancelText || modalLocale.cancelText\n }));\n });\n};\n\nexport default /*#__PURE__*/React.forwardRef(HookModal);"]},"metadata":{},"sourceType":"module"}