@nutui/nutui-react-taro 1.4.2 → 1.4.3

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 (82) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/esm/ActionSheet.js +4 -4
  3. package/dist/esm/Address.js +4 -4
  4. package/dist/esm/Audio.js +4 -4
  5. package/dist/esm/Badge.js +2 -2
  6. package/dist/esm/Barrage.js +2 -2
  7. package/dist/esm/Calendar.js +5 -5
  8. package/dist/esm/CalendarItem.js +2 -2
  9. package/dist/esm/Cascader.js +4 -4
  10. package/dist/esm/CircleProgress.js +2 -2
  11. package/dist/esm/DatePicker.js +5 -5
  12. package/dist/esm/Dialog.js +2 -2
  13. package/dist/esm/Drag.js +2 -2
  14. package/dist/esm/FixedNav.js +3 -3
  15. package/dist/esm/ImagePreview.js +4 -4
  16. package/dist/esm/InputNumber.js +2 -2
  17. package/dist/esm/MenuItem.js +3 -3
  18. package/dist/esm/NoticeBar.js +2 -2
  19. package/dist/esm/Notify.js +2 -2
  20. package/dist/esm/NumberKeyboard.js +4 -4
  21. package/dist/esm/Overlay.js +2 -2
  22. package/dist/esm/Picker.js +4 -4
  23. package/dist/esm/Popover.js +3 -3
  24. package/dist/esm/Popup.js +3 -3
  25. package/dist/esm/Range.js +3 -3
  26. package/dist/esm/ShortPassword.js +4 -4
  27. package/dist/esm/SideNavBar.js +4 -4
  28. package/dist/esm/Signature.js +2 -2
  29. package/dist/esm/TimeSelect.js +4 -4
  30. package/dist/esm/Toast.js +2 -2
  31. package/dist/esm/WaterMark.js +2 -2
  32. package/dist/esm/{actionsheet.taro-360d8d34.js → actionsheet.taro-a58d3d12.js} +1 -1
  33. package/dist/esm/{address.taro-c03b8b16.js → address.taro-1e2aea24.js} +22 -24
  34. package/dist/esm/{audio.taro-20890c93.js → audio.taro-fddcdfc0.js} +1 -1
  35. package/dist/esm/{badge.taro-9f72d846.js → badge.taro-fe9171ec.js} +1 -1
  36. package/dist/esm/{barrage.taro-d86c367a.js → barrage.taro-0e157b5e.js} +25 -23
  37. package/dist/esm/{calendar.taro-93b14945.js → calendar.taro-72974415.js} +2 -2
  38. package/dist/esm/{calendaritem.taro-85a8c4fc.js → calendaritem.taro-84e889eb.js} +19 -17
  39. package/dist/esm/{cascader.taro-459f7d45.js → cascader.taro-d8cb1c3e.js} +245 -235
  40. package/dist/esm/{circleprogress.taro-3c89a157.js → circleprogress.taro-47db537c.js} +2 -13
  41. package/dist/esm/{datepicker.taro-7de67b85.js → datepicker.taro-7199f521.js} +1 -1
  42. package/dist/esm/{dialog.taro-cf9e3087.js → dialog.taro-f54cfbf0.js} +1 -1
  43. package/dist/esm/{drag.taro-0717c783.js → drag.taro-82b6b27a.js} +4 -8
  44. package/dist/esm/ellipsis.taro-c0de6ff4.js +84 -76
  45. package/dist/esm/{fixednav.taro-005765f4.js → fixednav.taro-9e759320.js} +1 -1
  46. package/dist/esm/{imagepreview.taro-68e776f5.js → imagepreview.taro-3400ea03.js} +1 -1
  47. package/dist/esm/{inputnumber.taro-0a01f6e1.js → inputnumber.taro-dc39b853.js} +1 -0
  48. package/dist/esm/{menuitem.taro-2f8e69a4.js → menuitem.taro-216e9f7d.js} +17 -15
  49. package/dist/esm/{noticebar.taro-43c18dc9.js → noticebar.taro-94002898.js} +35 -33
  50. package/dist/esm/{notify.taro-d9c48fae.js → notify.taro-308e5892.js} +1 -1
  51. package/dist/esm/{numberkeyboard.taro-9635ecc9.js → numberkeyboard.taro-5e8f0ddf.js} +1 -1
  52. package/dist/esm/nutui-react.es.js +30 -30
  53. package/dist/esm/{overlay.taro-be45fed5.js → overlay.taro-98367bc1.js} +1 -1
  54. package/dist/esm/{picker.taro-9b7263ca.js → picker.taro-3b5cc054.js} +14 -12
  55. package/dist/esm/{popover.taro-7e5dff8c.js → popover.taro-46d813e8.js} +18 -16
  56. package/dist/esm/{popup.taro-33d0bbc8.js → popup.taro-cb777e09.js} +1 -1
  57. package/dist/esm/pulltorefresh.taro-f26a20dd.js +81 -75
  58. package/dist/esm/{range.taro-4cbe2469.js → range.taro-c41e9b90.js} +72 -68
  59. package/dist/esm/{shortpassword.taro-4bd513ae.js → shortpassword.taro-3a3bf412.js} +1 -1
  60. package/dist/esm/{sidenavbar.taro-3b1f1218.js → sidenavbar.taro-06026f31.js} +1 -1
  61. package/dist/esm/{signature.taro-504357dc.js → signature.taro-17648cac.js} +79 -39
  62. package/dist/esm/swipe.taro-83bc248f.js +37 -35
  63. package/dist/esm/swiper.taro-852f6615.js +28 -26
  64. package/dist/esm/{timeselect.taro-000060af.js → timeselect.taro-fc7ec6ee.js} +1 -1
  65. package/dist/esm/{toast.taro-86862dff.js → toast.taro-0804b6b4.js} +1 -1
  66. package/dist/esm/useClientRect-bf69d7b3.js +12 -10
  67. package/dist/esm/{watermark.taro-d1f38563.js → watermark.taro-323d1cf3.js} +53 -41
  68. package/dist/locales/base.js +1 -1
  69. package/dist/locales/en-US.js +1 -1
  70. package/dist/locales/id-ID.js +1 -1
  71. package/dist/locales/zh-CN.js +1 -1
  72. package/dist/locales/zh-TW.js +1 -1
  73. package/dist/locales/zh-UG.js +1 -1
  74. package/dist/nutui.react.es.js +160 -111
  75. package/dist/nutui.react.umd.js +159 -110
  76. package/dist/packages/drag/drag.scss +1 -0
  77. package/dist/packages/inputnumber/inputnumber.scss +4 -1
  78. package/dist/packages/signature/signature.scss +10 -3
  79. package/dist/style.css +1 -1
  80. package/dist/style.es.js +1 -1
  81. package/dist/styles/variables.scss +1 -1
  82. package/package.json +1 -1
@@ -122,82 +122,88 @@ var PullToRefresh = function PullToRefresh(p) {
122
122
  function _doRefresh() {
123
123
  _doRefresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
124
124
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
125
- while (1) switch (_context3.prev = _context3.next) {
126
- case 0:
127
- api.start({
128
- height: headHeight
129
- });
130
- setStatus('refreshing');
131
- _context3.prev = 2;
132
- _context3.next = 5;
133
- return props.onRefresh();
134
- case 5:
135
- setStatus('complete');
136
- _context3.next = 12;
137
- break;
138
- case 8:
139
- _context3.prev = 8;
140
- _context3.t0 = _context3["catch"](2);
141
- api.start({
142
- to: function () {
143
- var _to = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(next) {
144
- return _regeneratorRuntime.wrap(function _callee$(_context) {
145
- while (1) switch (_context.prev = _context.next) {
146
- case 0:
147
- _context.next = 2;
148
- return next({
149
- height: 0
150
- });
151
- case 2:
152
- setStatus('pulling');
153
- case 3:
154
- case "end":
155
- return _context.stop();
156
- }
157
- }, _callee);
158
- }));
159
- function to(_x) {
160
- return _to.apply(this, arguments);
161
- }
162
- return to;
163
- }()
164
- });
165
- throw _context3.t0;
166
- case 12:
167
- if (!(props.completeDelay > 0)) {
168
- _context3.next = 15;
125
+ while (1) {
126
+ switch (_context3.prev = _context3.next) {
127
+ case 0:
128
+ api.start({
129
+ height: headHeight
130
+ });
131
+ setStatus('refreshing');
132
+ _context3.prev = 2;
133
+ _context3.next = 5;
134
+ return props.onRefresh();
135
+ case 5:
136
+ setStatus('complete');
137
+ _context3.next = 12;
169
138
  break;
170
- }
171
- _context3.next = 15;
172
- return sleep(props.completeDelay);
173
- case 15:
174
- api.start({
175
- to: function () {
176
- var _to2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(next) {
177
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
178
- while (1) switch (_context2.prev = _context2.next) {
179
- case 0:
180
- _context2.next = 2;
181
- return next({
182
- height: 0
183
- });
184
- case 2:
185
- setStatus('pulling');
186
- case 3:
187
- case "end":
188
- return _context2.stop();
189
- }
190
- }, _callee2);
191
- }));
192
- function to(_x2) {
193
- return _to2.apply(this, arguments);
194
- }
195
- return to;
196
- }()
197
- });
198
- case 16:
199
- case "end":
200
- return _context3.stop();
139
+ case 8:
140
+ _context3.prev = 8;
141
+ _context3.t0 = _context3["catch"](2);
142
+ api.start({
143
+ to: function () {
144
+ var _to = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(next) {
145
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
146
+ while (1) {
147
+ switch (_context.prev = _context.next) {
148
+ case 0:
149
+ _context.next = 2;
150
+ return next({
151
+ height: 0
152
+ });
153
+ case 2:
154
+ setStatus('pulling');
155
+ case 3:
156
+ case "end":
157
+ return _context.stop();
158
+ }
159
+ }
160
+ }, _callee);
161
+ }));
162
+ function to(_x) {
163
+ return _to.apply(this, arguments);
164
+ }
165
+ return to;
166
+ }()
167
+ });
168
+ throw _context3.t0;
169
+ case 12:
170
+ if (!(props.completeDelay > 0)) {
171
+ _context3.next = 15;
172
+ break;
173
+ }
174
+ _context3.next = 15;
175
+ return sleep(props.completeDelay);
176
+ case 15:
177
+ api.start({
178
+ to: function () {
179
+ var _to2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(next) {
180
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
181
+ while (1) {
182
+ switch (_context2.prev = _context2.next) {
183
+ case 0:
184
+ _context2.next = 2;
185
+ return next({
186
+ height: 0
187
+ });
188
+ case 2:
189
+ setStatus('pulling');
190
+ case 3:
191
+ case "end":
192
+ return _context2.stop();
193
+ }
194
+ }
195
+ }, _callee2);
196
+ }));
197
+ function to(_x2) {
198
+ return _to2.apply(this, arguments);
199
+ }
200
+ return to;
201
+ }()
202
+ });
203
+ case 16:
204
+ case "end":
205
+ return _context3.stop();
206
+ }
201
207
  }
202
208
  }, _callee3, null, [[2, 8]]);
203
209
  }));
@@ -7,7 +7,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
7
7
  import React__default, { useState, useRef, useEffect, useCallback } from 'react';
8
8
  import { u as useTouch } from './useTouch-a2ea68c6.js';
9
9
  import { g as getRectByTaro } from './useClientRect-bf69d7b3.js';
10
- import { T as Toast } from './toast.taro-86862dff.js';
10
+ import { T as Toast } from './toast.taro-0804b6b4.js';
11
11
  import { u as useConfig } from './configprovider.taro-8bdb3a28.js';
12
12
  var defaultProps = {
13
13
  range: false,
@@ -244,41 +244,43 @@ var Range = function Range(props) {
244
244
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event) {
245
245
  var rect, delta, total, value, _currentValue, _currentValue2, left, right, middle;
246
246
  return _regeneratorRuntime.wrap(function _callee$(_context) {
247
- while (1) switch (_context.prev = _context.next) {
248
- case 0:
249
- if (!(disabled || !root.current)) {
250
- _context.next = 2;
251
- break;
252
- }
253
- return _context.abrupt("return");
254
- case 2:
255
- SetDragStatus('');
256
- _context.next = 5;
257
- return getRectByTaro(root.current);
258
- case 5:
259
- rect = _context.sent;
260
- delta = (event.detail.x ? event.detail.x : event.clientX) - rect.left;
261
- total = rect.width;
262
- if (vertical) {
263
- delta = (event.detail.y ? event.detail.y : event.clientY) - rect.top;
264
- total = rect.height;
265
- }
266
- value = Number(min) + delta / total * scope();
267
- currentValue = initValue || initValue === 0 ? initValue : modelValue;
268
- if (isRange(currentValue)) {
269
- _currentValue = currentValue, _currentValue2 = _slicedToArray(_currentValue, 2), left = _currentValue2[0], right = _currentValue2[1];
270
- middle = (left + right) / 2;
271
- if (value <= middle) {
272
- updateValue([value, right], true);
247
+ while (1) {
248
+ switch (_context.prev = _context.next) {
249
+ case 0:
250
+ if (!(disabled || !root.current)) {
251
+ _context.next = 2;
252
+ break;
253
+ }
254
+ return _context.abrupt("return");
255
+ case 2:
256
+ SetDragStatus('');
257
+ _context.next = 5;
258
+ return getRectByTaro(root.current);
259
+ case 5:
260
+ rect = _context.sent;
261
+ delta = (event.detail.x ? event.detail.x : event.clientX) - rect.left;
262
+ total = rect.width;
263
+ if (vertical) {
264
+ delta = (event.detail.y ? event.detail.y : event.clientY) - rect.top;
265
+ total = rect.height;
266
+ }
267
+ value = Number(min) + delta / total * scope();
268
+ currentValue = initValue || initValue === 0 ? initValue : modelValue;
269
+ if (isRange(currentValue)) {
270
+ _currentValue = currentValue, _currentValue2 = _slicedToArray(_currentValue, 2), left = _currentValue2[0], right = _currentValue2[1];
271
+ middle = (left + right) / 2;
272
+ if (value <= middle) {
273
+ updateValue([value, right], true);
274
+ } else {
275
+ updateValue([left, value], true);
276
+ }
273
277
  } else {
274
- updateValue([left, value], true);
278
+ updateValue(value, true);
275
279
  }
276
- } else {
277
- updateValue(value, true);
278
- }
279
- case 12:
280
- case "end":
281
- return _context.stop();
280
+ case 12:
281
+ case "end":
282
+ return _context.stop();
283
+ }
282
284
  }
283
285
  }, _callee);
284
286
  }));
@@ -303,41 +305,43 @@ var Range = function Range(props) {
303
305
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(event) {
304
306
  var rect, delta, total, diff;
305
307
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
306
- while (1) switch (_context2.prev = _context2.next) {
307
- case 0:
308
- if (!(disabled || !root.current)) {
309
- _context2.next = 2;
310
- break;
311
- }
312
- return _context2.abrupt("return");
313
- case 2:
314
- if (dragStatus === 'start') {
315
- dragStart && dragStart();
316
- onDragStart && onDragStart();
317
- }
318
- touch.move(event);
319
- SetDragStatus('draging');
320
- _context2.next = 7;
321
- return getRectByTaro(root.current);
322
- case 7:
323
- rect = _context2.sent;
324
- delta = touch.deltaX;
325
- total = rect.width;
326
- diff = delta / total * scope();
327
- if (vertical) {
328
- delta = touch.deltaY;
329
- total = rect.height;
308
+ while (1) {
309
+ switch (_context2.prev = _context2.next) {
310
+ case 0:
311
+ if (!(disabled || !root.current)) {
312
+ _context2.next = 2;
313
+ break;
314
+ }
315
+ return _context2.abrupt("return");
316
+ case 2:
317
+ if (dragStatus === 'start') {
318
+ dragStart && dragStart();
319
+ onDragStart && onDragStart();
320
+ }
321
+ touch.move(event);
322
+ SetDragStatus('draging');
323
+ _context2.next = 7;
324
+ return getRectByTaro(root.current);
325
+ case 7:
326
+ rect = _context2.sent;
327
+ delta = touch.deltaX;
328
+ total = rect.width;
330
329
  diff = delta / total * scope();
331
- }
332
- if (isRange(startValue)) {
333
- currentValue[buttonIndex] = startValue[buttonIndex] + diff;
334
- } else {
335
- currentValue = startValue + diff;
336
- }
337
- updateValue(currentValue);
338
- case 14:
339
- case "end":
340
- return _context2.stop();
330
+ if (vertical) {
331
+ delta = touch.deltaY;
332
+ total = rect.height;
333
+ diff = delta / total * scope();
334
+ }
335
+ if (isRange(startValue)) {
336
+ currentValue[buttonIndex] = startValue[buttonIndex] + diff;
337
+ } else {
338
+ currentValue = startValue + diff;
339
+ }
340
+ updateValue(currentValue);
341
+ case 14:
342
+ case "end":
343
+ return _context2.stop();
344
+ }
341
345
  }
342
346
  }, _callee2);
343
347
  }));
@@ -7,7 +7,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
7
7
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
8
  import React__default, { useRef, useState, useEffect } from 'react';
9
9
  import { c as cn } from './bem-893ad28d.js';
10
- import { P as Popup } from './popup.taro-33d0bbc8.js';
10
+ import { P as Popup } from './popup.taro-cb777e09.js';
11
11
  import { I as Icon } from './icon.taro-1d0d4fb7.js';
12
12
  import { u as useConfig } from './configprovider.taro-8bdb3a28.js';
13
13
  import { C as ComponentDefaults } from './typings-1c5f2628.js';
@@ -6,7 +6,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
6
6
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
7
  import React__default, { useState } from 'react';
8
8
  import { u as useConfig } from './configprovider.taro-8bdb3a28.js';
9
- import { P as Popup } from './popup.taro-33d0bbc8.js';
9
+ import { P as Popup } from './popup.taro-cb777e09.js';
10
10
  import { O as OffsetContext } from './offsetContext-bfb02c25.js';
11
11
  var defaultProps = {
12
12
  showhead: false,
@@ -4,13 +4,15 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
4
4
  var _excluded = ["canvasId", "type", "lineWidth", "strokeStyle", "unSupportTpl", "className", "confirm", "clear", "onConfirm", "onClear"];
5
5
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
6
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
- import React__default, { useRef, useState } from 'react';
8
- import Taro, { useReady } from '@tarojs/taro';
7
+ import React__default, { useRef, useState, useEffect } from 'react';
8
+ import Taro from '@tarojs/taro';
9
9
  import { B as Button } from './button.taro-4ce133b9.js';
10
10
  import { c as cn } from './bem-893ad28d.js';
11
11
  import { u as useConfig } from './configprovider.taro-8bdb3a28.js';
12
+
13
+ /* eslint-disable react/no-unknown-property */
12
14
  var defaultProps = {
13
- canvasId: 'weappCanvas',
15
+ canvasId: 'spcanvas',
14
16
  type: 'png',
15
17
  lineWidth: 2,
16
18
  strokeStyle: '#000',
@@ -32,7 +34,7 @@ var Signature = function Signature(props) {
32
34
  onClear = _defaultProps$props.onClear,
33
35
  rest = _objectWithoutProperties(_defaultProps$props, _excluded);
34
36
  var b = cn('signature');
35
- useRef(null);
37
+ var canvasRef = useRef(null);
36
38
  var wrapRef = useRef(null);
37
39
  var _useState = useState(0),
38
40
  _useState2 = _slicedToArray(_useState, 2),
@@ -43,8 +45,10 @@ var Signature = function Signature(props) {
43
45
  canvasWidth = _useState4[0],
44
46
  setCanvasWidth = _useState4[1];
45
47
  var ctx = useRef(null);
48
+ var _useState5 = useState('true'),
49
+ _useState6 = _slicedToArray(_useState5, 1),
50
+ disalbeScroll = _useState6[0];
46
51
  var startEventHandler = function startEventHandler(event) {
47
- event.preventDefault();
48
52
  if (ctx.current) {
49
53
  ctx.current.beginPath();
50
54
  ctx.current.lineWidth = lineWidth;
@@ -52,15 +56,25 @@ var Signature = function Signature(props) {
52
56
  }
53
57
  };
54
58
  var moveEventHandler = function moveEventHandler(event) {
55
- event.preventDefault();
56
59
  if (ctx.current) {
57
- ctx.current.lineTo(event.changedTouches[0].x, event.changedTouches[0].y);
58
- ctx.current.stroke();
60
+ var evt = event.changedTouches[0];
61
+ var mouseX = evt.x || evt.clientX;
62
+ var mouseY = evt.y || evt.clientY;
63
+ if (Taro.getEnv() === 'WEB' && canvasRef.current) {
64
+ var coverPos = canvasRef.current.getBoundingClientRect();
65
+ mouseX = evt.clientX - coverPos.left;
66
+ mouseY = evt.clientY - coverPos.top;
67
+ }
68
+ Taro.nextTick(function () {
69
+ var _ctx$current, _ctx$current2;
70
+ // ctx.current.lineCap = 'round'
71
+ // ctx.current.lineJoin = 'round'
72
+ (_ctx$current = ctx.current) === null || _ctx$current === void 0 ? void 0 : _ctx$current.lineTo(mouseX, mouseY);
73
+ (_ctx$current2 = ctx.current) === null || _ctx$current2 === void 0 ? void 0 : _ctx$current2.stroke();
74
+ });
59
75
  }
60
76
  };
61
- var endEventHandler = function endEventHandler(event) {
62
- event.preventDefault();
63
- };
77
+ var endEventHandler = function endEventHandler(event) {};
64
78
  var handleClearBtn = function handleClearBtn() {
65
79
  if (ctx.current) {
66
80
  ctx.current.clearRect(0, 0, canvasWidth, canvasHeight);
@@ -80,6 +94,7 @@ var Signature = function Signature(props) {
80
94
  Taro.canvasToTempFilePath({
81
95
  canvas: res[0].node,
82
96
  fileType: props.type,
97
+ canvasId: "".concat(canvasId),
83
98
  success: function success(res) {
84
99
  handleClearBtn();
85
100
  confirm && confirm(res.tempFilePath);
@@ -91,48 +106,73 @@ var Signature = function Signature(props) {
91
106
  });
92
107
  });
93
108
  };
94
- useReady(function () {
95
- initCanvas();
96
- });
97
- // useEffect(() => {
98
- // eventCenter.once((getCurrentInstanceTaro() as any).router.onReady, () => {
109
+ var canvasSetting = function canvasSetting(canvasDom, width, height) {
110
+ var canvas = canvasDom;
111
+ canvas.current = canvas;
112
+ ctx.current = canvas.getContext('2d');
113
+ setCanvasWidth(width);
114
+ setCanvasHeight(height);
115
+ canvas.width = width;
116
+ canvas.height = height;
117
+ if (ctx.current) {
118
+ ctx.current.clearRect(0, 0, width, height);
119
+ ctx.current.beginPath();
120
+ ctx.current.lineWidth = lineWidth;
121
+ ctx.current.strokeStyle = strokeStyle;
122
+ }
123
+ };
99
124
  var initCanvas = function initCanvas() {
100
- Taro.createSelectorQuery().select("#".concat(canvasId)).fields({
101
- node: true,
102
- size: true
103
- }, function (res) {
104
- var canvas = res.node;
105
- canvas.current = canvas;
106
- ctx.current = canvas.getContext('2d');
107
- setCanvasWidth(res.width);
108
- setCanvasHeight(res.height);
109
- if (ctx.current) {
110
- ctx.current.clearRect(0, 0, canvasWidth, canvasHeight);
111
- ctx.current.beginPath();
112
- ctx.current.lineWidth = lineWidth;
113
- ctx.current.strokeStyle = strokeStyle;
114
- }
115
- }).exec();
125
+ Taro.nextTick(function () {
126
+ setTimeout(function () {
127
+ if (Taro.getEnv() === 'WEAPP' || Taro.getEnv() === 'JD') {
128
+ Taro.createSelectorQuery().select("#".concat(canvasId)).fields({
129
+ node: true,
130
+ size: true
131
+ }, function (res) {
132
+ var node = res.node,
133
+ width = res.width,
134
+ height = res.height;
135
+ canvasSetting(node, width, height);
136
+ }).exec();
137
+ } else {
138
+ var canvasDom = document.getElementById("".concat(canvasId));
139
+ var canvas = canvasDom;
140
+ if ((canvasDom === null || canvasDom === void 0 ? void 0 : canvasDom.tagName) !== 'CANVAS') {
141
+ canvas = canvasDom === null || canvasDom === void 0 ? void 0 : canvasDom.getElementsByTagName('canvas')[0];
142
+ }
143
+ canvasSetting(canvas, canvasDom === null || canvasDom === void 0 ? void 0 : canvasDom.offsetWidth, canvasDom === null || canvasDom === void 0 ? void 0 : canvasDom.offsetHeight);
144
+ }
145
+ }, 1000);
146
+ });
116
147
  };
117
- // })
118
- // }, [])
148
+ useEffect(function () {
149
+ initCanvas();
150
+ }, []);
119
151
  return React__default.createElement("div", _objectSpread({
120
152
  className: "".concat(b(), " ").concat(className)
121
153
  }, rest), React__default.createElement("div", {
122
- className: "".concat(b('inner')),
154
+ className: "".concat(b('inner'), " spcanvas_WEAPP"),
123
155
  ref: wrapRef
124
- }, React__default.createElement("canvas", {
156
+ }, Taro.getEnv() === 'WEAPP' || Taro.getEnv() === 'JD' ? React__default.createElement("canvas", {
125
157
  id: canvasId,
158
+ ref: canvasRef,
126
159
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
127
160
  // @ts-ignore
128
- // eslint-disable-next-line react/no-unknown-property
129
161
  canvasId: canvasId,
130
- // eslint-disable-next-line react/no-unknown-property
131
- disableScroll: true,
162
+ disalbeScroll: true,
132
163
  type: "2d",
133
164
  onTouchStart: startEventHandler,
134
165
  onTouchMove: moveEventHandler,
135
166
  onTouchEnd: endEventHandler
167
+ }) : React__default.createElement("canvas", {
168
+ id: canvasId,
169
+ ref: canvasRef,
170
+ "canvas-id": canvasId,
171
+ "disalbe-scroll": disalbeScroll,
172
+ onTouchStart: startEventHandler,
173
+ onTouchMove: moveEventHandler,
174
+ onTouchEnd: endEventHandler,
175
+ onTouchCancel: endEventHandler
136
176
  })), React__default.createElement(Button, {
137
177
  className: "".concat(b('btn')),
138
178
  type: "default",
@@ -60,43 +60,45 @@ var Swipe = forwardRef(function (props, instanceRef) {
60
60
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event) {
61
61
  var leftRect, rightRect;
62
62
  return _regeneratorRuntime.wrap(function _callee$(_context) {
63
- while (1) switch (_context.prev = _context.next) {
64
- case 0:
65
- if (!leftWrapper.current) {
66
- _context.next = 5;
67
- break;
68
- }
69
- _context.next = 3;
70
- return getRectByTaro(leftWrapper.current);
71
- case 3:
72
- leftRect = _context.sent;
73
- setActionWidth(function (v) {
74
- return _objectSpread(_objectSpread({}, v), {}, {
75
- left: leftRect.width
63
+ while (1) {
64
+ switch (_context.prev = _context.next) {
65
+ case 0:
66
+ if (!leftWrapper.current) {
67
+ _context.next = 5;
68
+ break;
69
+ }
70
+ _context.next = 3;
71
+ return getRectByTaro(leftWrapper.current);
72
+ case 3:
73
+ leftRect = _context.sent;
74
+ setActionWidth(function (v) {
75
+ return _objectSpread(_objectSpread({}, v), {}, {
76
+ left: leftRect.width
77
+ });
76
78
  });
77
- });
78
- case 5:
79
- if (!rightWrapper.current) {
80
- _context.next = 10;
81
- break;
82
- }
83
- _context.next = 8;
84
- return getRectByTaro(rightWrapper.current);
85
- case 8:
86
- rightRect = _context.sent;
87
- setActionWidth(function (v) {
88
- return _objectSpread(_objectSpread({}, v), {}, {
89
- right: rightRect.width
79
+ case 5:
80
+ if (!rightWrapper.current) {
81
+ _context.next = 10;
82
+ break;
83
+ }
84
+ _context.next = 8;
85
+ return getRectByTaro(rightWrapper.current);
86
+ case 8:
87
+ rightRect = _context.sent;
88
+ setActionWidth(function (v) {
89
+ return _objectSpread(_objectSpread({}, v), {}, {
90
+ right: rightRect.width
91
+ });
90
92
  });
91
- });
92
- case 10:
93
- if (!props.disabled) {
94
- startOffset.current = state.offset;
95
- touch.start(event);
96
- }
97
- case 11:
98
- case "end":
99
- return _context.stop();
93
+ case 10:
94
+ if (!props.disabled) {
95
+ startOffset.current = state.offset;
96
+ touch.start(event);
97
+ }
98
+ case 11:
99
+ case "end":
100
+ return _context.stop();
101
+ }
100
102
  }
101
103
  }, _callee);
102
104
  }));