71f90f6d5737cfddb4330e4070c1aa11.json
20.6 KB
{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport { useRef, useEffect } from 'react';\nimport classNames from 'classnames';\nimport KeyCode from \"rc-util/es/KeyCode\";\nimport contains from \"rc-util/es/Dom/contains\";\nimport Mask from './Mask';\nimport { getMotionName, getUUID } from '../util';\nimport Content from './Content';\nexport default function Dialog(props) {\n var _props$prefixCls = props.prefixCls,\n prefixCls = _props$prefixCls === void 0 ? 'rc-dialog' : _props$prefixCls,\n zIndex = props.zIndex,\n _props$visible = props.visible,\n visible = _props$visible === void 0 ? false : _props$visible,\n _props$keyboard = props.keyboard,\n keyboard = _props$keyboard === void 0 ? true : _props$keyboard,\n _props$focusTriggerAf = props.focusTriggerAfterClose,\n focusTriggerAfterClose = _props$focusTriggerAf === void 0 ? true : _props$focusTriggerAf,\n _props$switchScrollin = props.switchScrollingEffect,\n switchScrollingEffect = _props$switchScrollin === void 0 ? function () {} : _props$switchScrollin,\n title = props.title,\n wrapStyle = props.wrapStyle,\n wrapClassName = props.wrapClassName,\n wrapProps = props.wrapProps,\n onClose = props.onClose,\n afterClose = props.afterClose,\n transitionName = props.transitionName,\n animation = props.animation,\n _props$closable = props.closable,\n closable = _props$closable === void 0 ? true : _props$closable,\n _props$mask = props.mask,\n mask = _props$mask === void 0 ? true : _props$mask,\n maskTransitionName = props.maskTransitionName,\n maskAnimation = props.maskAnimation,\n _props$maskClosable = props.maskClosable,\n maskClosable = _props$maskClosable === void 0 ? true : _props$maskClosable,\n maskStyle = props.maskStyle,\n maskProps = props.maskProps;\n var lastOutSideActiveElementRef = useRef();\n var wrapperRef = useRef();\n var contentRef = useRef();\n\n var _React$useState = React.useState(visible),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n animatedVisible = _React$useState2[0],\n setAnimatedVisible = _React$useState2[1]; // ========================== Init ==========================\n\n\n var ariaIdRef = useRef();\n\n if (!ariaIdRef.current) {\n ariaIdRef.current = \"rcDialogTitle\".concat(getUUID());\n } // ========================= Events =========================\n\n\n function onDialogVisibleChanged(newVisible) {\n if (newVisible) {\n // Try to focus\n if (!contains(wrapperRef.current, document.activeElement)) {\n var _contentRef$current;\n\n lastOutSideActiveElementRef.current = document.activeElement;\n (_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 ? void 0 : _contentRef$current.focus();\n }\n } else {\n // Clean up scroll bar & focus back\n setAnimatedVisible(false);\n switchScrollingEffect();\n\n if (mask && lastOutSideActiveElementRef.current && focusTriggerAfterClose) {\n try {\n lastOutSideActiveElementRef.current.focus({\n preventScroll: true\n });\n } catch (e) {// Do nothing\n }\n\n lastOutSideActiveElementRef.current = null;\n }\n\n afterClose === null || afterClose === void 0 ? void 0 : afterClose();\n }\n }\n\n function onInternalClose(e) {\n onClose === null || onClose === void 0 ? void 0 : onClose(e);\n } // >>> Content\n\n\n var contentClickRef = useRef(false);\n var contentTimeoutRef = useRef(); // We need record content click incase content popup out of dialog\n\n var onContentMouseDown = function onContentMouseDown() {\n clearTimeout(contentTimeoutRef.current);\n contentClickRef.current = true;\n };\n\n var onContentMouseUp = function onContentMouseUp() {\n contentTimeoutRef.current = setTimeout(function () {\n contentClickRef.current = false;\n });\n }; // >>> Wrapper\n // Close only when element not on dialog\n\n\n var onWrapperClick = null;\n\n if (maskClosable) {\n onWrapperClick = function onWrapperClick(e) {\n if (contentClickRef.current) {\n contentClickRef.current = false;\n } else if (!contains(contentRef.current.getDOM(), e.target)) {\n onInternalClose(e);\n }\n };\n }\n\n function onWrapperKeyDown(e) {\n if (keyboard && e.keyCode === KeyCode.ESC) {\n e.stopPropagation();\n onInternalClose(e);\n return;\n } // keep focus inside dialog\n\n\n if (visible) {\n if (e.keyCode === KeyCode.TAB) {\n contentRef.current.changeActive(!e.shiftKey);\n }\n }\n } // ========================= Effect =========================\n\n\n useEffect(function () {\n if (visible) {\n setAnimatedVisible(true);\n switchScrollingEffect();\n }\n }, [visible]); // Remove direct should also check the scroll bar update\n\n useEffect(function () {\n return function () {\n switchScrollingEffect();\n clearTimeout(contentTimeoutRef.current);\n };\n }, []); // ========================= Render =========================\n\n return /*#__PURE__*/React.createElement(\"div\", {\n className: \"\".concat(prefixCls, \"-root\")\n }, /*#__PURE__*/React.createElement(Mask, {\n prefixCls: prefixCls,\n visible: mask && visible,\n motionName: getMotionName(prefixCls, maskTransitionName, maskAnimation),\n style: _objectSpread({\n zIndex: zIndex\n }, maskStyle),\n maskProps: maskProps\n }), /*#__PURE__*/React.createElement(\"div\", _extends({\n tabIndex: -1,\n onKeyDown: onWrapperKeyDown,\n className: classNames(\"\".concat(prefixCls, \"-wrap\"), wrapClassName),\n ref: wrapperRef,\n onClick: onWrapperClick,\n role: \"dialog\",\n \"aria-labelledby\": title ? ariaIdRef.current : null,\n style: _objectSpread(_objectSpread({\n zIndex: zIndex\n }, wrapStyle), {}, {\n display: !animatedVisible ? 'none' : null\n })\n }, wrapProps), /*#__PURE__*/React.createElement(Content, _extends({}, props, {\n onMouseDown: onContentMouseDown,\n onMouseUp: onContentMouseUp,\n ref: contentRef,\n closable: closable,\n ariaId: ariaIdRef.current,\n prefixCls: prefixCls,\n visible: visible,\n onClose: onInternalClose,\n onVisibleChanged: onDialogVisibleChanged,\n motionName: getMotionName(prefixCls, transitionName, animation)\n }))));\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-dialog/es/Dialog/index.js"],"names":["_extends","_objectSpread","_slicedToArray","React","useRef","useEffect","classNames","KeyCode","contains","Mask","getMotionName","getUUID","Content","Dialog","props","_props$prefixCls","prefixCls","zIndex","_props$visible","visible","_props$keyboard","keyboard","_props$focusTriggerAf","focusTriggerAfterClose","_props$switchScrollin","switchScrollingEffect","title","wrapStyle","wrapClassName","wrapProps","onClose","afterClose","transitionName","animation","_props$closable","closable","_props$mask","mask","maskTransitionName","maskAnimation","_props$maskClosable","maskClosable","maskStyle","maskProps","lastOutSideActiveElementRef","wrapperRef","contentRef","_React$useState","useState","_React$useState2","animatedVisible","setAnimatedVisible","ariaIdRef","current","concat","onDialogVisibleChanged","newVisible","document","activeElement","_contentRef$current","focus","preventScroll","e","onInternalClose","contentClickRef","contentTimeoutRef","onContentMouseDown","clearTimeout","onContentMouseUp","setTimeout","onWrapperClick","getDOM","target","onWrapperKeyDown","keyCode","ESC","stopPropagation","TAB","changeActive","shiftKey","createElement","className","motionName","style","tabIndex","onKeyDown","ref","onClick","role","display","onMouseDown","onMouseUp","ariaId","onVisibleChanged"],"mappings":"AAAA,OAAOA,QAAP,MAAqB,oCAArB;AACA,OAAOC,aAAP,MAA0B,0CAA1B;AACA,OAAOC,cAAP,MAA2B,0CAA3B;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,SAASC,MAAT,EAAiBC,SAAjB,QAAkC,OAAlC;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,OAAOC,OAAP,MAAoB,oBAApB;AACA,OAAOC,QAAP,MAAqB,yBAArB;AACA,OAAOC,IAAP,MAAiB,QAAjB;AACA,SAASC,aAAT,EAAwBC,OAAxB,QAAuC,SAAvC;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,eAAe,SAASC,MAAT,CAAgBC,KAAhB,EAAuB;AACpC,MAAIC,gBAAgB,GAAGD,KAAK,CAACE,SAA7B;AAAA,MACIA,SAAS,GAAGD,gBAAgB,KAAK,KAAK,CAA1B,GAA8B,WAA9B,GAA4CA,gBAD5D;AAAA,MAEIE,MAAM,GAAGH,KAAK,CAACG,MAFnB;AAAA,MAGIC,cAAc,GAAGJ,KAAK,CAACK,OAH3B;AAAA,MAIIA,OAAO,GAAGD,cAAc,KAAK,KAAK,CAAxB,GAA4B,KAA5B,GAAoCA,cAJlD;AAAA,MAKIE,eAAe,GAAGN,KAAK,CAACO,QAL5B;AAAA,MAMIA,QAAQ,GA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,EAAExC,UAHsE;AAI3EX,IAAAA,QAAQ,EAAEA,QAJiE;AAK3EyD,IAAAA,MAAM,EAAExC,SAAS,CAACC,OALyD;AAM3ErC,IAAAA,SAAS,EAAEA,SANgE;AAO3EG,IAAAA,OAAO,EAAEA,OAPkE;AAQ3EW,IAAAA,OAAO,EAAEiC,eARkE;AAS3E8B,IAAAA,gBAAgB,EAAEtC,sBATyD;AAU3E2B,IAAAA,UAAU,EAAExE,aAAa,CAACM,SAAD,EAAYgB,cAAZ,EAA4BC,SAA5B;AAVkD,GAAZ,CAArC,CAbX,CAVG,CAApB;AAmCD","sourcesContent":["import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport { useRef, useEffect } from 'react';\nimport classNames from 'classnames';\nimport KeyCode from \"rc-util/es/KeyCode\";\nimport contains from \"rc-util/es/Dom/contains\";\nimport Mask from './Mask';\nimport { getMotionName, getUUID } from '../util';\nimport Content from './Content';\nexport default function Dialog(props) {\n var _props$prefixCls = props.prefixCls,\n prefixCls = _props$prefixCls === void 0 ? 'rc-dialog' : _props$prefixCls,\n zIndex = props.zIndex,\n _props$visible = props.visible,\n visible = _props$visible === void 0 ? false : _props$visible,\n _props$keyboard = props.keyboard,\n keyboard = _props$keyboard === void 0 ? true : _props$keyboard,\n _props$focusTriggerAf = props.focusTriggerAfterClose,\n focusTriggerAfterClose = _props$focusTriggerAf === void 0 ? true : _props$focusTriggerAf,\n _props$switchScrollin = props.switchScrollingEffect,\n switchScrollingEffect = _props$switchScrollin === void 0 ? function () {} : _props$switchScrollin,\n title = props.title,\n wrapStyle = props.wrapStyle,\n wrapClassName = props.wrapClassName,\n wrapProps = props.wrapProps,\n onClose = props.onClose,\n afterClose = props.afterClose,\n transitionName = props.transitionName,\n animation = props.animation,\n _props$closable = props.closable,\n closable = _props$closable === void 0 ? true : _props$closable,\n _props$mask = props.mask,\n mask = _props$mask === void 0 ? true : _props$mask,\n maskTransitionName = props.maskTransitionName,\n maskAnimation = props.maskAnimation,\n _props$maskClosable = props.maskClosable,\n maskClosable = _props$maskClosable === void 0 ? true : _props$maskClosable,\n maskStyle = props.maskStyle,\n maskProps = props.maskProps;\n var lastOutSideActiveElementRef = useRef();\n var wrapperRef = useRef();\n var contentRef = useRef();\n\n var _React$useState = React.useState(visible),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n animatedVisible = _React$useState2[0],\n setAnimatedVisible = _React$useState2[1]; // ========================== Init ==========================\n\n\n var ariaIdRef = useRef();\n\n if (!ariaIdRef.current) {\n ariaIdRef.current = \"rcDialogTitle\".concat(getUUID());\n } // ========================= Events =========================\n\n\n function onDialogVisibleChanged(newVisible) {\n if (newVisible) {\n // Try to focus\n if (!contains(wrapperRef.current, document.activeElement)) {\n var _contentRef$current;\n\n lastOutSideActiveElementRef.current = document.activeElement;\n (_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 ? void 0 : _contentRef$current.focus();\n }\n } else {\n // Clean up scroll bar & focus back\n setAnimatedVisible(false);\n switchScrollingEffect();\n\n if (mask && lastOutSideActiveElementRef.current && focusTriggerAfterClose) {\n try {\n lastOutSideActiveElementRef.current.focus({\n preventScroll: true\n });\n } catch (e) {// Do nothing\n }\n\n lastOutSideActiveElementRef.current = null;\n }\n\n afterClose === null || afterClose === void 0 ? void 0 : afterClose();\n }\n }\n\n function onInternalClose(e) {\n onClose === null || onClose === void 0 ? void 0 : onClose(e);\n } // >>> Content\n\n\n var contentClickRef = useRef(false);\n var contentTimeoutRef = useRef(); // We need record content click incase content popup out of dialog\n\n var onContentMouseDown = function onContentMouseDown() {\n clearTimeout(contentTimeoutRef.current);\n contentClickRef.current = true;\n };\n\n var onContentMouseUp = function onContentMouseUp() {\n contentTimeoutRef.current = setTimeout(function () {\n contentClickRef.current = false;\n });\n }; // >>> Wrapper\n // Close only when element not on dialog\n\n\n var onWrapperClick = null;\n\n if (maskClosable) {\n onWrapperClick = function onWrapperClick(e) {\n if (contentClickRef.current) {\n contentClickRef.current = false;\n } else if (!contains(contentRef.current.getDOM(), e.target)) {\n onInternalClose(e);\n }\n };\n }\n\n function onWrapperKeyDown(e) {\n if (keyboard && e.keyCode === KeyCode.ESC) {\n e.stopPropagation();\n onInternalClose(e);\n return;\n } // keep focus inside dialog\n\n\n if (visible) {\n if (e.keyCode === KeyCode.TAB) {\n contentRef.current.changeActive(!e.shiftKey);\n }\n }\n } // ========================= Effect =========================\n\n\n useEffect(function () {\n if (visible) {\n setAnimatedVisible(true);\n switchScrollingEffect();\n }\n }, [visible]); // Remove direct should also check the scroll bar update\n\n useEffect(function () {\n return function () {\n switchScrollingEffect();\n clearTimeout(contentTimeoutRef.current);\n };\n }, []); // ========================= Render =========================\n\n return /*#__PURE__*/React.createElement(\"div\", {\n className: \"\".concat(prefixCls, \"-root\")\n }, /*#__PURE__*/React.createElement(Mask, {\n prefixCls: prefixCls,\n visible: mask && visible,\n motionName: getMotionName(prefixCls, maskTransitionName, maskAnimation),\n style: _objectSpread({\n zIndex: zIndex\n }, maskStyle),\n maskProps: maskProps\n }), /*#__PURE__*/React.createElement(\"div\", _extends({\n tabIndex: -1,\n onKeyDown: onWrapperKeyDown,\n className: classNames(\"\".concat(prefixCls, \"-wrap\"), wrapClassName),\n ref: wrapperRef,\n onClick: onWrapperClick,\n role: \"dialog\",\n \"aria-labelledby\": title ? ariaIdRef.current : null,\n style: _objectSpread(_objectSpread({\n zIndex: zIndex\n }, wrapStyle), {}, {\n display: !animatedVisible ? 'none' : null\n })\n }, wrapProps), /*#__PURE__*/React.createElement(Content, _extends({}, props, {\n onMouseDown: onContentMouseDown,\n onMouseUp: onContentMouseUp,\n ref: contentRef,\n closable: closable,\n ariaId: ariaIdRef.current,\n prefixCls: prefixCls,\n visible: visible,\n onClose: onInternalClose,\n onVisibleChanged: onDialogVisibleChanged,\n motionName: getMotionName(prefixCls, transitionName, animation)\n }))));\n}"]},"metadata":{},"sourceType":"module"}