antd3-esm 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/LICENSE +21 -0
  2. package/dist/Checkbox.js +164 -0
  3. package/dist/CommonMixin.js +816 -0
  4. package/dist/Divider.js +646 -0
  5. package/dist/Notification.js +279 -0
  6. package/dist/Pagination.js +1106 -0
  7. package/dist/PortalWrapper.js +347 -0
  8. package/dist/RowContext.js +5 -0
  9. package/dist/Sider.js +533 -0
  10. package/dist/TextArea.js +432 -0
  11. package/dist/_arrayMap.js +68 -0
  12. package/dist/_assignValue.js +95 -0
  13. package/dist/_copyArray.js +31 -0
  14. package/dist/_hasPath.js +53 -0
  15. package/dist/_overArg.js +437 -0
  16. package/dist/_stringToArray.js +136 -0
  17. package/dist/antd/es/affix.js +12 -0
  18. package/dist/antd/es/alert.js +5 -0
  19. package/dist/antd/es/anchor.js +466 -0
  20. package/dist/antd/es/auto-complete.js +5 -0
  21. package/dist/antd/es/avatar.js +5 -0
  22. package/dist/antd/es/back-top.js +5 -0
  23. package/dist/antd/es/badge.js +5 -0
  24. package/dist/antd/es/breadcrumb.js +18 -0
  25. package/dist/antd/es/button.js +12 -0
  26. package/dist/antd/es/calendar.js +953 -0
  27. package/dist/antd/es/card.js +5 -0
  28. package/dist/antd/es/carousel.js +5 -0
  29. package/dist/antd/es/cascader.js +1275 -0
  30. package/dist/antd/es/checkbox.js +11 -0
  31. package/dist/antd/es/col.js +4 -0
  32. package/dist/antd/es/collapse.js +688 -0
  33. package/dist/antd/es/comment.js +5 -0
  34. package/dist/antd/es/config-provider.js +2 -0
  35. package/dist/antd/es/date-picker.js +4322 -0
  36. package/dist/antd/es/descriptions.js +342 -0
  37. package/dist/antd/es/divider.js +53 -0
  38. package/dist/antd/es/drawer.js +1115 -0
  39. package/dist/antd/es/dropdown.js +14 -0
  40. package/dist/antd/es/empty.js +6 -0
  41. package/dist/antd/es/form.js +5008 -0
  42. package/dist/antd/es/grid.js +13 -0
  43. package/dist/antd/es/icon.js +6 -0
  44. package/dist/antd/es/input-number.js +5 -0
  45. package/dist/antd/es/input.js +16 -0
  46. package/dist/antd/es/layout.js +14 -0
  47. package/dist/antd/es/list.js +5 -0
  48. package/dist/antd/es/locale/ar_EG.js +102 -0
  49. package/dist/antd/es/locale/bg_BG.js +98 -0
  50. package/dist/antd/es/locale/ca_ES.js +96 -0
  51. package/dist/antd/es/locale/cs_CZ.js +96 -0
  52. package/dist/antd/es/locale/da_DK.js +98 -0
  53. package/dist/antd/es/locale/de_DE.js +98 -0
  54. package/dist/antd/es/locale/default.js +2 -0
  55. package/dist/antd/es/locale/el_GR.js +98 -0
  56. package/dist/antd/es/locale/en_GB.js +98 -0
  57. package/dist/antd/es/locale/en_US.js +2 -0
  58. package/dist/antd/es/locale/es_ES.js +114 -0
  59. package/dist/antd/es/locale/et_EE.js +98 -0
  60. package/dist/antd/es/locale/fa_IR.js +98 -0
  61. package/dist/antd/es/locale/fi_FI.js +99 -0
  62. package/dist/antd/es/locale/fr_BE.js +102 -0
  63. package/dist/antd/es/locale/fr_FR.js +102 -0
  64. package/dist/antd/es/locale/ga_IE.js +99 -0
  65. package/dist/antd/es/locale/he_IL.js +99 -0
  66. package/dist/antd/es/locale/hi_IN.js +107 -0
  67. package/dist/antd/es/locale/hr_HR.js +113 -0
  68. package/dist/antd/es/locale/hu_HU.js +99 -0
  69. package/dist/antd/es/locale/hy_AM.js +109 -0
  70. package/dist/antd/es/locale/id_ID.js +101 -0
  71. package/dist/antd/es/locale/is_IS.js +98 -0
  72. package/dist/antd/es/locale/it_IT.js +111 -0
  73. package/dist/antd/es/locale/ja_JP.js +96 -0
  74. package/dist/antd/es/locale/kn_IN.js +107 -0
  75. package/dist/antd/es/locale/ko_KR.js +98 -0
  76. package/dist/antd/es/locale/ku_IQ.js +98 -0
  77. package/dist/antd/es/locale/lv_LV.js +98 -0
  78. package/dist/antd/es/locale/mk_MK.js +113 -0
  79. package/dist/antd/es/locale/mn_MN.js +99 -0
  80. package/dist/antd/es/locale/ms_MY.js +118 -0
  81. package/dist/antd/es/locale/nb_NO.js +97 -0
  82. package/dist/antd/es/locale/ne_NP.js +44 -0
  83. package/dist/antd/es/locale/nl_BE.js +98 -0
  84. package/dist/antd/es/locale/nl_NL.js +117 -0
  85. package/dist/antd/es/locale/pl_PL.js +98 -0
  86. package/dist/antd/es/locale/pt_BR.js +104 -0
  87. package/dist/antd/es/locale/pt_PT.js +127 -0
  88. package/dist/antd/es/locale/ro_RO.js +118 -0
  89. package/dist/antd/es/locale/ru_RU.js +110 -0
  90. package/dist/antd/es/locale/sk_SK.js +118 -0
  91. package/dist/antd/es/locale/sl_SI.js +96 -0
  92. package/dist/antd/es/locale/sr_RS.js +97 -0
  93. package/dist/antd/es/locale/sv_SE.js +101 -0
  94. package/dist/antd/es/locale/ta_IN.js +119 -0
  95. package/dist/antd/es/locale/th_TH.js +117 -0
  96. package/dist/antd/es/locale/tr_TR.js +112 -0
  97. package/dist/antd/es/locale/uk_UA.js +97 -0
  98. package/dist/antd/es/locale/vi_VN.js +99 -0
  99. package/dist/antd/es/locale/zh_CN.js +104 -0
  100. package/dist/antd/es/locale/zh_TW.js +100 -0
  101. package/dist/antd/es/locale-provider.js +6 -0
  102. package/dist/antd/es/mention.js +23215 -0
  103. package/dist/antd/es/mentions.js +961 -0
  104. package/dist/antd/es/menu.js +5 -0
  105. package/dist/antd/es/message.js +161 -0
  106. package/dist/antd/es/modal.js +885 -0
  107. package/dist/antd/es/notification.js +216 -0
  108. package/dist/antd/es/page-header.js +350 -0
  109. package/dist/antd/es/pagination.js +15 -0
  110. package/dist/antd/es/popconfirm.js +215 -0
  111. package/dist/antd/es/popover.js +5 -0
  112. package/dist/antd/es/progress.js +10 -0
  113. package/dist/antd/es/radio.js +10 -0
  114. package/dist/antd/es/rate.js +5 -0
  115. package/dist/antd/es/result.js +828 -0
  116. package/dist/antd/es/row.js +9 -0
  117. package/dist/antd/es/select.js +5 -0
  118. package/dist/antd/es/skeleton.js +370 -0
  119. package/dist/antd/es/slider.js +5 -0
  120. package/dist/antd/es/spin.js +11 -0
  121. package/dist/antd/es/statistic.js +650 -0
  122. package/dist/antd/es/steps.js +5 -0
  123. package/dist/antd/es/style.js +5 -0
  124. package/dist/antd/es/switch.js +5 -0
  125. package/dist/antd/es/table.js +7057 -0
  126. package/dist/antd/es/tabs.js +5 -0
  127. package/dist/antd/es/tag.js +12 -0
  128. package/dist/antd/es/time-picker.js +10 -0
  129. package/dist/antd/es/timeline.js +206 -0
  130. package/dist/antd/es/tooltip.js +9 -0
  131. package/dist/antd/es/transfer.js +2508 -0
  132. package/dist/antd/es/tree-select.js +5 -0
  133. package/dist/antd/es/tree.js +10 -0
  134. package/dist/antd/es/typography.js +1246 -0
  135. package/dist/antd/es/upload.js +3418 -0
  136. package/dist/antd/es/version.js +7 -0
  137. package/dist/col.js +142 -0
  138. package/dist/config-provider.js +6949 -0
  139. package/dist/dropdown.js +442 -0
  140. package/dist/get.js +1043 -0
  141. package/dist/icon.js +6138 -0
  142. package/dist/identity.js +230 -0
  143. package/dist/index.js +462 -0
  144. package/dist/index10.js +478 -0
  145. package/dist/index11.js +232 -0
  146. package/dist/index12.js +2766 -0
  147. package/dist/index13.js +422 -0
  148. package/dist/index14.js +283 -0
  149. package/dist/index15.js +1755 -0
  150. package/dist/index2.js +374 -0
  151. package/dist/index3.js +407 -0
  152. package/dist/index4.js +522 -0
  153. package/dist/index5.js +601 -0
  154. package/dist/index6.js +601 -0
  155. package/dist/index7.js +364 -0
  156. package/dist/index8.js +436 -0
  157. package/dist/index9.js +130 -0
  158. package/dist/input.js +475 -0
  159. package/dist/isLength.js +402 -0
  160. package/dist/keys.js +292 -0
  161. package/dist/menu.js +8138 -0
  162. package/dist/progress.js +852 -0
  163. package/dist/raf.js +34 -0
  164. package/dist/responsiveObserve.js +444 -0
  165. package/dist/row.js +173 -0
  166. package/dist/scrollTo.js +66 -0
  167. package/dist/toInteger.js +123 -0
  168. package/dist/toString.js +84 -0
  169. package/dist/transButton.js +121 -0
  170. package/dist/tree.js +3017 -0
  171. package/dist/warning.js +55 -0
  172. package/dist/wave.js +230 -0
  173. package/dist/zh_CN.js +17 -0
  174. package/package.json +160 -0
@@ -0,0 +1,1115 @@
1
+ import { n, c as classNames, s as withConfigConsumer, h as createReactContext } from '../../config-provider.js';
2
+ import * as React from 'react';
3
+ import { g as getScrollBarSize, P as Portal } from '../../PortalWrapper.js';
4
+ import { p as polyfill, K as KeyCode } from '../../menu.js';
5
+ import { o as omit, t as tuple } from '../../input.js';
6
+ import { I as Icon } from '../../icon.js';
7
+ import 'react-dom';
8
+
9
+ var css = "/* stylelint-disable at-rule-empty-line-before,at-rule-name-space-after,at-rule-no-unknown */\n/* stylelint-disable no-duplicate-selectors */\n/* stylelint-disable */\n/* stylelint-disable declaration-bang-space-before,no-duplicate-selectors,string-no-newline */\n.ant-drawer {\n position: fixed;\n z-index: 1000;\n width: 0%;\n height: 100%;\n transition: transform 0.3s cubic-bezier(0.7, 0.3, 0.1, 1), height 0s ease 0.3s, width 0s ease 0.3s;\n}\n.ant-drawer > * {\n transition: transform 0.3s cubic-bezier(0.7, 0.3, 0.1, 1), box-shadow 0.3s cubic-bezier(0.7, 0.3, 0.1, 1);\n}\n.ant-drawer-content-wrapper {\n position: absolute;\n}\n.ant-drawer .ant-drawer-content {\n width: 100%;\n height: 100%;\n}\n.ant-drawer-left,\n.ant-drawer-right {\n top: 0;\n width: 0%;\n height: 100%;\n}\n.ant-drawer-left .ant-drawer-content-wrapper,\n.ant-drawer-right .ant-drawer-content-wrapper {\n height: 100%;\n}\n.ant-drawer-left.ant-drawer-open,\n.ant-drawer-right.ant-drawer-open {\n width: 100%;\n transition: transform 0.3s cubic-bezier(0.7, 0.3, 0.1, 1);\n}\n.ant-drawer-left.ant-drawer-open.no-mask,\n.ant-drawer-right.ant-drawer-open.no-mask {\n width: 0%;\n}\n.ant-drawer-left.ant-drawer-open .ant-drawer-content-wrapper {\n box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);\n}\n.ant-drawer-right {\n right: 0;\n}\n.ant-drawer-right .ant-drawer-content-wrapper {\n right: 0;\n}\n.ant-drawer-right.ant-drawer-open .ant-drawer-content-wrapper {\n box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);\n}\n.ant-drawer-right.ant-drawer-open.no-mask {\n right: 1px;\n transform: translateX(1px);\n}\n.ant-drawer-top,\n.ant-drawer-bottom {\n left: 0;\n width: 100%;\n height: 0%;\n}\n.ant-drawer-top .ant-drawer-content-wrapper,\n.ant-drawer-bottom .ant-drawer-content-wrapper {\n width: 100%;\n}\n.ant-drawer-top.ant-drawer-open,\n.ant-drawer-bottom.ant-drawer-open {\n height: 100%;\n transition: transform 0.3s cubic-bezier(0.7, 0.3, 0.1, 1);\n}\n.ant-drawer-top.ant-drawer-open.no-mask,\n.ant-drawer-bottom.ant-drawer-open.no-mask {\n height: 0%;\n}\n.ant-drawer-top {\n top: 0;\n}\n.ant-drawer-top.ant-drawer-open .ant-drawer-content-wrapper {\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);\n}\n.ant-drawer-bottom {\n bottom: 0;\n}\n.ant-drawer-bottom .ant-drawer-content-wrapper {\n bottom: 0;\n}\n.ant-drawer-bottom.ant-drawer-open .ant-drawer-content-wrapper {\n box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.15);\n}\n.ant-drawer-bottom.ant-drawer-open.no-mask {\n bottom: 1px;\n transform: translateY(1px);\n}\n.ant-drawer.ant-drawer-open .ant-drawer-mask {\n height: 100%;\n opacity: 1;\n transition: none;\n animation: antdDrawerFadeIn 0.3s cubic-bezier(0.7, 0.3, 0.1, 1);\n}\n.ant-drawer-title {\n margin: 0;\n color: rgba(0, 0, 0, 0.85);\n font-weight: 500;\n font-size: 16px;\n line-height: 22px;\n}\n.ant-drawer-content {\n position: relative;\n z-index: 1;\n overflow: auto;\n background-color: #fff;\n background-clip: padding-box;\n border: 0;\n}\n.ant-drawer-close {\n position: absolute;\n top: 0;\n right: 0;\n z-index: 10;\n display: block;\n width: 56px;\n height: 56px;\n padding: 0;\n color: rgba(0, 0, 0, 0.45);\n font-weight: 700;\n font-size: 16px;\n font-style: normal;\n line-height: 56px;\n text-align: center;\n text-transform: none;\n text-decoration: none;\n background: transparent;\n border: 0;\n outline: 0;\n cursor: pointer;\n transition: color 0.3s;\n text-rendering: auto;\n}\n.ant-drawer-close:focus,\n.ant-drawer-close:hover {\n color: rgba(0, 0, 0, 0.75);\n text-decoration: none;\n}\n.ant-drawer-header {\n position: relative;\n padding: 16px 24px;\n color: rgba(0, 0, 0, 0.65);\n background: #fff;\n border-bottom: 1px solid #e8e8e8;\n border-radius: 4px 4px 0 0;\n}\n.ant-drawer-header-no-title {\n color: rgba(0, 0, 0, 0.65);\n background: #fff;\n}\n.ant-drawer-body {\n padding: 24px;\n font-size: 14px;\n line-height: 1.5;\n word-wrap: break-word;\n}\n.ant-drawer-wrapper-body {\n height: 100%;\n overflow: auto;\n}\n.ant-drawer-mask {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 0;\n background-color: rgba(0, 0, 0, 0.45);\n opacity: 0;\n filter: alpha(opacity=45);\n transition: opacity 0.3s linear, height 0s ease 0.3s;\n}\n.ant-drawer-open-content {\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n}\n@keyframes antdDrawerFadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n/*# sourceMappingURL=index.css.map */";
10
+ n(css,{"prepend":true});
11
+
12
+ function dataToArray(vars) {
13
+ if (Array.isArray(vars)) {
14
+ return vars;
15
+ }
16
+
17
+ return [vars];
18
+ }
19
+ var transitionEndObject = {
20
+ transition: 'transitionend',
21
+ WebkitTransition: 'webkitTransitionEnd',
22
+ MozTransition: 'transitionend',
23
+ OTransition: 'oTransitionEnd otransitionend'
24
+ };
25
+ var transitionStr = Object.keys(transitionEndObject).filter(function (key) {
26
+ if (typeof document === 'undefined') {
27
+ return false;
28
+ }
29
+
30
+ var html = document.getElementsByTagName('html')[0];
31
+ return key in (html ? html.style : {});
32
+ })[0];
33
+ var transitionEnd = transitionEndObject[transitionStr];
34
+ function addEventListener(target, eventType, callback, options) {
35
+ if (target.addEventListener) {
36
+ target.addEventListener(eventType, callback, options);
37
+ } else if (target.attachEvent) {
38
+ // tslint:disable-line
39
+ target.attachEvent("on".concat(eventType), callback); // tslint:disable-line
40
+ }
41
+ }
42
+ function removeEventListener(target, eventType, callback, options) {
43
+ if (target.removeEventListener) {
44
+ target.removeEventListener(eventType, callback, options);
45
+ } else if (target.attachEvent) {
46
+ // tslint:disable-line
47
+ target.detachEvent("on".concat(eventType), callback); // tslint:disable-line
48
+ }
49
+ }
50
+ function transformArguments(arg, cb) {
51
+ var result = typeof arg === 'function' ? arg(cb) : arg;
52
+
53
+ if (Array.isArray(result)) {
54
+ if (result.length === 2) {
55
+ return result;
56
+ }
57
+
58
+ return [result[0], result[1]];
59
+ }
60
+
61
+ return [result];
62
+ }
63
+ var isNumeric = function isNumeric(value) {
64
+ return !isNaN(parseFloat(value)) && isFinite(value);
65
+ };
66
+ var windowIsUndefined = !(typeof window !== 'undefined' && window.document && window.document.createElement);
67
+ var getTouchParentScroll = function getTouchParentScroll(root, currentTarget, differX, differY) {
68
+ if (!currentTarget || currentTarget === document || currentTarget instanceof Document) {
69
+ return false;
70
+ } // root 为 drawer-content 设定了 overflow, 判断为 root 的 parent 时结束滚动;
71
+
72
+
73
+ if (currentTarget === root.parentNode) {
74
+ return true;
75
+ }
76
+
77
+ var isY = Math.max(Math.abs(differX), Math.abs(differY)) === Math.abs(differY);
78
+ var isX = Math.max(Math.abs(differX), Math.abs(differY)) === Math.abs(differX);
79
+ var scrollY = currentTarget.scrollHeight - currentTarget.clientHeight;
80
+ var scrollX = currentTarget.scrollWidth - currentTarget.clientWidth;
81
+ var style = document.defaultView.getComputedStyle(currentTarget);
82
+ var overflowY = style.overflowY === 'auto' || style.overflowY === 'scroll';
83
+ var overflowX = style.overflowX === 'auto' || style.overflowX === 'scroll';
84
+ var y = scrollY && overflowY;
85
+ var x = scrollX && overflowX;
86
+
87
+ if (isY && (!y || y && (currentTarget.scrollTop >= scrollY && differY < 0 || currentTarget.scrollTop <= 0 && differY > 0)) || isX && (!x || x && (currentTarget.scrollLeft >= scrollX && scrollX < 0 || currentTarget.scrollLeft <= 0 && scrollX > 0))) {
88
+ return getTouchParentScroll(root, currentTarget.parentNode, differX, differY);
89
+ }
90
+
91
+ return false;
92
+ };
93
+
94
+ function _typeof$2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$2 = function _typeof(obj) { return typeof obj; }; } else { _typeof$2 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$2(obj); }
95
+
96
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
97
+
98
+ function _objectWithoutProperties$1(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose$1(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
99
+
100
+ function _objectWithoutPropertiesLoose$1(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
101
+
102
+ function _classCallCheck$2(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
103
+
104
+ function _defineProperties$2(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
105
+
106
+ function _createClass$2(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$2(Constructor.prototype, protoProps); if (staticProps) _defineProperties$2(Constructor, staticProps); return Constructor; }
107
+
108
+ function _possibleConstructorReturn$2(self, call) { if (call && (_typeof$2(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized$2(self); }
109
+
110
+ function _getPrototypeOf$2(o) { _getPrototypeOf$2 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf$2(o); }
111
+
112
+ function _assertThisInitialized$2(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
113
+
114
+ function _inherits$2(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf$2(subClass, superClass); }
115
+
116
+ function _setPrototypeOf$2(o, p) { _setPrototypeOf$2 = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf$2(o, p); }
117
+ var currentDrawer = {};
118
+
119
+ var DrawerChild =
120
+ /*#__PURE__*/
121
+ function (_React$Component) {
122
+ _inherits$2(DrawerChild, _React$Component);
123
+
124
+ function DrawerChild(props) {
125
+ var _this;
126
+
127
+ _classCallCheck$2(this, DrawerChild);
128
+
129
+ _this = _possibleConstructorReturn$2(this, _getPrototypeOf$2(DrawerChild).call(this, props));
130
+
131
+ _this.domFocus = function () {
132
+ if (_this.dom) {
133
+ _this.dom.focus();
134
+ }
135
+ };
136
+
137
+ _this.removeStartHandler = function (e) {
138
+ if (e.touches.length > 1) {
139
+ return;
140
+ }
141
+
142
+ _this.startPos = {
143
+ x: e.touches[0].clientX,
144
+ y: e.touches[0].clientY
145
+ };
146
+ };
147
+
148
+ _this.removeMoveHandler = function (e) {
149
+ if (e.changedTouches.length > 1) {
150
+ return;
151
+ }
152
+
153
+ var currentTarget = e.currentTarget;
154
+ var differX = e.changedTouches[0].clientX - _this.startPos.x;
155
+ var differY = e.changedTouches[0].clientY - _this.startPos.y;
156
+
157
+ if (currentTarget === _this.maskDom || currentTarget === _this.handlerDom || currentTarget === _this.contentDom && getTouchParentScroll(currentTarget, e.target, differX, differY)) {
158
+ e.preventDefault();
159
+ }
160
+ };
161
+
162
+ _this.transitionEnd = function (e) {
163
+ var dom = e.target;
164
+ removeEventListener(dom, transitionEnd, _this.transitionEnd);
165
+ dom.style.transition = '';
166
+ };
167
+
168
+ _this.onKeyDown = function (e) {
169
+ if (e.keyCode === KeyCode.ESC) {
170
+ var onClose = _this.props.onClose;
171
+ e.stopPropagation();
172
+
173
+ if (onClose) {
174
+ onClose(e);
175
+ }
176
+ }
177
+ };
178
+
179
+ _this.onWrapperTransitionEnd = function (e) {
180
+ var _this$props = _this.props,
181
+ open = _this$props.open,
182
+ afterVisibleChange = _this$props.afterVisibleChange;
183
+
184
+ if (e.target === _this.contentWrapper && e.propertyName.match(/transform$/)) {
185
+ _this.dom.style.transition = '';
186
+
187
+ if (!open && _this.getCurrentDrawerSome()) {
188
+ document.body.style.overflowX = '';
189
+
190
+ if (_this.maskDom) {
191
+ _this.maskDom.style.left = '';
192
+ _this.maskDom.style.width = '';
193
+ }
194
+ }
195
+
196
+ if (afterVisibleChange) {
197
+ afterVisibleChange(!!open);
198
+ }
199
+ }
200
+ };
201
+
202
+ _this.openLevelTransition = function () {
203
+ var _this$props2 = _this.props,
204
+ open = _this$props2.open,
205
+ width = _this$props2.width,
206
+ height = _this$props2.height;
207
+
208
+ var _this$getHorizontalBo = _this.getHorizontalBoolAndPlacementName(),
209
+ isHorizontal = _this$getHorizontalBo.isHorizontal,
210
+ placementName = _this$getHorizontalBo.placementName;
211
+
212
+ var contentValue = _this.contentDom ? _this.contentDom.getBoundingClientRect()[isHorizontal ? 'width' : 'height'] : 0;
213
+ var value = (isHorizontal ? width : height) || contentValue;
214
+
215
+ _this.setLevelAndScrolling(open, placementName, value);
216
+ };
217
+
218
+ _this.setLevelTransform = function (open, placementName, value, right) {
219
+ var _this$props3 = _this.props,
220
+ placement = _this$props3.placement,
221
+ levelMove = _this$props3.levelMove,
222
+ duration = _this$props3.duration,
223
+ ease = _this$props3.ease,
224
+ showMask = _this$props3.showMask; // router 切换时可能会导至页面失去滚动条,所以需要时时获取。
225
+
226
+ _this.levelDom.forEach(function (dom) {
227
+ dom.style.transition = "transform ".concat(duration, " ").concat(ease);
228
+ addEventListener(dom, transitionEnd, _this.transitionEnd);
229
+ var levelValue = open ? value : 0;
230
+
231
+ if (levelMove) {
232
+ var $levelMove = transformArguments(levelMove, {
233
+ target: dom,
234
+ open: open
235
+ });
236
+ levelValue = open ? $levelMove[0] : $levelMove[1] || 0;
237
+ }
238
+
239
+ var $value = typeof levelValue === 'number' ? "".concat(levelValue, "px") : levelValue;
240
+ var placementPos = placement === 'left' || placement === 'top' ? $value : "-".concat($value);
241
+ placementPos = showMask && placement === 'right' && right ? "calc(".concat(placementPos, " + ").concat(right, "px)") : placementPos;
242
+ dom.style.transform = levelValue ? "".concat(placementName, "(").concat(placementPos, ")") : '';
243
+ });
244
+ };
245
+
246
+ _this.setLevelAndScrolling = function (open, placementName, value) {
247
+ var onChange = _this.props.onChange;
248
+
249
+ if (!windowIsUndefined) {
250
+ var right = document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight) && window.innerWidth > document.body.offsetWidth ? getScrollBarSize(true) : 0;
251
+
252
+ _this.setLevelTransform(open, placementName, value, right);
253
+
254
+ _this.toggleScrollingToDrawerAndBody(right);
255
+ }
256
+
257
+ if (onChange) {
258
+ onChange(open);
259
+ }
260
+ };
261
+
262
+ _this.toggleScrollingToDrawerAndBody = function (right) {
263
+ var _this$props4 = _this.props,
264
+ getOpenCount = _this$props4.getOpenCount,
265
+ getContainer = _this$props4.getContainer,
266
+ showMask = _this$props4.showMask,
267
+ open = _this$props4.open;
268
+ var container = getContainer && getContainer();
269
+ var openCount = getOpenCount && getOpenCount(); // 处理 body 滚动
270
+
271
+ if (container && container.parentNode === document.body && showMask) {
272
+ var eventArray = ['touchstart'];
273
+ var domArray = [document.body, _this.maskDom, _this.handlerDom, _this.contentDom];
274
+
275
+ if (open && document.body.style.overflow !== 'hidden') {
276
+ if (right) {
277
+ _this.addScrollingEffect(right);
278
+ }
279
+
280
+ if (openCount === 1) {
281
+ document.body.style.overflow = 'hidden';
282
+ }
283
+
284
+ document.body.style.touchAction = 'none'; // 手机禁滚
285
+
286
+ domArray.forEach(function (item, i) {
287
+ if (!item) {
288
+ return;
289
+ }
290
+
291
+ addEventListener(item, eventArray[i] || 'touchmove', i ? _this.removeMoveHandler : _this.removeStartHandler, _this.passive);
292
+ });
293
+ } else if (_this.getCurrentDrawerSome()) {
294
+ // 没有弹框的状态下清除 overflow;
295
+ if (!openCount) {
296
+ document.body.style.overflow = '';
297
+ }
298
+
299
+ document.body.style.touchAction = '';
300
+
301
+ if (right) {
302
+ _this.remScrollingEffect(right);
303
+ } // 恢复事件
304
+
305
+
306
+ domArray.forEach(function (item, i) {
307
+ if (!item) {
308
+ return;
309
+ }
310
+
311
+ removeEventListener(item, eventArray[i] || 'touchmove', i ? _this.removeMoveHandler : _this.removeStartHandler, _this.passive);
312
+ });
313
+ }
314
+ }
315
+ };
316
+
317
+ _this.addScrollingEffect = function (right) {
318
+ var _this$props5 = _this.props,
319
+ placement = _this$props5.placement,
320
+ duration = _this$props5.duration,
321
+ ease = _this$props5.ease,
322
+ getOpenCount = _this$props5.getOpenCount,
323
+ switchScrollingEffect = _this$props5.switchScrollingEffect;
324
+ var openCount = getOpenCount && getOpenCount();
325
+
326
+ if (openCount === 1) {
327
+ switchScrollingEffect();
328
+ }
329
+
330
+ var widthTransition = "width ".concat(duration, " ").concat(ease);
331
+ var transformTransition = "transform ".concat(duration, " ").concat(ease);
332
+ _this.dom.style.transition = 'none';
333
+
334
+ switch (placement) {
335
+ case 'right':
336
+ _this.dom.style.transform = "translateX(-".concat(right, "px)");
337
+ break;
338
+
339
+ case 'top':
340
+ case 'bottom':
341
+ _this.dom.style.width = "calc(100% - ".concat(right, "px)");
342
+ _this.dom.style.transform = 'translateZ(0)';
343
+ break;
344
+ }
345
+
346
+ clearTimeout(_this.timeout);
347
+ _this.timeout = setTimeout(function () {
348
+ if (_this.dom) {
349
+ _this.dom.style.transition = "".concat(transformTransition, ",").concat(widthTransition);
350
+ _this.dom.style.width = '';
351
+ _this.dom.style.transform = '';
352
+ }
353
+ });
354
+ };
355
+
356
+ _this.remScrollingEffect = function (right) {
357
+ var _this$props6 = _this.props,
358
+ placement = _this$props6.placement,
359
+ duration = _this$props6.duration,
360
+ ease = _this$props6.ease,
361
+ getOpenCount = _this$props6.getOpenCount,
362
+ switchScrollingEffect = _this$props6.switchScrollingEffect;
363
+ var openCount = getOpenCount && getOpenCount();
364
+
365
+ if (!openCount) {
366
+ switchScrollingEffect(true);
367
+ }
368
+
369
+ if (transitionStr) {
370
+ document.body.style.overflowX = 'hidden';
371
+ }
372
+
373
+ _this.dom.style.transition = 'none';
374
+ var heightTransition;
375
+ var widthTransition = "width ".concat(duration, " ").concat(ease);
376
+ var transformTransition = "transform ".concat(duration, " ").concat(ease);
377
+
378
+ switch (placement) {
379
+ case 'left':
380
+ {
381
+ _this.dom.style.width = '100%';
382
+ widthTransition = "width 0s ".concat(ease, " ").concat(duration);
383
+ break;
384
+ }
385
+
386
+ case 'right':
387
+ {
388
+ _this.dom.style.transform = "translateX(".concat(right, "px)");
389
+ _this.dom.style.width = '100%';
390
+ widthTransition = "width 0s ".concat(ease, " ").concat(duration);
391
+
392
+ if (_this.maskDom) {
393
+ _this.maskDom.style.left = "-".concat(right, "px");
394
+ _this.maskDom.style.width = "calc(100% + ".concat(right, "px)");
395
+ }
396
+
397
+ break;
398
+ }
399
+
400
+ case 'top':
401
+ case 'bottom':
402
+ {
403
+ _this.dom.style.width = "calc(100% + ".concat(right, "px)");
404
+ _this.dom.style.height = '100%';
405
+ _this.dom.style.transform = 'translateZ(0)';
406
+ heightTransition = "height 0s ".concat(ease, " ").concat(duration);
407
+ break;
408
+ }
409
+ }
410
+
411
+ clearTimeout(_this.timeout);
412
+ _this.timeout = setTimeout(function () {
413
+ if (_this.dom) {
414
+ _this.dom.style.transition = "".concat(transformTransition, ",").concat(heightTransition ? "".concat(heightTransition, ",") : '').concat(widthTransition);
415
+ _this.dom.style.transform = '';
416
+ _this.dom.style.width = '';
417
+ _this.dom.style.height = '';
418
+ }
419
+ });
420
+ };
421
+
422
+ _this.getCurrentDrawerSome = function () {
423
+ return !Object.keys(currentDrawer).some(function (key) {
424
+ return currentDrawer[key];
425
+ });
426
+ };
427
+
428
+ _this.getLevelDom = function (_ref) {
429
+ var level = _ref.level,
430
+ getContainer = _ref.getContainer;
431
+
432
+ if (windowIsUndefined) {
433
+ return;
434
+ }
435
+
436
+ var container = getContainer && getContainer();
437
+ var parent = container ? container.parentNode : null;
438
+ _this.levelDom = [];
439
+
440
+ if (level === 'all') {
441
+ var children = parent ? Array.prototype.slice.call(parent.children) : [];
442
+ children.forEach(function (child) {
443
+ if (child.nodeName !== 'SCRIPT' && child.nodeName !== 'STYLE' && child.nodeName !== 'LINK' && child !== container) {
444
+ _this.levelDom.push(child);
445
+ }
446
+ });
447
+ } else if (level) {
448
+ dataToArray(level).forEach(function (key) {
449
+ document.querySelectorAll(key).forEach(function (item) {
450
+ _this.levelDom.push(item);
451
+ });
452
+ });
453
+ }
454
+ };
455
+
456
+ _this.getHorizontalBoolAndPlacementName = function () {
457
+ var placement = _this.props.placement;
458
+ var isHorizontal = placement === 'left' || placement === 'right';
459
+ var placementName = "translate".concat(isHorizontal ? 'X' : 'Y');
460
+ return {
461
+ isHorizontal: isHorizontal,
462
+ placementName: placementName
463
+ };
464
+ };
465
+
466
+ _this.state = {
467
+ _self: _assertThisInitialized$2(_this)
468
+ };
469
+ return _this;
470
+ }
471
+
472
+ _createClass$2(DrawerChild, [{
473
+ key: "componentDidMount",
474
+ value: function componentDidMount() {
475
+ var _this2 = this;
476
+
477
+ if (!windowIsUndefined) {
478
+ var passiveSupported = false;
479
+
480
+ try {
481
+ window.addEventListener('test', null, Object.defineProperty({}, 'passive', {
482
+ get: function get() {
483
+ passiveSupported = true;
484
+ return null;
485
+ }
486
+ }));
487
+ } catch (err) {}
488
+
489
+ this.passive = passiveSupported ? {
490
+ passive: false
491
+ } : false;
492
+ }
493
+
494
+ var open = this.props.open;
495
+ this.drawerId = "drawer_id_".concat(Number((Date.now() + Math.random()).toString().replace('.', Math.round(Math.random() * 9).toString())).toString(16));
496
+ this.getLevelDom(this.props);
497
+
498
+ if (open) {
499
+ currentDrawer[this.drawerId] = open; // 默认打开状态时推出 level;
500
+
501
+ this.openLevelTransition();
502
+ this.forceUpdate(function () {
503
+ _this2.domFocus();
504
+ });
505
+ }
506
+ }
507
+ }, {
508
+ key: "componentDidUpdate",
509
+ value: function componentDidUpdate(prevProps) {
510
+ var open = this.props.open;
511
+
512
+ if (open !== prevProps.open) {
513
+ if (open) {
514
+ this.domFocus();
515
+ }
516
+
517
+ currentDrawer[this.drawerId] = !!open;
518
+ this.openLevelTransition();
519
+ }
520
+ }
521
+ }, {
522
+ key: "componentWillUnmount",
523
+ value: function componentWillUnmount() {
524
+ var _this$props7 = this.props,
525
+ getOpenCount = _this$props7.getOpenCount,
526
+ open = _this$props7.open,
527
+ switchScrollingEffect = _this$props7.switchScrollingEffect;
528
+ var openCount = typeof getOpenCount === 'function' && getOpenCount();
529
+ delete currentDrawer[this.drawerId];
530
+
531
+ if (open) {
532
+ this.setLevelTransform(false);
533
+ document.body.style.touchAction = '';
534
+ }
535
+
536
+ if (!openCount) {
537
+ document.body.style.overflow = '';
538
+ switchScrollingEffect(true);
539
+ }
540
+ } // tslint:disable-next-line:member-ordering
541
+
542
+ }, {
543
+ key: "render",
544
+ value: function render() {
545
+ var _classnames,
546
+ _this3 = this;
547
+
548
+ var _this$props8 = this.props,
549
+ className = _this$props8.className,
550
+ children = _this$props8.children,
551
+ style = _this$props8.style,
552
+ width = _this$props8.width,
553
+ height = _this$props8.height,
554
+ $open = _this$props8.open,
555
+ prefixCls = _this$props8.prefixCls,
556
+ placement = _this$props8.placement,
557
+ handler = _this$props8.handler,
558
+ showMask = _this$props8.showMask,
559
+ maskClosable = _this$props8.maskClosable,
560
+ maskStyle = _this$props8.maskStyle,
561
+ onClose = _this$props8.onClose,
562
+ onHandleClick = _this$props8.onHandleClick,
563
+ keyboard = _this$props8.keyboard,
564
+ props = _objectWithoutProperties$1(_this$props8, ["className", "children", "style", "width", "height", "defaultOpen", "open", "prefixCls", "placement", "level", "levelMove", "ease", "duration", "getContainer", "handler", "onChange", "afterVisibleChange", "showMask", "maskClosable", "maskStyle", "onClose", "onHandleClick", "keyboard", "getOpenCount", "switchScrollingEffect"]); // 首次渲染都将是关闭状态。
565
+
566
+
567
+ var open = this.dom ? $open : false;
568
+ var wrapperClassName = classNames(prefixCls, (_classnames = {}, _defineProperty(_classnames, "".concat(prefixCls, "-").concat(placement), true), _defineProperty(_classnames, "".concat(prefixCls, "-open"), open), _defineProperty(_classnames, className || '', !!className), _defineProperty(_classnames, 'no-mask', !showMask), _classnames));
569
+
570
+ var _this$getHorizontalBo2 = this.getHorizontalBoolAndPlacementName(),
571
+ placementName = _this$getHorizontalBo2.placementName; // 百分比与像素动画不同步,第一次打用后全用像素动画。
572
+ // const defaultValue = !this.contentDom || !level ? '100%' : `${value}px`;
573
+
574
+
575
+ var placementPos = placement === 'left' || placement === 'top' ? '-100%' : '100%';
576
+ var transform = open ? '' : "".concat(placementName, "(").concat(placementPos, ")");
577
+ var handlerChildren = handler && React.cloneElement(handler, {
578
+ onClick: function onClick(e) {
579
+ if (handler.props.onClick) {
580
+ handler.props.onClick();
581
+ }
582
+
583
+ if (onHandleClick) {
584
+ onHandleClick(e);
585
+ }
586
+ },
587
+ ref: function ref(c) {
588
+ _this3.handlerDom = c;
589
+ }
590
+ });
591
+ return React.createElement("div", Object.assign({}, props, {
592
+ tabIndex: -1,
593
+ className: wrapperClassName,
594
+ style: style,
595
+ ref: function ref(c) {
596
+ _this3.dom = c;
597
+ },
598
+ onKeyDown: open && keyboard ? this.onKeyDown : undefined,
599
+ onTransitionEnd: this.onWrapperTransitionEnd
600
+ }), showMask && React.createElement("div", {
601
+ className: "".concat(prefixCls, "-mask"),
602
+ onClick: maskClosable ? onClose : undefined,
603
+ style: maskStyle,
604
+ ref: function ref(c) {
605
+ _this3.maskDom = c;
606
+ }
607
+ }), React.createElement("div", {
608
+ className: "".concat(prefixCls, "-content-wrapper"),
609
+ style: {
610
+ transform: transform,
611
+ msTransform: transform,
612
+ width: isNumeric(width) ? "".concat(width, "px") : width,
613
+ height: isNumeric(height) ? "".concat(height, "px") : height
614
+ },
615
+ ref: function ref(c) {
616
+ _this3.contentWrapper = c;
617
+ }
618
+ }, React.createElement("div", {
619
+ className: "".concat(prefixCls, "-content"),
620
+ ref: function ref(c) {
621
+ _this3.contentDom = c;
622
+ },
623
+ onTouchStart: open && showMask ? this.removeStartHandler : undefined,
624
+ onTouchMove: open && showMask ? this.removeMoveHandler : undefined
625
+ }, children), handlerChildren));
626
+ }
627
+ }], [{
628
+ key: "getDerivedStateFromProps",
629
+ value: function getDerivedStateFromProps(props, _ref2) {
630
+ var prevProps = _ref2.prevProps,
631
+ _self = _ref2._self;
632
+ var nextState = {
633
+ prevProps: props
634
+ };
635
+
636
+ if (prevProps !== undefined) {
637
+ var placement = props.placement,
638
+ level = props.level;
639
+
640
+ if (placement !== prevProps.placement) {
641
+ // test 的 bug, 有动画过场,删除 dom
642
+ _self.contentDom = null;
643
+ }
644
+
645
+ if (level !== prevProps.level) {
646
+ _self.getLevelDom(props);
647
+ }
648
+ }
649
+
650
+ return nextState;
651
+ }
652
+ }]);
653
+
654
+ return DrawerChild;
655
+ }(React.Component);
656
+
657
+ DrawerChild.defaultProps = {
658
+ switchScrollingEffect: function switchScrollingEffect() {}
659
+ };
660
+ var Child = polyfill(DrawerChild);
661
+
662
+ function _typeof$1(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$1 = function _typeof(obj) { return typeof obj; }; } else { _typeof$1 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$1(obj); }
663
+
664
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
665
+
666
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
667
+
668
+ function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
669
+
670
+ function _defineProperties$1(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
671
+
672
+ function _createClass$1(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); if (staticProps) _defineProperties$1(Constructor, staticProps); return Constructor; }
673
+
674
+ function _possibleConstructorReturn$1(self, call) { if (call && (_typeof$1(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized$1(self); }
675
+
676
+ function _assertThisInitialized$1(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
677
+
678
+ function _getPrototypeOf$1(o) { _getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf$1(o); }
679
+
680
+ function _inherits$1(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf$1(subClass, superClass); }
681
+
682
+ function _setPrototypeOf$1(o, p) { _setPrototypeOf$1 = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf$1(o, p); }
683
+
684
+ var DrawerWrapper =
685
+ /*#__PURE__*/
686
+ function (_React$Component) {
687
+ _inherits$1(DrawerWrapper, _React$Component);
688
+
689
+ function DrawerWrapper(props) {
690
+ var _this;
691
+
692
+ _classCallCheck$1(this, DrawerWrapper);
693
+
694
+ _this = _possibleConstructorReturn$1(this, _getPrototypeOf$1(DrawerWrapper).call(this, props));
695
+
696
+ _this.onHandleClick = function (e) {
697
+ var _this$props = _this.props,
698
+ onHandleClick = _this$props.onHandleClick,
699
+ $open = _this$props.open;
700
+
701
+ if (onHandleClick) {
702
+ onHandleClick(e);
703
+ }
704
+
705
+ if (typeof $open === 'undefined') {
706
+ var _open = _this.state.open;
707
+
708
+ _this.setState({
709
+ open: !_open
710
+ });
711
+ }
712
+ };
713
+
714
+ _this.onClose = function (e) {
715
+ var _this$props2 = _this.props,
716
+ onClose = _this$props2.onClose,
717
+ open = _this$props2.open;
718
+
719
+ if (onClose) {
720
+ onClose(e);
721
+ }
722
+
723
+ if (typeof open === 'undefined') {
724
+ _this.setState({
725
+ open: false
726
+ });
727
+ }
728
+ };
729
+
730
+ var open = typeof props.open !== 'undefined' ? props.open : !!props.defaultOpen;
731
+ _this.state = {
732
+ open: open
733
+ };
734
+
735
+ if ('onMaskClick' in props) {
736
+ console.warn('`onMaskClick` are removed, please use `onClose` instead.');
737
+ }
738
+
739
+ return _this;
740
+ }
741
+
742
+ _createClass$1(DrawerWrapper, [{
743
+ key: "render",
744
+ // tslint:disable-next-line:member-ordering
745
+ value: function render() {
746
+ var _this2 = this;
747
+
748
+ var _this$props3 = this.props,
749
+ getContainer = _this$props3.getContainer,
750
+ wrapperClassName = _this$props3.wrapperClassName,
751
+ forceRender = _this$props3.forceRender,
752
+ handler = _this$props3.handler,
753
+ props = _objectWithoutProperties(_this$props3, ["defaultOpen", "getContainer", "wrapperClassName", "forceRender", "handler"]);
754
+
755
+ var open = this.state.open; // 渲染在当前 dom 里;
756
+
757
+ if (!getContainer) {
758
+ return React.createElement("div", {
759
+ className: wrapperClassName,
760
+ ref: function ref(c) {
761
+ _this2.dom = c;
762
+ }
763
+ }, React.createElement(Child, Object.assign({}, props, {
764
+ open: open,
765
+ handler: handler,
766
+ getContainer: function getContainer() {
767
+ return _this2.dom;
768
+ },
769
+ onClose: this.onClose,
770
+ onHandleClick: this.onHandleClick
771
+ })));
772
+ } // 如果有 handler 为内置强制渲染;
773
+
774
+
775
+ var $forceRender = !!handler || forceRender;
776
+ return React.createElement(Portal, {
777
+ visible: open,
778
+ forceRender: $forceRender,
779
+ getContainer: getContainer,
780
+ wrapperClassName: wrapperClassName
781
+ }, function (_ref) {
782
+ var visible = _ref.visible,
783
+ afterClose = _ref.afterClose,
784
+ rest = _objectWithoutProperties(_ref, ["visible", "afterClose"]);
785
+
786
+ return (// react 15,componentWillUnmount 时 Portal 返回 afterClose, visible.
787
+ React.createElement(Child, Object.assign({}, props, rest, {
788
+ open: visible !== undefined ? visible : open,
789
+ afterVisibleChange: afterClose !== undefined ? afterClose : props.afterVisibleChange,
790
+ handler: handler,
791
+ onClose: _this2.onClose,
792
+ onHandleClick: _this2.onHandleClick
793
+ }))
794
+ );
795
+ });
796
+ }
797
+ }], [{
798
+ key: "getDerivedStateFromProps",
799
+ value: function getDerivedStateFromProps(props, _ref2) {
800
+ var prevProps = _ref2.prevProps;
801
+ var newState = {
802
+ prevProps: props
803
+ };
804
+
805
+ if (typeof prevProps !== 'undefined' && props.open !== prevProps.open) {
806
+ newState.open = props.open;
807
+ }
808
+
809
+ return newState;
810
+ }
811
+ }]);
812
+
813
+ return DrawerWrapper;
814
+ }(React.Component);
815
+
816
+ DrawerWrapper.defaultProps = {
817
+ prefixCls: 'drawer',
818
+ placement: 'left',
819
+ getContainer: 'body',
820
+ defaultOpen: false,
821
+ level: 'all',
822
+ duration: '.3s',
823
+ ease: 'cubic-bezier(0.78, 0.14, 0.15, 0.86)',
824
+ onChange: function onChange() {},
825
+ afterVisibleChange: function afterVisibleChange() {},
826
+ handler: React.createElement("div", {
827
+ className: "drawer-handle"
828
+ }, React.createElement("i", {
829
+ className: "drawer-handle-icon"
830
+ })),
831
+ showMask: true,
832
+ maskClosable: true,
833
+ maskStyle: {},
834
+ wrapperClassName: '',
835
+ className: '',
836
+ keyboard: true,
837
+ forceRender: false
838
+ };
839
+ var Drawer$1 = polyfill(DrawerWrapper);
840
+
841
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
842
+
843
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
844
+
845
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
846
+
847
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
848
+
849
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); return Constructor; }
850
+
851
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
852
+
853
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
854
+
855
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
856
+
857
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
858
+
859
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
860
+
861
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
862
+
863
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
864
+
865
+ var __rest = undefined && undefined.__rest || function (s, e) {
866
+ var t = {};
867
+
868
+ for (var p in s) {
869
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
870
+ }
871
+
872
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
873
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
874
+ }
875
+ return t;
876
+ };
877
+ var DrawerContext = createReactContext(null);
878
+ tuple('top', 'right', 'bottom', 'left');
879
+
880
+ var Drawer = /*#__PURE__*/function (_React$Component) {
881
+ _inherits(Drawer, _React$Component);
882
+
883
+ var _super = _createSuper(Drawer);
884
+
885
+ function Drawer() {
886
+ var _this;
887
+
888
+ _classCallCheck(this, Drawer);
889
+
890
+ _this = _super.apply(this, arguments);
891
+ _this.state = {
892
+ push: false
893
+ };
894
+
895
+ _this.push = function () {
896
+ _this.setState({
897
+ push: true
898
+ });
899
+ };
900
+
901
+ _this.pull = function () {
902
+ _this.setState({
903
+ push: false
904
+ });
905
+ };
906
+
907
+ _this.onDestroyTransitionEnd = function () {
908
+ var isDestroyOnClose = _this.getDestroyOnClose();
909
+
910
+ if (!isDestroyOnClose) {
911
+ return;
912
+ }
913
+
914
+ if (!_this.props.visible) {
915
+ _this.destroyClose = true;
916
+
917
+ _this.forceUpdate();
918
+ }
919
+ };
920
+
921
+ _this.getDestroyOnClose = function () {
922
+ return _this.props.destroyOnClose && !_this.props.visible;
923
+ }; // get drawer push width or height
924
+
925
+
926
+ _this.getPushTransform = function (placement) {
927
+ if (placement === 'left' || placement === 'right') {
928
+ return "translateX(".concat(placement === 'left' ? 180 : -180, "px)");
929
+ }
930
+
931
+ if (placement === 'top' || placement === 'bottom') {
932
+ return "translateY(".concat(placement === 'top' ? 180 : -180, "px)");
933
+ }
934
+ };
935
+
936
+ _this.getRcDrawerStyle = function () {
937
+ var _this$props = _this.props,
938
+ zIndex = _this$props.zIndex,
939
+ placement = _this$props.placement,
940
+ style = _this$props.style;
941
+ var push = _this.state.push;
942
+ return _extends({
943
+ zIndex: zIndex,
944
+ transform: push ? _this.getPushTransform(placement) : undefined
945
+ }, style);
946
+ }; // render drawer body dom
947
+
948
+
949
+ _this.renderBody = function () {
950
+ var _this$props2 = _this.props,
951
+ bodyStyle = _this$props2.bodyStyle,
952
+ drawerStyle = _this$props2.drawerStyle,
953
+ prefixCls = _this$props2.prefixCls,
954
+ visible = _this$props2.visible;
955
+
956
+ if (_this.destroyClose && !visible) {
957
+ return null;
958
+ }
959
+
960
+ _this.destroyClose = false;
961
+ var containerStyle = {};
962
+
963
+ var isDestroyOnClose = _this.getDestroyOnClose();
964
+
965
+ if (isDestroyOnClose) {
966
+ // Increase the opacity transition, delete children after closing.
967
+ containerStyle.opacity = 0;
968
+ containerStyle.transition = 'opacity .3s';
969
+ }
970
+
971
+ return /*#__PURE__*/React.createElement("div", {
972
+ className: "".concat(prefixCls, "-wrapper-body"),
973
+ style: _extends(_extends({}, containerStyle), drawerStyle),
974
+ onTransitionEnd: _this.onDestroyTransitionEnd
975
+ }, _this.renderHeader(), /*#__PURE__*/React.createElement("div", {
976
+ className: "".concat(prefixCls, "-body"),
977
+ style: bodyStyle
978
+ }, _this.props.children));
979
+ }; // render Provider for Multi-level drawer
980
+
981
+
982
+ _this.renderProvider = function (value) {
983
+ var _a = _this.props,
984
+ prefixCls = _a.prefixCls,
985
+ placement = _a.placement,
986
+ className = _a.className,
987
+ wrapClassName = _a.wrapClassName,
988
+ width = _a.width,
989
+ height = _a.height,
990
+ mask = _a.mask,
991
+ rest = __rest(_a, ["prefixCls", "placement", "className", "wrapClassName", "width", "height", "mask"]);
992
+ var haveMask = mask ? '' : 'no-mask';
993
+ _this.parentDrawer = value;
994
+ var offsetStyle = {};
995
+
996
+ if (placement === 'left' || placement === 'right') {
997
+ offsetStyle.width = width;
998
+ } else {
999
+ offsetStyle.height = height;
1000
+ }
1001
+
1002
+ return /*#__PURE__*/React.createElement(DrawerContext.Provider, {
1003
+ value: _assertThisInitialized(_this)
1004
+ }, /*#__PURE__*/React.createElement(Drawer$1, _extends({
1005
+ handler: false
1006
+ }, omit(rest, ['zIndex', 'style', 'closable', 'destroyOnClose', 'drawerStyle', 'headerStyle', 'bodyStyle', 'title', 'push', 'visible', 'getPopupContainer', 'rootPrefixCls', 'getPrefixCls', 'renderEmpty', 'csp', 'pageHeader', 'autoInsertSpaceInButton']), offsetStyle, {
1007
+ prefixCls: prefixCls,
1008
+ open: _this.props.visible,
1009
+ showMask: mask,
1010
+ placement: placement,
1011
+ style: _this.getRcDrawerStyle(),
1012
+ className: classNames(wrapClassName, className, haveMask)
1013
+ }), _this.renderBody()));
1014
+ };
1015
+
1016
+ return _this;
1017
+ }
1018
+
1019
+ _createClass(Drawer, [{
1020
+ key: "componentDidMount",
1021
+ value: function componentDidMount() {
1022
+ // fix: delete drawer in child and re-render, no push started.
1023
+ // <Drawer>{show && <Drawer />}</Drawer>
1024
+ var visible = this.props.visible;
1025
+
1026
+ if (visible && this.parentDrawer) {
1027
+ this.parentDrawer.push();
1028
+ }
1029
+ }
1030
+ }, {
1031
+ key: "componentDidUpdate",
1032
+ value: function componentDidUpdate(preProps) {
1033
+ var visible = this.props.visible;
1034
+
1035
+ if (preProps.visible !== visible && this.parentDrawer) {
1036
+ if (visible) {
1037
+ this.parentDrawer.push();
1038
+ } else {
1039
+ this.parentDrawer.pull();
1040
+ }
1041
+ }
1042
+ }
1043
+ }, {
1044
+ key: "componentWillUnmount",
1045
+ value: function componentWillUnmount() {
1046
+ // unmount drawer in child, clear push.
1047
+ if (this.parentDrawer) {
1048
+ this.parentDrawer.pull();
1049
+ this.parentDrawer = null;
1050
+ }
1051
+ }
1052
+ }, {
1053
+ key: "renderHeader",
1054
+ value: function renderHeader() {
1055
+ var _this$props3 = this.props,
1056
+ title = _this$props3.title,
1057
+ prefixCls = _this$props3.prefixCls,
1058
+ closable = _this$props3.closable,
1059
+ headerStyle = _this$props3.headerStyle;
1060
+
1061
+ if (!title && !closable) {
1062
+ return null;
1063
+ }
1064
+
1065
+ var headerClassName = title ? "".concat(prefixCls, "-header") : "".concat(prefixCls, "-header-no-title");
1066
+ return /*#__PURE__*/React.createElement("div", {
1067
+ className: headerClassName,
1068
+ style: headerStyle
1069
+ }, title && /*#__PURE__*/React.createElement("div", {
1070
+ className: "".concat(prefixCls, "-title")
1071
+ }, title), closable && this.renderCloseIcon());
1072
+ }
1073
+ }, {
1074
+ key: "renderCloseIcon",
1075
+ value: function renderCloseIcon() {
1076
+ var _this$props4 = this.props,
1077
+ closable = _this$props4.closable,
1078
+ prefixCls = _this$props4.prefixCls,
1079
+ onClose = _this$props4.onClose;
1080
+ return closable &&
1081
+ /*#__PURE__*/
1082
+ // eslint-disable-next-line react/button-has-type
1083
+ React.createElement("button", {
1084
+ onClick: onClose,
1085
+ "aria-label": "Close",
1086
+ className: "".concat(prefixCls, "-close")
1087
+ }, /*#__PURE__*/React.createElement(Icon, {
1088
+ type: "close"
1089
+ }));
1090
+ }
1091
+ }, {
1092
+ key: "render",
1093
+ value: function render() {
1094
+ return /*#__PURE__*/React.createElement(DrawerContext.Consumer, null, this.renderProvider);
1095
+ }
1096
+ }]);
1097
+
1098
+ return Drawer;
1099
+ }(React.Component);
1100
+
1101
+ Drawer.defaultProps = {
1102
+ width: 256,
1103
+ height: 256,
1104
+ closable: true,
1105
+ placement: 'right',
1106
+ maskClosable: true,
1107
+ mask: true,
1108
+ level: null,
1109
+ keyboard: true
1110
+ };
1111
+ var index = withConfigConsumer({
1112
+ prefixCls: 'drawer'
1113
+ })(Drawer);
1114
+
1115
+ export { index as default };