@arco-design/mobile-react 2.20.0 → 2.21.0

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 (295) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.en-US.md +2 -2
  3. package/README.md +2 -2
  4. package/cjs/avatar/index.d.ts +1 -1
  5. package/cjs/avatar/index.js +1 -1
  6. package/cjs/badge/index.d.ts +1 -1
  7. package/cjs/badge/index.js +1 -1
  8. package/cjs/carousel/index.d.ts +1 -1
  9. package/cjs/carousel/index.js +1 -1
  10. package/cjs/cell/index.d.ts +1 -1
  11. package/cjs/cell/index.js +1 -1
  12. package/cjs/checkbox/index.d.ts +1 -1
  13. package/cjs/checkbox/index.js +1 -1
  14. package/cjs/collapse/index.d.ts +1 -1
  15. package/cjs/collapse/index.js +1 -1
  16. package/cjs/count-down/index.d.ts +1 -1
  17. package/cjs/count-down/index.js +1 -1
  18. package/cjs/date-picker/index.d.ts +1 -1
  19. package/cjs/date-picker/index.js +1 -1
  20. package/cjs/dropdown/dropdown.js +36 -20
  21. package/cjs/dropdown/style/css/index.css +3 -0
  22. package/cjs/dropdown/style/index.less +2 -0
  23. package/cjs/ellipsis/index.d.ts +1 -1
  24. package/cjs/ellipsis/index.js +1 -1
  25. package/cjs/image/index.d.ts +1 -1
  26. package/cjs/image/index.js +1 -1
  27. package/cjs/image-picker/index.d.ts +4 -175
  28. package/cjs/image-picker/index.js +41 -18
  29. package/cjs/image-picker/type.d.ts +174 -0
  30. package/cjs/image-picker/type.js +3 -0
  31. package/cjs/image-preview/index.d.ts +1 -1
  32. package/cjs/image-preview/index.js +1 -1
  33. package/cjs/index.d.ts +2 -0
  34. package/cjs/index.js +9 -1
  35. package/cjs/input/hooks.js +49 -8
  36. package/cjs/input/index.d.ts +1 -1
  37. package/cjs/input/index.js +1 -1
  38. package/cjs/input/props.d.ts +8 -2
  39. package/cjs/notice-bar/index.d.ts +1 -1
  40. package/cjs/notice-bar/index.js +1 -1
  41. package/cjs/picker/index.d.ts +1 -1
  42. package/cjs/picker/index.js +1 -1
  43. package/cjs/picker-view/index.d.ts +1 -1
  44. package/cjs/picker-view/index.js +1 -1
  45. package/cjs/popover/index.d.ts +1 -1
  46. package/cjs/popover/index.js +1 -1
  47. package/cjs/popup-swiper/index.js +3 -2
  48. package/cjs/radio/index.d.ts +1 -1
  49. package/cjs/radio/index.js +1 -1
  50. package/cjs/rate/index.d.ts +1 -1
  51. package/cjs/rate/index.js +1 -1
  52. package/cjs/search-bar/association.d.ts +3 -0
  53. package/cjs/search-bar/association.js +92 -0
  54. package/cjs/search-bar/cancel-button.d.ts +10 -0
  55. package/cjs/search-bar/cancel-button.js +41 -0
  56. package/cjs/search-bar/demo/style/css/mobile.css +5 -0
  57. package/cjs/search-bar/demo/style/mobile.less +9 -0
  58. package/cjs/search-bar/highlight.d.ts +12 -0
  59. package/cjs/search-bar/highlight.js +77 -0
  60. package/cjs/search-bar/index.d.ts +13 -0
  61. package/cjs/search-bar/index.js +239 -0
  62. package/cjs/search-bar/style/css/index.css +148 -0
  63. package/cjs/search-bar/style/css/index.d.ts +2 -0
  64. package/cjs/search-bar/style/css/index.js +5 -0
  65. package/cjs/search-bar/style/index.d.ts +2 -0
  66. package/cjs/search-bar/style/index.js +5 -0
  67. package/cjs/search-bar/style/index.less +111 -0
  68. package/cjs/search-bar/type.d.ts +163 -0
  69. package/cjs/search-bar/type.js +3 -0
  70. package/cjs/slider/index.d.ts +1 -1
  71. package/cjs/slider/index.js +1 -1
  72. package/cjs/steps/index.d.ts +1 -1
  73. package/cjs/steps/index.js +1 -1
  74. package/cjs/sticky/index.d.ts +1 -1
  75. package/cjs/style.d.ts +2 -0
  76. package/cjs/style.js +4 -0
  77. package/cjs/swipe-action/demo/style/css/mobile.css +5 -0
  78. package/cjs/swipe-action/demo/style/mobile.less +9 -0
  79. package/cjs/swipe-action/index.d.ts +12 -0
  80. package/cjs/swipe-action/index.js +339 -0
  81. package/cjs/swipe-action/item.d.ts +11 -0
  82. package/cjs/swipe-action/item.js +52 -0
  83. package/cjs/swipe-action/style/css/index.css +88 -0
  84. package/cjs/swipe-action/style/css/index.d.ts +2 -0
  85. package/cjs/swipe-action/style/css/index.js +5 -0
  86. package/cjs/swipe-action/style/index.d.ts +2 -0
  87. package/cjs/swipe-action/style/index.js +5 -0
  88. package/cjs/swipe-action/style/index.less +89 -0
  89. package/cjs/swipe-action/type.d.ts +123 -0
  90. package/cjs/swipe-action/type.js +3 -0
  91. package/cjs/switch/index.d.ts +1 -1
  92. package/cjs/switch/index.js +1 -1
  93. package/cjs/tabs/tab-pane.js +5 -1
  94. package/cjs/tag/index.d.ts +1 -1
  95. package/cjs/tag/index.js +1 -1
  96. package/cjs/textarea/index.d.ts +1 -1
  97. package/cjs/textarea/index.js +1 -1
  98. package/dist/index.js +7450 -6611
  99. package/dist/index.min.js +6 -6
  100. package/dist/style.css +203 -0
  101. package/dist/style.min.css +1 -1
  102. package/esm/avatar/index.d.ts +1 -1
  103. package/esm/avatar/index.js +1 -1
  104. package/esm/badge/index.d.ts +1 -1
  105. package/esm/badge/index.js +1 -1
  106. package/esm/carousel/index.d.ts +1 -1
  107. package/esm/carousel/index.js +1 -1
  108. package/esm/cell/index.d.ts +1 -1
  109. package/esm/cell/index.js +1 -1
  110. package/esm/checkbox/index.d.ts +1 -1
  111. package/esm/checkbox/index.js +1 -1
  112. package/esm/collapse/index.d.ts +1 -1
  113. package/esm/collapse/index.js +1 -1
  114. package/esm/count-down/index.d.ts +1 -1
  115. package/esm/count-down/index.js +1 -1
  116. package/esm/date-picker/index.d.ts +1 -1
  117. package/esm/date-picker/index.js +1 -1
  118. package/esm/dropdown/dropdown.js +36 -20
  119. package/esm/dropdown/style/css/index.css +3 -0
  120. package/esm/dropdown/style/index.less +2 -0
  121. package/esm/ellipsis/index.d.ts +1 -1
  122. package/esm/ellipsis/index.js +1 -1
  123. package/esm/image/index.d.ts +1 -1
  124. package/esm/image/index.js +1 -1
  125. package/esm/image-picker/index.d.ts +4 -175
  126. package/esm/image-picker/index.js +30 -17
  127. package/esm/image-picker/type.d.ts +174 -0
  128. package/esm/image-picker/type.js +1 -0
  129. package/esm/image-preview/index.d.ts +1 -1
  130. package/esm/image-preview/index.js +1 -1
  131. package/esm/index.d.ts +2 -0
  132. package/esm/index.js +2 -0
  133. package/esm/input/hooks.js +49 -8
  134. package/esm/input/index.d.ts +1 -1
  135. package/esm/input/index.js +1 -1
  136. package/esm/input/props.d.ts +8 -2
  137. package/esm/notice-bar/index.d.ts +1 -1
  138. package/esm/notice-bar/index.js +1 -1
  139. package/esm/picker/index.d.ts +1 -1
  140. package/esm/picker/index.js +1 -1
  141. package/esm/picker-view/index.d.ts +1 -1
  142. package/esm/picker-view/index.js +1 -1
  143. package/esm/popover/index.d.ts +1 -1
  144. package/esm/popover/index.js +1 -1
  145. package/esm/popup-swiper/index.js +3 -2
  146. package/esm/radio/index.d.ts +1 -1
  147. package/esm/radio/index.js +1 -1
  148. package/esm/rate/index.d.ts +1 -1
  149. package/esm/rate/index.js +1 -1
  150. package/esm/search-bar/association.d.ts +3 -0
  151. package/esm/search-bar/association.js +82 -0
  152. package/esm/search-bar/cancel-button.d.ts +10 -0
  153. package/esm/search-bar/cancel-button.js +30 -0
  154. package/esm/search-bar/demo/style/css/mobile.css +5 -0
  155. package/esm/search-bar/demo/style/mobile.less +9 -0
  156. package/esm/search-bar/highlight.d.ts +12 -0
  157. package/esm/search-bar/highlight.js +66 -0
  158. package/esm/search-bar/index.d.ts +13 -0
  159. package/esm/search-bar/index.js +213 -0
  160. package/esm/search-bar/style/css/index.css +148 -0
  161. package/esm/search-bar/style/css/index.d.ts +2 -0
  162. package/esm/search-bar/style/css/index.js +2 -0
  163. package/esm/search-bar/style/index.d.ts +2 -0
  164. package/esm/search-bar/style/index.js +2 -0
  165. package/esm/search-bar/style/index.less +111 -0
  166. package/esm/search-bar/type.d.ts +163 -0
  167. package/esm/search-bar/type.js +1 -0
  168. package/esm/slider/index.d.ts +1 -1
  169. package/esm/slider/index.js +1 -1
  170. package/esm/steps/index.d.ts +1 -1
  171. package/esm/steps/index.js +1 -1
  172. package/esm/sticky/index.d.ts +1 -1
  173. package/esm/style.d.ts +2 -0
  174. package/esm/style.js +2 -0
  175. package/esm/swipe-action/demo/style/css/mobile.css +5 -0
  176. package/esm/swipe-action/demo/style/mobile.less +9 -0
  177. package/esm/swipe-action/index.d.ts +12 -0
  178. package/esm/swipe-action/index.js +321 -0
  179. package/esm/swipe-action/item.d.ts +11 -0
  180. package/esm/swipe-action/item.js +42 -0
  181. package/esm/swipe-action/style/css/index.css +88 -0
  182. package/esm/swipe-action/style/css/index.d.ts +2 -0
  183. package/esm/swipe-action/style/css/index.js +2 -0
  184. package/esm/swipe-action/style/index.d.ts +2 -0
  185. package/esm/swipe-action/style/index.js +2 -0
  186. package/esm/swipe-action/style/index.less +89 -0
  187. package/esm/swipe-action/type.d.ts +123 -0
  188. package/esm/swipe-action/type.js +1 -0
  189. package/esm/switch/index.d.ts +1 -1
  190. package/esm/switch/index.js +1 -1
  191. package/esm/tabs/tab-pane.js +5 -1
  192. package/esm/tag/index.d.ts +1 -1
  193. package/esm/tag/index.js +1 -1
  194. package/esm/textarea/index.d.ts +1 -1
  195. package/esm/textarea/index.js +1 -1
  196. package/package.json +3 -3
  197. package/tokens/app/arcodesign/default/css-variables.less +34 -0
  198. package/tokens/app/arcodesign/default/index.d.ts +34 -0
  199. package/tokens/app/arcodesign/default/index.js +34 -0
  200. package/tokens/app/arcodesign/default/index.json +398 -0
  201. package/tokens/app/arcodesign/default/index.less +34 -0
  202. package/umd/avatar/index.d.ts +1 -1
  203. package/umd/avatar/index.js +1 -1
  204. package/umd/badge/index.d.ts +1 -1
  205. package/umd/badge/index.js +1 -1
  206. package/umd/carousel/index.d.ts +1 -1
  207. package/umd/carousel/index.js +1 -1
  208. package/umd/cell/index.d.ts +1 -1
  209. package/umd/cell/index.js +1 -1
  210. package/umd/checkbox/index.d.ts +1 -1
  211. package/umd/checkbox/index.js +1 -1
  212. package/umd/collapse/index.d.ts +1 -1
  213. package/umd/collapse/index.js +1 -1
  214. package/umd/count-down/index.d.ts +1 -1
  215. package/umd/count-down/index.js +1 -1
  216. package/umd/date-picker/index.d.ts +1 -1
  217. package/umd/date-picker/index.js +1 -1
  218. package/umd/dropdown/dropdown.js +36 -20
  219. package/umd/dropdown/style/css/index.css +3 -0
  220. package/umd/dropdown/style/index.less +2 -0
  221. package/umd/ellipsis/index.d.ts +1 -1
  222. package/umd/ellipsis/index.js +1 -1
  223. package/umd/image/index.d.ts +1 -1
  224. package/umd/image/index.js +1 -1
  225. package/umd/image-picker/index.d.ts +4 -175
  226. package/umd/image-picker/index.js +40 -22
  227. package/umd/image-picker/type.d.ts +174 -0
  228. package/umd/image-picker/type.js +17 -0
  229. package/umd/image-preview/index.d.ts +1 -1
  230. package/umd/image-preview/index.js +1 -1
  231. package/umd/index.d.ts +2 -0
  232. package/umd/index.js +9 -5
  233. package/umd/input/hooks.js +48 -7
  234. package/umd/input/index.d.ts +1 -1
  235. package/umd/input/index.js +1 -1
  236. package/umd/input/props.d.ts +8 -2
  237. package/umd/notice-bar/index.d.ts +1 -1
  238. package/umd/notice-bar/index.js +1 -1
  239. package/umd/picker/index.d.ts +1 -1
  240. package/umd/picker/index.js +1 -1
  241. package/umd/picker-view/index.d.ts +1 -1
  242. package/umd/picker-view/index.js +1 -1
  243. package/umd/popover/index.d.ts +1 -1
  244. package/umd/popover/index.js +1 -1
  245. package/umd/popup-swiper/index.js +3 -2
  246. package/umd/radio/index.d.ts +1 -1
  247. package/umd/radio/index.js +1 -1
  248. package/umd/rate/index.d.ts +1 -1
  249. package/umd/rate/index.js +1 -1
  250. package/umd/search-bar/association.d.ts +3 -0
  251. package/umd/search-bar/association.js +101 -0
  252. package/umd/search-bar/cancel-button.d.ts +10 -0
  253. package/umd/search-bar/cancel-button.js +52 -0
  254. package/umd/search-bar/demo/style/css/mobile.css +5 -0
  255. package/umd/search-bar/demo/style/mobile.less +9 -0
  256. package/umd/search-bar/highlight.d.ts +12 -0
  257. package/umd/search-bar/highlight.js +87 -0
  258. package/umd/search-bar/index.d.ts +13 -0
  259. package/umd/search-bar/index.js +235 -0
  260. package/umd/search-bar/style/css/index.css +148 -0
  261. package/umd/search-bar/style/css/index.d.ts +2 -0
  262. package/umd/search-bar/style/css/index.js +15 -0
  263. package/umd/search-bar/style/index.d.ts +2 -0
  264. package/umd/search-bar/style/index.js +15 -0
  265. package/umd/search-bar/style/index.less +111 -0
  266. package/umd/search-bar/type.d.ts +163 -0
  267. package/umd/search-bar/type.js +17 -0
  268. package/umd/slider/index.d.ts +1 -1
  269. package/umd/slider/index.js +1 -1
  270. package/umd/steps/index.d.ts +1 -1
  271. package/umd/steps/index.js +1 -1
  272. package/umd/sticky/index.d.ts +1 -1
  273. package/umd/style.d.ts +2 -0
  274. package/umd/style.js +4 -4
  275. package/umd/swipe-action/demo/style/css/mobile.css +5 -0
  276. package/umd/swipe-action/demo/style/mobile.less +9 -0
  277. package/umd/swipe-action/index.d.ts +12 -0
  278. package/umd/swipe-action/index.js +342 -0
  279. package/umd/swipe-action/item.d.ts +11 -0
  280. package/umd/swipe-action/item.js +62 -0
  281. package/umd/swipe-action/style/css/index.css +88 -0
  282. package/umd/swipe-action/style/css/index.d.ts +2 -0
  283. package/umd/swipe-action/style/css/index.js +15 -0
  284. package/umd/swipe-action/style/index.d.ts +2 -0
  285. package/umd/swipe-action/style/index.js +15 -0
  286. package/umd/swipe-action/style/index.less +89 -0
  287. package/umd/swipe-action/type.d.ts +123 -0
  288. package/umd/swipe-action/type.js +17 -0
  289. package/umd/switch/index.d.ts +1 -1
  290. package/umd/switch/index.js +1 -1
  291. package/umd/tabs/tab-pane.js +5 -1
  292. package/umd/tag/index.d.ts +1 -1
  293. package/umd/tag/index.js +1 -1
  294. package/umd/textarea/index.d.ts +1 -1
  295. package/umd/textarea/index.js +1 -1
@@ -0,0 +1,339 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ exports.__esModule = true;
6
+ exports.default = void 0;
7
+
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+
10
+ var _react = _interopRequireWildcard(require("react"));
11
+
12
+ var _utils = require("@arco-design/mobile-utils/utils");
13
+
14
+ var _mobileUtils = require("@arco-design/mobile-utils");
15
+
16
+ var _contextProvider = require("../context-provider");
17
+
18
+ var _item = _interopRequireDefault(require("./item"));
19
+
20
+ var _helpers = require("../_helpers");
21
+
22
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
+
24
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
+
26
+ /**
27
+ * 滑动操作组件,左右滑动拉出菜单栏
28
+ * @en SwipeAction component, slide left and right to pull out the menu bar
29
+ * @type 反馈
30
+ * @type_en FeedBack
31
+ * @name 滑动操作
32
+ * @name_en SwipeAction
33
+ */
34
+ var SwipeAction = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
35
+ var _props$className = props.className,
36
+ className = _props$className === void 0 ? '' : _props$className,
37
+ style = props.style,
38
+ children = props.children,
39
+ leftActions = props.leftActions,
40
+ rightActions = props.rightActions,
41
+ _props$disabled = props.disabled,
42
+ disabled = _props$disabled === void 0 ? false : _props$disabled,
43
+ _props$threshold = props.threshold,
44
+ threshold = _props$threshold === void 0 ? 0.15 : _props$threshold,
45
+ closeOnTouchOutside = props.closeOnTouchOutside,
46
+ _props$transitionDura = props.transitionDuration,
47
+ transitionDuration = _props$transitionDura === void 0 ? 300 : _props$transitionDura,
48
+ _props$dampRate = props.dampRate,
49
+ dampRate = _props$dampRate === void 0 ? 15 : _props$dampRate,
50
+ _props$openStyleType = props.openStyleType,
51
+ openStyleType = _props$openStyleType === void 0 ? 'layer' : _props$openStyleType,
52
+ onClose = props.onClose,
53
+ onOpen = props.onOpen;
54
+ var domRef = (0, _react.useRef)(null);
55
+ var leftRef = (0, _react.useRef)(null);
56
+ var rightRef = (0, _react.useRef)(null);
57
+ var isOpen = (0, _react.useRef)(false);
58
+ var leftMenuWidthRef = (0, _react.useRef)(0);
59
+
60
+ var _useState = (0, _react.useState)([]),
61
+ leftMenuWidthArr = _useState[0],
62
+ setLeftMenuWidthArr = _useState[1];
63
+
64
+ var rightMenuWidthRef = (0, _react.useRef)(0);
65
+
66
+ var _useState2 = (0, _react.useState)([]),
67
+ rightMenuWidthArr = _useState2[0],
68
+ setRightMenuWidthArr = _useState2[1];
69
+
70
+ var dampRateRef = (0, _helpers.useLatestRef)(dampRate);
71
+ var forbidClick = (0, _react.useRef)(false);
72
+
73
+ var _useRefState = (0, _helpers.useRefState)(false),
74
+ moving = _useRefState[0],
75
+ movingRef = _useRefState[1],
76
+ setMoving = _useRefState[2];
77
+
78
+ var _useRefState2 = (0, _helpers.useRefState)(0),
79
+ offset = _useRefState2[0],
80
+ offsetRef = _useRefState2[1],
81
+ setOffset = _useRefState2[2];
82
+
83
+ var _useContext = (0, _react.useContext)(_contextProvider.GlobalContext),
84
+ prefixCls = _useContext.prefixCls;
85
+
86
+ var startRef = (0, _react.useRef)(0);
87
+ var startX = (0, _react.useRef)(0);
88
+ var slideX = (0, _react.useRef)(0);
89
+ var isLayer = openStyleType === 'layer';
90
+ var transitionStyle = (0, _react.useMemo)(function () {
91
+ return (0, _helpers.getStyleWithVendor)({
92
+ transitionDuration: moving ? '0ms' : transitionDuration + "ms"
93
+ });
94
+ }, [moving, transitionDuration]);
95
+
96
+ function resetMoveData() {
97
+ startX.current = 0;
98
+ slideX.current = 0;
99
+ }
100
+
101
+ function getMenuCurrentWidth(a, min, max) {
102
+ var buffer = Math.abs(a) / dampRateRef.current;
103
+ return Math.min(Math.max(a, min - buffer), max + buffer);
104
+ }
105
+
106
+ function touchstart(e) {
107
+ startRef.current = offsetRef.current;
108
+ resetMoveData();
109
+ startX.current = e.touches[0].pageX;
110
+ }
111
+
112
+ function touchmove(e) {
113
+ e.preventDefault();
114
+ slideX.current = e.touches[0].pageX - startX.current;
115
+ forbidClick.current = true;
116
+ setMoving(true);
117
+ setOffset(getMenuCurrentWidth(slideX.current + startRef.current, -rightMenuWidthRef.current, leftMenuWidthRef.current));
118
+ }
119
+
120
+ function touchend() {
121
+ if (movingRef.current) {
122
+ var currentMenu = offsetRef.current > 0 ? 'left' : 'right';
123
+ changeMenu(currentMenu);
124
+ setMoving(false);
125
+ (0, _utils.nextTick)(function () {
126
+ forbidClick.current = false;
127
+ });
128
+ }
129
+ }
130
+
131
+ function changeMenu(dir) {
132
+ var cookedThreshold = isOpen.current ? 1 - threshold : threshold;
133
+ var width = dir === 'left' ? leftMenuWidthRef.current : rightMenuWidthRef.current;
134
+
135
+ if (width && Math.abs(offsetRef.current) > width * cookedThreshold) {
136
+ open(dir);
137
+ } else {
138
+ close(dir);
139
+ }
140
+ }
141
+
142
+ function getWidthByRef(widthRef) {
143
+ if (!widthRef.current) {
144
+ return {
145
+ totalWidth: 0,
146
+ widthArr: []
147
+ };
148
+ }
149
+
150
+ var totalWidth = 0;
151
+ var widthArr = [];
152
+ var allEle = widthRef.current.getElementsByClassName(prefixCls + "-swipe-action-menu-action-info-container");
153
+ Array.prototype.forEach.call(allEle, function (ele) {
154
+ var _ele$getBoundingClien;
155
+
156
+ var w = (_ele$getBoundingClien = ele.getBoundingClientRect().width) != null ? _ele$getBoundingClien : 0;
157
+ totalWidth += w;
158
+ widthArr.push(w);
159
+ });
160
+ return {
161
+ totalWidth: totalWidth,
162
+ widthArr: widthArr
163
+ };
164
+ }
165
+
166
+ (0, _react.useEffect)(function () {
167
+ var container = domRef.current;
168
+
169
+ if (!disabled && container) {
170
+ container.addEventListener('touchstart', touchstart);
171
+ container.addEventListener('touchmove', touchmove);
172
+ container.addEventListener('touchend', touchend);
173
+ }
174
+
175
+ return function () {
176
+ if (!disabled && container) {
177
+ container.removeEventListener('touchstart', touchstart);
178
+ container.removeEventListener('touchmove', touchmove);
179
+ container.removeEventListener('touchend', touchend);
180
+ }
181
+ };
182
+ }, [disabled]); // 获取左右菜单的宽度
183
+ // @en Get the width of the left and right menu
184
+
185
+ (0, _react.useEffect)(function () {
186
+ var _getWidthByRef = getWidthByRef(leftRef),
187
+ leftTotalWidth = _getWidthByRef.totalWidth,
188
+ leftWidthArr = _getWidthByRef.widthArr;
189
+
190
+ leftMenuWidthRef.current = leftTotalWidth;
191
+ setLeftMenuWidthArr(leftWidthArr);
192
+
193
+ var _getWidthByRef2 = getWidthByRef(rightRef),
194
+ rightTotalWidth = _getWidthByRef2.totalWidth,
195
+ rightWidthArr = _getWidthByRef2.widthArr;
196
+
197
+ rightMenuWidthRef.current = rightTotalWidth;
198
+ setRightMenuWidthArr(rightWidthArr);
199
+ }, [leftActions, rightActions]); // 点击外部区域事件
200
+ // @en Event when clicking outside of the element
201
+
202
+ (0, _react.useEffect)(function () {
203
+ var handle = function handle(e) {
204
+ var _domRef$current;
205
+
206
+ if (!((_domRef$current = domRef.current) != null && _domRef$current.contains(e.target)) && isOpen.current) {
207
+ close();
208
+ }
209
+ };
210
+
211
+ closeOnTouchOutside && document.addEventListener('touchstart', handle);
212
+ return function () {
213
+ closeOnTouchOutside && document.removeEventListener('touchstart', handle);
214
+ };
215
+ }, [closeOnTouchOutside]);
216
+ (0, _react.useImperativeHandle)(ref, function () {
217
+ return {
218
+ dom: domRef.current,
219
+ close: close,
220
+ open: open
221
+ };
222
+ });
223
+
224
+ function close(dir) {
225
+ setOffset(0);
226
+
227
+ if (isOpen.current) {
228
+ isOpen.current = false;
229
+
230
+ if (!dir && offsetRef.current !== 0) {
231
+ var noDir = offsetRef.current > 0 ? 'left' : 'right';
232
+ handleClose(noDir);
233
+ return;
234
+ }
235
+
236
+ handleClose(dir);
237
+ }
238
+ }
239
+
240
+ function open(dir) {
241
+ if (dir === void 0) {
242
+ dir = 'right';
243
+ }
244
+
245
+ if (!isOpen.current) {
246
+ isOpen.current = true;
247
+ handleOpen(dir);
248
+ }
249
+
250
+ setOffset(dir === 'left' ? leftMenuWidthRef.current : -rightMenuWidthRef.current);
251
+ }
252
+
253
+ function handleOpen(dir) {
254
+ setTimeout(function () {
255
+ onOpen == null ? void 0 : onOpen(dir);
256
+ }, transitionDuration);
257
+ }
258
+
259
+ function handleClose(dir) {
260
+ setTimeout(function () {
261
+ onClose == null ? void 0 : onClose(dir);
262
+ }, transitionDuration);
263
+ }
264
+
265
+ function actionClick(e) {
266
+ var _leftRef$current, _rightRef$current;
267
+
268
+ if (isOpen.current && !forbidClick.current && !((_leftRef$current = leftRef.current) != null && _leftRef$current.contains(e.target)) && !((_rightRef$current = rightRef.current) != null && _rightRef$current.contains(e.target))) {
269
+ close();
270
+ }
271
+ }
272
+
273
+ function getActionRightByIndex(index) {
274
+ var preWidth = leftMenuWidthArr.slice(index + 1).reduce(function (acc, cur) {
275
+ return acc + cur;
276
+ }, 0);
277
+ return (preWidth / leftMenuWidthRef.current || 0) * 100 + "%";
278
+ }
279
+
280
+ function getActionLeftByIndex(index) {
281
+ var preWidth = rightMenuWidthArr.slice(0, index).reduce(function (acc, cur) {
282
+ return acc + cur;
283
+ }, 0);
284
+ return (preWidth / rightMenuWidthRef.current || 0) * 100 + "%";
285
+ }
286
+
287
+ return /*#__PURE__*/_react.default.createElement("div", {
288
+ className: (0, _mobileUtils.cls)(prefixCls + "-swipe-action", className, offset === 0 ? 'action-close' : 'action-open'),
289
+ style: (0, _helpers.getStyleWithVendor)((0, _extends2.default)({}, style || {}, transitionStyle, {
290
+ transform: "translateX(" + offset + "px)"
291
+ })),
292
+ ref: domRef,
293
+ onClick: actionClick
294
+ }, /*#__PURE__*/_react.default.createElement("div", {
295
+ className: (0, _mobileUtils.cls)(prefixCls + "-swipe-action-menu-left", prefixCls + "-swipe-action-menu", offset > 0 ? 'action-open' : 'action-close'),
296
+ ref: leftRef,
297
+ style: isLayer && offset >= 0 ? (0, _extends2.default)({
298
+ width: offset
299
+ }, transitionStyle) : {}
300
+ }, leftActions == null ? void 0 : leftActions.map(function (action, index) {
301
+ return /*#__PURE__*/_react.default.createElement(_item.default, {
302
+ action: (0, _extends2.default)({}, action || {}, {
303
+ style: (0, _extends2.default)({}, isLayer ? {
304
+ right: getActionRightByIndex(index)
305
+ } : {}, action.style || {}),
306
+ className: (0, _mobileUtils.cls)(action.className, "open-style-" + openStyleType)
307
+ }),
308
+ prefixCls: prefixCls + "-swipe-action-menu-action",
309
+ index: leftActions.length - index,
310
+ type: "left",
311
+ close: close,
312
+ key: index
313
+ });
314
+ })), /*#__PURE__*/_react.default.createElement("div", {
315
+ className: prefixCls + "-swipe-action-content"
316
+ }, children), /*#__PURE__*/_react.default.createElement("div", {
317
+ className: (0, _mobileUtils.cls)(prefixCls + "-swipe-action-menu-right", prefixCls + "-swipe-action-menu", offset < 0 ? 'action-open' : 'action-close'),
318
+ ref: rightRef,
319
+ style: isLayer && offset <= 0 ? (0, _extends2.default)({
320
+ width: -1 * offset
321
+ }, transitionStyle) : {}
322
+ }, rightActions == null ? void 0 : rightActions.map(function (action, index) {
323
+ return /*#__PURE__*/_react.default.createElement(_item.default, {
324
+ action: (0, _extends2.default)({}, action || {}, {
325
+ style: (0, _extends2.default)({}, isLayer ? {
326
+ left: getActionLeftByIndex(index)
327
+ } : {}, action.style || {}),
328
+ className: (0, _mobileUtils.cls)(action.className, "open-style-" + openStyleType)
329
+ }),
330
+ prefixCls: prefixCls + "-swipe-action-menu-action",
331
+ index: index + 1,
332
+ type: "right",
333
+ close: close,
334
+ key: index
335
+ });
336
+ })));
337
+ });
338
+ var _default = SwipeAction;
339
+ exports.default = _default;
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import { Action } from './type';
3
+ interface IProps {
4
+ action: Action;
5
+ prefixCls: string;
6
+ index: number;
7
+ type: 'left' | 'right';
8
+ close: () => void;
9
+ }
10
+ export default function renderAction({ action, prefixCls, index, type, close }: IProps): JSX.Element;
11
+ export {};
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ exports.__esModule = true;
6
+ exports.default = renderAction;
7
+
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+
10
+ var _react = _interopRequireDefault(require("react"));
11
+
12
+ var _mobileUtils = require("@arco-design/mobile-utils");
13
+
14
+ function renderAction(_ref) {
15
+ var action = _ref.action,
16
+ prefixCls = _ref.prefixCls,
17
+ index = _ref.index,
18
+ type = _ref.type,
19
+ close = _ref.close;
20
+ var text = action.text,
21
+ actionStyle = action.style,
22
+ className = action.className,
23
+ onClick = action.onClick,
24
+ icon = action.icon,
25
+ children = action.children;
26
+
27
+ function click() {
28
+ var result = (onClick == null ? void 0 : onClick()) || null;
29
+
30
+ if (!result || typeof result === 'boolean') {
31
+ !result && close();
32
+ } else if (result && result.then) {
33
+ result.then(function (res) {
34
+ return !res && close();
35
+ });
36
+ }
37
+ }
38
+
39
+ return /*#__PURE__*/_react.default.createElement("div", {
40
+ className: (0, _mobileUtils.cls)(prefixCls + "-" + type + " " + prefixCls + "-info-container", className),
41
+ style: (0, _extends2.default)({
42
+ zIndex: index
43
+ }, actionStyle),
44
+ onClick: click
45
+ }, children || /*#__PURE__*/_react.default.createElement("div", {
46
+ className: prefixCls + "-info"
47
+ }, icon ? /*#__PURE__*/_react.default.createElement("div", {
48
+ className: prefixCls + "-info-icon"
49
+ }, icon) : null, text ? /*#__PURE__*/_react.default.createElement("div", {
50
+ className: prefixCls + "-info-text"
51
+ }, text) : null));
52
+ }
@@ -0,0 +1,88 @@
1
+ .arco-swipe-action {
2
+ position: relative;
3
+ -webkit-transition: -webkit-transform 0s;
4
+ transition: -webkit-transform 0s;
5
+ transition: transform 0s;
6
+ transition: transform 0s, -webkit-transform 0s;
7
+ font-size: 0.32rem ;
8
+ }
9
+ .arco-swipe-action.action-open,
10
+ .arco-swipe-action-menu.action-open {
11
+ -webkit-transition-timing-function: cubic-bezier(0.2, 0.8, 0.32, 1.28) ;
12
+ transition-timing-function: cubic-bezier(0.2, 0.8, 0.32, 1.28) ;
13
+ }
14
+ .arco-swipe-action.action-close,
15
+ .arco-swipe-action-menu.action-close {
16
+ -webkit-transition-timing-function: cubic-bezier(0.34, 0.69, 0.1, 1) ;
17
+ transition-timing-function: cubic-bezier(0.34, 0.69, 0.1, 1) ;
18
+ }
19
+ .arco-swipe-action-content {
20
+ width: 100%;
21
+ }
22
+ .arco-swipe-action-menu {
23
+ display: -webkit-box;
24
+ display: -webkit-flex;
25
+ display: flex;
26
+ position: absolute;
27
+ height: 100%;
28
+ overflow: visible;
29
+ -webkit-flex-wrap: nowrap;
30
+ flex-wrap: nowrap;
31
+ top: 0;
32
+ -webkit-transition: width 0s;
33
+ transition: width 0s;
34
+ }
35
+ .arco-swipe-action-menu-left {
36
+ right: 100%;
37
+ }
38
+ .arco-swipe-action-menu-right {
39
+ left: 100%;
40
+ }
41
+ .arco-swipe-action-menu-action-left::after {
42
+ right: 100%;
43
+ margin-right: -1PX;
44
+ }
45
+ .arco-swipe-action-menu-action-right::after {
46
+ left: 100%;
47
+ margin-left: -1PX;
48
+ }
49
+ .arco-swipe-action-menu-action-info {
50
+ height: 100%;
51
+ padding: 0.32rem ;
52
+ display: -webkit-box;
53
+ display: -webkit-flex;
54
+ display: flex;
55
+ -webkit-box-pack: center;
56
+ -webkit-justify-content: center;
57
+ justify-content: center;
58
+ -webkit-box-align: center;
59
+ -webkit-align-items: center;
60
+ align-items: center;
61
+ }
62
+ .arco-swipe-action-menu-action-info-container {
63
+ position: relative;
64
+ }
65
+ .arco-swipe-action-menu-action-info-container.open-style-layer {
66
+ position: absolute;
67
+ height: 100%;
68
+ }
69
+ .arco-swipe-action-menu-action-info-container::after {
70
+ content: " ";
71
+ position: absolute;
72
+ top: 0;
73
+ height: 100%;
74
+ width: 0.6rem ;
75
+ background: inherit;
76
+ }
77
+ .arco-swipe-action-menu-action-info-text {
78
+ white-space: nowrap;
79
+ font-size: 0.32rem ;
80
+ line-height: 0.44rem ;
81
+ color: #ffffff ;
82
+ }
83
+ .arco-swipe-action-menu-action-info-icon {
84
+ margin-right: 0.08rem ;
85
+ height: 0.4rem ;
86
+ width: 0.4rem ;
87
+ color: #ffffff ;
88
+ }
@@ -0,0 +1,2 @@
1
+ import '../../../../style/css/public.css';
2
+ import './index.css';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ require("../../../../style/css/public.css");
4
+
5
+ require("./index.css");
@@ -0,0 +1,2 @@
1
+ import '../../../style/public.less';
2
+ import './index.less';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ require("../../../style/public.less");
4
+
5
+ require("./index.less");
@@ -0,0 +1,89 @@
1
+ @import '../../../style/mixin.less';
2
+
3
+ .@{prefix}-swipe-action {
4
+ position: relative;
5
+ transition: transform 0s;
6
+ .use-var(font-size,swipe-action-text-font-size);
7
+
8
+ &, &-menu {
9
+ &.action-open {
10
+ .use-var(transition-timing-function, swipe-action-open-transition);
11
+ }
12
+ &.action-close {
13
+ .use-var(transition-timing-function, swipe-action-close-transition);
14
+ }
15
+ }
16
+
17
+ &-content {
18
+ width: 100%;
19
+ }
20
+
21
+ &-menu {
22
+ display: flex;
23
+ position: absolute;
24
+ height: 100%;
25
+ overflow: visible;
26
+ flex-wrap: nowrap;
27
+ top: 0;
28
+ transition: width 0s;
29
+
30
+ &-left {
31
+ right: 100%;
32
+ }
33
+
34
+ &-right {
35
+ left: 100%;
36
+ }
37
+ &-action {
38
+ &-left {
39
+ &::after {
40
+ right: 100%;
41
+ margin-right: -1PX;
42
+ }
43
+ }
44
+ &-right {
45
+ &::after {
46
+ left: 100%;
47
+ margin-left: -1PX;
48
+ }
49
+ }
50
+ &-info {
51
+ height: 100%;
52
+ .use-var(padding, swipe-action-info-padding);
53
+ display: flex;
54
+ justify-content: center;
55
+ align-items: center;
56
+
57
+ &-container {
58
+ position: relative;
59
+ &.open-style-layer {
60
+ position: absolute;
61
+ height: 100%;
62
+ }
63
+ &::after {
64
+ content: " ";
65
+ position: absolute;
66
+ top: 0;
67
+ height: 100%;
68
+ .use-var(width, swipe-action-info-bounce-buffer);
69
+ background: inherit;
70
+ }
71
+ }
72
+
73
+ &-text {
74
+ white-space: nowrap;
75
+ .use-var(font-size,swipe-action-text-font-size);
76
+ .use-var(line-height,swipe-action-text-line-height);
77
+ .use-var(color, swipe-action-text-color);
78
+ }
79
+
80
+ &-icon {
81
+ .use-var(margin-right,swipe-action-icon-margin-right);
82
+ .use-var(height, swipe-action-icon-height);
83
+ .use-var(width, swipe-action-icon-width);
84
+ .use-var(color, swipe-action-text-color);
85
+ }
86
+ }
87
+ }
88
+ }
89
+ }