@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.
- package/CHANGELOG.md +12 -0
- package/dist/esm/ActionSheet.js +4 -4
- package/dist/esm/Address.js +4 -4
- package/dist/esm/Audio.js +4 -4
- package/dist/esm/Badge.js +2 -2
- package/dist/esm/Barrage.js +2 -2
- package/dist/esm/Calendar.js +5 -5
- package/dist/esm/CalendarItem.js +2 -2
- package/dist/esm/Cascader.js +4 -4
- package/dist/esm/CircleProgress.js +2 -2
- package/dist/esm/DatePicker.js +5 -5
- package/dist/esm/Dialog.js +2 -2
- package/dist/esm/Drag.js +2 -2
- package/dist/esm/FixedNav.js +3 -3
- package/dist/esm/ImagePreview.js +4 -4
- package/dist/esm/InputNumber.js +2 -2
- package/dist/esm/MenuItem.js +3 -3
- package/dist/esm/NoticeBar.js +2 -2
- package/dist/esm/Notify.js +2 -2
- package/dist/esm/NumberKeyboard.js +4 -4
- package/dist/esm/Overlay.js +2 -2
- package/dist/esm/Picker.js +4 -4
- package/dist/esm/Popover.js +3 -3
- package/dist/esm/Popup.js +3 -3
- package/dist/esm/Range.js +3 -3
- package/dist/esm/ShortPassword.js +4 -4
- package/dist/esm/SideNavBar.js +4 -4
- package/dist/esm/Signature.js +2 -2
- package/dist/esm/TimeSelect.js +4 -4
- package/dist/esm/Toast.js +2 -2
- package/dist/esm/WaterMark.js +2 -2
- package/dist/esm/{actionsheet.taro-360d8d34.js → actionsheet.taro-a58d3d12.js} +1 -1
- package/dist/esm/{address.taro-c03b8b16.js → address.taro-1e2aea24.js} +22 -24
- package/dist/esm/{audio.taro-20890c93.js → audio.taro-fddcdfc0.js} +1 -1
- package/dist/esm/{badge.taro-9f72d846.js → badge.taro-fe9171ec.js} +1 -1
- package/dist/esm/{barrage.taro-d86c367a.js → barrage.taro-0e157b5e.js} +25 -23
- package/dist/esm/{calendar.taro-93b14945.js → calendar.taro-72974415.js} +2 -2
- package/dist/esm/{calendaritem.taro-85a8c4fc.js → calendaritem.taro-84e889eb.js} +19 -17
- package/dist/esm/{cascader.taro-459f7d45.js → cascader.taro-d8cb1c3e.js} +245 -235
- package/dist/esm/{circleprogress.taro-3c89a157.js → circleprogress.taro-47db537c.js} +2 -13
- package/dist/esm/{datepicker.taro-7de67b85.js → datepicker.taro-7199f521.js} +1 -1
- package/dist/esm/{dialog.taro-cf9e3087.js → dialog.taro-f54cfbf0.js} +1 -1
- package/dist/esm/{drag.taro-0717c783.js → drag.taro-82b6b27a.js} +4 -8
- package/dist/esm/ellipsis.taro-c0de6ff4.js +84 -76
- package/dist/esm/{fixednav.taro-005765f4.js → fixednav.taro-9e759320.js} +1 -1
- package/dist/esm/{imagepreview.taro-68e776f5.js → imagepreview.taro-3400ea03.js} +1 -1
- package/dist/esm/{inputnumber.taro-0a01f6e1.js → inputnumber.taro-dc39b853.js} +1 -0
- package/dist/esm/{menuitem.taro-2f8e69a4.js → menuitem.taro-216e9f7d.js} +17 -15
- package/dist/esm/{noticebar.taro-43c18dc9.js → noticebar.taro-94002898.js} +35 -33
- package/dist/esm/{notify.taro-d9c48fae.js → notify.taro-308e5892.js} +1 -1
- package/dist/esm/{numberkeyboard.taro-9635ecc9.js → numberkeyboard.taro-5e8f0ddf.js} +1 -1
- package/dist/esm/nutui-react.es.js +30 -30
- package/dist/esm/{overlay.taro-be45fed5.js → overlay.taro-98367bc1.js} +1 -1
- package/dist/esm/{picker.taro-9b7263ca.js → picker.taro-3b5cc054.js} +14 -12
- package/dist/esm/{popover.taro-7e5dff8c.js → popover.taro-46d813e8.js} +18 -16
- package/dist/esm/{popup.taro-33d0bbc8.js → popup.taro-cb777e09.js} +1 -1
- package/dist/esm/pulltorefresh.taro-f26a20dd.js +81 -75
- package/dist/esm/{range.taro-4cbe2469.js → range.taro-c41e9b90.js} +72 -68
- package/dist/esm/{shortpassword.taro-4bd513ae.js → shortpassword.taro-3a3bf412.js} +1 -1
- package/dist/esm/{sidenavbar.taro-3b1f1218.js → sidenavbar.taro-06026f31.js} +1 -1
- package/dist/esm/{signature.taro-504357dc.js → signature.taro-17648cac.js} +79 -39
- package/dist/esm/swipe.taro-83bc248f.js +37 -35
- package/dist/esm/swiper.taro-852f6615.js +28 -26
- package/dist/esm/{timeselect.taro-000060af.js → timeselect.taro-fc7ec6ee.js} +1 -1
- package/dist/esm/{toast.taro-86862dff.js → toast.taro-0804b6b4.js} +1 -1
- package/dist/esm/useClientRect-bf69d7b3.js +12 -10
- package/dist/esm/{watermark.taro-d1f38563.js → watermark.taro-323d1cf3.js} +53 -41
- package/dist/locales/base.js +1 -1
- package/dist/locales/en-US.js +1 -1
- package/dist/locales/id-ID.js +1 -1
- package/dist/locales/zh-CN.js +1 -1
- package/dist/locales/zh-TW.js +1 -1
- package/dist/locales/zh-UG.js +1 -1
- package/dist/nutui.react.es.js +160 -111
- package/dist/nutui.react.umd.js +159 -110
- package/dist/packages/drag/drag.scss +1 -0
- package/dist/packages/inputnumber/inputnumber.scss +4 -1
- package/dist/packages/signature/signature.scss +10 -3
- package/dist/style.css +1 -1
- package/dist/style.es.js +1 -1
- package/dist/styles/variables.scss +1 -1
- package/package.json +1 -1
package/dist/nutui.react.es.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui-react-taro v1.4.
|
|
2
|
+
* @nutui/nutui-react-taro v1.4.3-beta.0 Wed Jan 11 2023 14:52:52 GMT+0800 (China Standard Time)
|
|
3
3
|
* (c) 2023 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
import * as React from "react";
|
|
7
7
|
import React__default, { useCallback, useState, useEffect, useRef, createContext, useContext, useMemo, forwardRef, useImperativeHandle, useLayoutEffect, memo, Component } from "react";
|
|
8
|
-
import Taro, { usePageScroll,
|
|
8
|
+
import Taro, { usePageScroll, nextTick, useReady, createSelectorQuery } from "@tarojs/taro";
|
|
9
9
|
import ReactDOM, { createPortal, unstable_batchedUpdates } from "react-dom";
|
|
10
10
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
11
11
|
function getAugmentedNamespace(n) {
|
|
@@ -482,7 +482,7 @@ const Overlay = (props) => {
|
|
|
482
482
|
if (closeOnClickOverlay) {
|
|
483
483
|
props.onClick && props.onClick(e2);
|
|
484
484
|
renderRef.current = false;
|
|
485
|
-
const id = setTimeout(() => {
|
|
485
|
+
const id = window.setTimeout(() => {
|
|
486
486
|
setShow(!visible);
|
|
487
487
|
}, duration * 1e3 * 0.8);
|
|
488
488
|
intervalRef.current = id;
|
|
@@ -6768,7 +6768,7 @@ const defaultProps$1p = {
|
|
|
6768
6768
|
showError: true,
|
|
6769
6769
|
showLoading: true
|
|
6770
6770
|
};
|
|
6771
|
-
const Image = (props) => {
|
|
6771
|
+
const Image$1 = (props) => {
|
|
6772
6772
|
useConfig$1();
|
|
6773
6773
|
const {
|
|
6774
6774
|
children,
|
|
@@ -6847,8 +6847,8 @@ const Image = (props) => {
|
|
|
6847
6847
|
name: "image-error"
|
|
6848
6848
|
})) : null);
|
|
6849
6849
|
};
|
|
6850
|
-
Image.defaultProps = defaultProps$1p;
|
|
6851
|
-
Image.displayName = "NutImage";
|
|
6850
|
+
Image$1.defaultProps = defaultProps$1p;
|
|
6851
|
+
Image$1.displayName = "NutImage";
|
|
6852
6852
|
const defaultProps$1o = {};
|
|
6853
6853
|
const Layout = (props) => {
|
|
6854
6854
|
({ ...defaultProps$1o, ...props });
|
|
@@ -8770,7 +8770,7 @@ const Toast = (props) => {
|
|
|
8770
8770
|
const show = () => {
|
|
8771
8771
|
clearTimer();
|
|
8772
8772
|
if (duration) {
|
|
8773
|
-
timer = setTimeout(() => {
|
|
8773
|
+
timer = window.setTimeout(() => {
|
|
8774
8774
|
hide();
|
|
8775
8775
|
}, duration * 1e3);
|
|
8776
8776
|
}
|
|
@@ -9569,7 +9569,7 @@ const CalendarItem = (props) => {
|
|
|
9569
9569
|
if (type2 === "end") {
|
|
9570
9570
|
monthsPanel.current.style.webkitTransition = `transform ${time}ms cubic-bezier(0.19, 1, 0.22, 1)`;
|
|
9571
9571
|
clearTimeout(state.timer);
|
|
9572
|
-
state.timer = setTimeout(() => {
|
|
9572
|
+
state.timer = window.setTimeout(() => {
|
|
9573
9573
|
loadScroll();
|
|
9574
9574
|
}, time);
|
|
9575
9575
|
} else {
|
|
@@ -10973,6 +10973,7 @@ const InputNumber = (props) => {
|
|
|
10973
10973
|
name: "minus",
|
|
10974
10974
|
onClick: reduceNumber
|
|
10975
10975
|
}), /* @__PURE__ */ React__default.createElement("input", {
|
|
10976
|
+
className: "nut-number-input",
|
|
10976
10977
|
type: "number",
|
|
10977
10978
|
min,
|
|
10978
10979
|
max,
|
|
@@ -13820,7 +13821,6 @@ const Drag = (props) => {
|
|
|
13820
13821
|
transformCache.current = { x: translateX.current, y: translateY.current };
|
|
13821
13822
|
};
|
|
13822
13823
|
const touchMove = (e2) => {
|
|
13823
|
-
e2.preventDefault();
|
|
13824
13824
|
if (e2.touches.length === 1 && dragRef.current) {
|
|
13825
13825
|
const touch = e2.touches[0];
|
|
13826
13826
|
const x = touch.clientX - axisCache.current.x;
|
|
@@ -13853,11 +13853,9 @@ const Drag = (props) => {
|
|
|
13853
13853
|
}
|
|
13854
13854
|
};
|
|
13855
13855
|
useEffect(() => {
|
|
13856
|
-
|
|
13857
|
-
|
|
13858
|
-
|
|
13859
|
-
}, 200);
|
|
13860
|
-
});
|
|
13856
|
+
timer.current = window.setTimeout(() => {
|
|
13857
|
+
getInfo();
|
|
13858
|
+
}, 300);
|
|
13861
13859
|
return () => {
|
|
13862
13860
|
clearTimeout(timer.current);
|
|
13863
13861
|
};
|
|
@@ -14040,7 +14038,7 @@ const BaseDialog = (props, ref) => {
|
|
|
14040
14038
|
}),
|
|
14041
14039
|
disabled: okBtnDisabled,
|
|
14042
14040
|
onClick: (e2) => handleOk(e2)
|
|
14043
|
-
}, okText));
|
|
14041
|
+
}, okText || locale.confirm));
|
|
14044
14042
|
return footerContent;
|
|
14045
14043
|
};
|
|
14046
14044
|
return /* @__PURE__ */ React__default.createElement(DialogWrapper, {
|
|
@@ -14275,7 +14273,7 @@ const Notify = (props) => {
|
|
|
14275
14273
|
const show = () => {
|
|
14276
14274
|
clearTimer();
|
|
14277
14275
|
if (duration) {
|
|
14278
|
-
timer = setTimeout(() => {
|
|
14276
|
+
timer = window.setTimeout(() => {
|
|
14279
14277
|
hide();
|
|
14280
14278
|
}, duration);
|
|
14281
14279
|
}
|
|
@@ -19278,7 +19276,6 @@ const CircleProgress = (props) => {
|
|
|
19278
19276
|
const b2 = cn("circleprogress");
|
|
19279
19277
|
const classes = classNames(className, b2(""));
|
|
19280
19278
|
const refRandomId = Math.random().toString(36).slice(-8);
|
|
19281
|
-
let lastTime = 0;
|
|
19282
19279
|
const styles = {
|
|
19283
19280
|
height: `${Number(radius) * 2}px`,
|
|
19284
19281
|
width: `${Number(radius) * 2}px`,
|
|
@@ -19296,24 +19293,14 @@ const CircleProgress = (props) => {
|
|
|
19296
19293
|
const rate = progress2 * (endRate - startRate) + startRate;
|
|
19297
19294
|
setOldValue(Math.min(Math.max(+rate, 0), 100));
|
|
19298
19295
|
if (endRate > startRate ? rate < endRate : rate > endRate) {
|
|
19299
|
-
rafId =
|
|
19296
|
+
rafId = window.requestAnimationFrame(animate);
|
|
19300
19297
|
}
|
|
19301
19298
|
};
|
|
19302
19299
|
if (rafId) {
|
|
19303
19300
|
cancelAnimationFrame2(rafId);
|
|
19304
19301
|
}
|
|
19305
|
-
rafId =
|
|
19302
|
+
rafId = window.requestAnimationFrame(animate);
|
|
19306
19303
|
}, [progress]);
|
|
19307
|
-
const requestAnimationFrame2 = function(callback) {
|
|
19308
|
-
const currTime = new Date().getTime();
|
|
19309
|
-
const timeToCall = Math.max(0, 16.7 - (currTime - lastTime));
|
|
19310
|
-
lastTime = currTime + timeToCall;
|
|
19311
|
-
const id = setTimeout(function() {
|
|
19312
|
-
callback();
|
|
19313
|
-
}, timeToCall);
|
|
19314
|
-
lastTime = currTime + timeToCall;
|
|
19315
|
-
return id;
|
|
19316
|
-
};
|
|
19317
19304
|
const cancelAnimationFrame2 = function(id) {
|
|
19318
19305
|
clearTimeout(id);
|
|
19319
19306
|
};
|
|
@@ -19530,7 +19517,10 @@ const NoticeBar = (props) => {
|
|
|
19530
19517
|
const startRollEasy = () => {
|
|
19531
19518
|
showhorseLamp();
|
|
19532
19519
|
const time = height / speed / 4 < 1 ? Number((height / speed / 4).toFixed(1)) * 1e3 : ~~(height / speed / 4) * 1e3;
|
|
19533
|
-
const timerCurr = setInterval(
|
|
19520
|
+
const timerCurr = window.setInterval(
|
|
19521
|
+
showhorseLamp,
|
|
19522
|
+
time + Number(standTime)
|
|
19523
|
+
);
|
|
19534
19524
|
SetTimer(timerCurr);
|
|
19535
19525
|
};
|
|
19536
19526
|
const showhorseLamp = () => {
|
|
@@ -19543,7 +19533,7 @@ const NoticeBar = (props) => {
|
|
|
19543
19533
|
}, time);
|
|
19544
19534
|
};
|
|
19545
19535
|
const startRoll = () => {
|
|
19546
|
-
const timerCurr = setInterval(() => {
|
|
19536
|
+
const timerCurr = window.setInterval(() => {
|
|
19547
19537
|
const chunk = 100;
|
|
19548
19538
|
for (let i = 0; i < chunk; i++) {
|
|
19549
19539
|
scroll(i, !(i < chunk - 1));
|
|
@@ -20563,7 +20553,7 @@ const Badge = (props) => {
|
|
|
20563
20553
|
style2.top = `${Number(top) || parseFloat(top) || 0}px`;
|
|
20564
20554
|
style2.right = `${Number(right) || parseFloat(right) || 0}px`;
|
|
20565
20555
|
style2.zIndex = zIndex;
|
|
20566
|
-
style2.
|
|
20556
|
+
style2.background = color;
|
|
20567
20557
|
return style2;
|
|
20568
20558
|
};
|
|
20569
20559
|
return /* @__PURE__ */ React__default.createElement("div", {
|
|
@@ -22584,55 +22574,67 @@ const WaterMark = (props) => {
|
|
|
22584
22574
|
}, []);
|
|
22585
22575
|
const init = () => {
|
|
22586
22576
|
let ratio = 1;
|
|
22587
|
-
Taro.getSystemInfo({
|
|
22588
|
-
|
|
22589
|
-
|
|
22590
|
-
}
|
|
22591
|
-
|
|
22592
|
-
|
|
22593
|
-
|
|
22594
|
-
|
|
22595
|
-
|
|
22596
|
-
|
|
22597
|
-
|
|
22598
|
-
|
|
22599
|
-
|
|
22600
|
-
|
|
22601
|
-
|
|
22602
|
-
|
|
22603
|
-
|
|
22604
|
-
|
|
22605
|
-
|
|
22606
|
-
|
|
22607
|
-
|
|
22608
|
-
|
|
22609
|
-
|
|
22610
|
-
|
|
22611
|
-
ctx2.
|
|
22612
|
-
|
|
22613
|
-
|
|
22614
|
-
|
|
22615
|
-
|
|
22616
|
-
|
|
22617
|
-
|
|
22577
|
+
Taro.getSystemInfo().then((res) => {
|
|
22578
|
+
ratio = res.pixelRatio;
|
|
22579
|
+
const canvasWidth = `${(gapX + width) * ratio}px`;
|
|
22580
|
+
const canvasHeight = `${(gapY + height) * ratio}px`;
|
|
22581
|
+
const markWidth = width * ratio;
|
|
22582
|
+
const markHeight = height * ratio;
|
|
22583
|
+
let ctx2;
|
|
22584
|
+
let canvas;
|
|
22585
|
+
if ({}.TARO_ENV === "h5") {
|
|
22586
|
+
canvas = document.createElement("canvas");
|
|
22587
|
+
ctx2 = canvas.getContext("2d");
|
|
22588
|
+
canvas.setAttribute("width", canvasWidth);
|
|
22589
|
+
canvas.setAttribute("height", canvasHeight);
|
|
22590
|
+
} else {
|
|
22591
|
+
canvas = Taro.createOffscreenCanvas({
|
|
22592
|
+
type: "2d",
|
|
22593
|
+
width: Number(canvasWidth),
|
|
22594
|
+
height: Number(canvasHeight)
|
|
22595
|
+
});
|
|
22596
|
+
ctx2 = canvas.getContext("2d");
|
|
22597
|
+
}
|
|
22598
|
+
if (ctx2) {
|
|
22599
|
+
if (image) {
|
|
22600
|
+
ctx2.translate(markWidth / 2, markHeight / 2);
|
|
22601
|
+
ctx2.rotate(Math.PI / 180 * Number(rotate));
|
|
22602
|
+
let img;
|
|
22603
|
+
if ({}.TARO_ENV === "h5") {
|
|
22604
|
+
img = new Image();
|
|
22605
|
+
} else {
|
|
22606
|
+
img = canvas.createImage();
|
|
22607
|
+
}
|
|
22608
|
+
img.crossOrigin = "anonymous";
|
|
22609
|
+
img.referrerPolicy = "no-referrer";
|
|
22610
|
+
img.src = image;
|
|
22611
|
+
img.onload = () => {
|
|
22612
|
+
ctx2.drawImage(
|
|
22613
|
+
img,
|
|
22614
|
+
-imageWidth * ratio / 2,
|
|
22615
|
+
-imageHeight * ratio / 2,
|
|
22616
|
+
imageWidth * ratio,
|
|
22617
|
+
imageHeight * ratio
|
|
22618
|
+
);
|
|
22619
|
+
ctx2.restore();
|
|
22620
|
+
setBase64Url(canvas.toDataURL());
|
|
22621
|
+
};
|
|
22622
|
+
} else if (content) {
|
|
22623
|
+
ctx2.textBaseline = "middle";
|
|
22624
|
+
ctx2.textAlign = "center";
|
|
22625
|
+
ctx2.translate(markWidth / 2, markHeight / 2);
|
|
22626
|
+
ctx2.rotate(Math.PI / 180 * Number(rotate));
|
|
22627
|
+
const markSize = Number(fontSize) * ratio;
|
|
22628
|
+
ctx2.font = `${fontStyle} normal ${fontWeight} ${markSize}px/${markHeight}px ${fontFamily}`;
|
|
22629
|
+
ctx2.fillStyle = fontColor;
|
|
22630
|
+
ctx2.fillText(content, 0, 0);
|
|
22618
22631
|
ctx2.restore();
|
|
22619
22632
|
setBase64Url(canvas.toDataURL());
|
|
22620
|
-
}
|
|
22621
|
-
} else
|
|
22622
|
-
|
|
22623
|
-
ctx2.textAlign = "center";
|
|
22624
|
-
ctx2.translate(markWidth / 2, markHeight / 2);
|
|
22625
|
-
ctx2.rotate(Math.PI / 180 * Number(rotate));
|
|
22626
|
-
const markSize = Number(fontSize) * ratio;
|
|
22627
|
-
ctx2.font = `${fontStyle} normal ${fontWeight} ${markSize}px/${markHeight}px ${fontFamily}`;
|
|
22628
|
-
ctx2.fillStyle = fontColor;
|
|
22629
|
-
ctx2.fillText(content, 0, 0);
|
|
22630
|
-
ctx2.restore();
|
|
22631
|
-
setBase64Url(canvas.toDataURL());
|
|
22633
|
+
}
|
|
22634
|
+
} else {
|
|
22635
|
+
throw new Error(locale.watermark.errorCanvasTips);
|
|
22632
22636
|
}
|
|
22633
|
-
}
|
|
22634
|
-
throw new Error(locale.watermark.errorCanvasTips);
|
|
22635
|
-
}
|
|
22637
|
+
});
|
|
22636
22638
|
};
|
|
22637
22639
|
return /* @__PURE__ */ React__default.createElement("div", {
|
|
22638
22640
|
className: cls,
|
|
@@ -23533,7 +23535,7 @@ const InternalBarrage = (props, ref) => {
|
|
|
23533
23535
|
}, [barrageList]);
|
|
23534
23536
|
const run = () => {
|
|
23535
23537
|
clearInterval(timer.current);
|
|
23536
|
-
timer.current = setInterval(() => {
|
|
23538
|
+
timer.current = window.setInterval(() => {
|
|
23537
23539
|
play();
|
|
23538
23540
|
run();
|
|
23539
23541
|
}, frequency);
|
|
@@ -23570,7 +23572,7 @@ const Barrage = React__default.forwardRef(InternalBarrage);
|
|
|
23570
23572
|
Barrage.defaultProps = defaultProps$5;
|
|
23571
23573
|
Barrage.displayName = "NutBarrage";
|
|
23572
23574
|
const defaultProps$4 = {
|
|
23573
|
-
canvasId: "
|
|
23575
|
+
canvasId: "spcanvas",
|
|
23574
23576
|
type: "png",
|
|
23575
23577
|
lineWidth: 2,
|
|
23576
23578
|
strokeStyle: "#000",
|
|
@@ -23595,13 +23597,13 @@ const Signature = (props) => {
|
|
|
23595
23597
|
...props
|
|
23596
23598
|
};
|
|
23597
23599
|
const b2 = cn("signature");
|
|
23598
|
-
useRef(null);
|
|
23600
|
+
const canvasRef = useRef(null);
|
|
23599
23601
|
const wrapRef = useRef(null);
|
|
23600
23602
|
const [canvasHeight, setCanvasHeight] = useState(0);
|
|
23601
23603
|
const [canvasWidth, setCanvasWidth] = useState(0);
|
|
23602
23604
|
const ctx2 = useRef(null);
|
|
23605
|
+
const [disalbeScroll] = useState("true");
|
|
23603
23606
|
const startEventHandler = (event) => {
|
|
23604
|
-
event.preventDefault();
|
|
23605
23607
|
if (ctx2.current) {
|
|
23606
23608
|
ctx2.current.beginPath();
|
|
23607
23609
|
ctx2.current.lineWidth = lineWidth;
|
|
@@ -23609,14 +23611,23 @@ const Signature = (props) => {
|
|
|
23609
23611
|
}
|
|
23610
23612
|
};
|
|
23611
23613
|
const moveEventHandler = (event) => {
|
|
23612
|
-
event.preventDefault();
|
|
23613
23614
|
if (ctx2.current) {
|
|
23614
|
-
|
|
23615
|
-
|
|
23615
|
+
const evt = event.changedTouches[0];
|
|
23616
|
+
let mouseX = evt.x || evt.clientX;
|
|
23617
|
+
let mouseY = evt.y || evt.clientY;
|
|
23618
|
+
if (Taro.getEnv() === "WEB" && canvasRef.current) {
|
|
23619
|
+
const coverPos = canvasRef.current.getBoundingClientRect();
|
|
23620
|
+
mouseX = evt.clientX - coverPos.left;
|
|
23621
|
+
mouseY = evt.clientY - coverPos.top;
|
|
23622
|
+
}
|
|
23623
|
+
Taro.nextTick(() => {
|
|
23624
|
+
var _a, _b;
|
|
23625
|
+
(_a = ctx2.current) == null ? void 0 : _a.lineTo(mouseX, mouseY);
|
|
23626
|
+
(_b = ctx2.current) == null ? void 0 : _b.stroke();
|
|
23627
|
+
});
|
|
23616
23628
|
}
|
|
23617
23629
|
};
|
|
23618
23630
|
const endEventHandler = (event) => {
|
|
23619
|
-
event.preventDefault();
|
|
23620
23631
|
};
|
|
23621
23632
|
const handleClearBtn = () => {
|
|
23622
23633
|
if (ctx2.current) {
|
|
@@ -23637,6 +23648,7 @@ const Signature = (props) => {
|
|
|
23637
23648
|
Taro.canvasToTempFilePath({
|
|
23638
23649
|
canvas: res[0].node,
|
|
23639
23650
|
fileType: props.type,
|
|
23651
|
+
canvasId: `${canvasId}`,
|
|
23640
23652
|
success: (res2) => {
|
|
23641
23653
|
handleClearBtn();
|
|
23642
23654
|
confirm && confirm(res2.tempFilePath);
|
|
@@ -23648,44 +23660,81 @@ const Signature = (props) => {
|
|
|
23648
23660
|
});
|
|
23649
23661
|
});
|
|
23650
23662
|
};
|
|
23651
|
-
|
|
23652
|
-
|
|
23653
|
-
|
|
23663
|
+
const canvasSetting = (canvasDom, width, height) => {
|
|
23664
|
+
const canvas = canvasDom;
|
|
23665
|
+
canvas.current = canvas;
|
|
23666
|
+
ctx2.current = canvas.getContext("2d");
|
|
23667
|
+
setCanvasWidth(width);
|
|
23668
|
+
setCanvasHeight(height);
|
|
23669
|
+
canvas.width = width;
|
|
23670
|
+
canvas.height = height;
|
|
23671
|
+
if (ctx2.current) {
|
|
23672
|
+
ctx2.current.clearRect(0, 0, width, height);
|
|
23673
|
+
ctx2.current.beginPath();
|
|
23674
|
+
ctx2.current.lineWidth = lineWidth;
|
|
23675
|
+
ctx2.current.strokeStyle = strokeStyle;
|
|
23676
|
+
}
|
|
23677
|
+
};
|
|
23654
23678
|
const initCanvas = () => {
|
|
23655
|
-
Taro.
|
|
23656
|
-
{
|
|
23657
|
-
|
|
23658
|
-
|
|
23659
|
-
|
|
23660
|
-
|
|
23661
|
-
|
|
23662
|
-
|
|
23663
|
-
|
|
23664
|
-
|
|
23665
|
-
|
|
23666
|
-
|
|
23667
|
-
|
|
23668
|
-
|
|
23669
|
-
|
|
23670
|
-
|
|
23679
|
+
Taro.nextTick(() => {
|
|
23680
|
+
setTimeout(() => {
|
|
23681
|
+
if (Taro.getEnv() === "WEAPP" || Taro.getEnv() === "JD") {
|
|
23682
|
+
Taro.createSelectorQuery().select(`#${canvasId}`).fields(
|
|
23683
|
+
{
|
|
23684
|
+
node: true,
|
|
23685
|
+
size: true
|
|
23686
|
+
},
|
|
23687
|
+
(res) => {
|
|
23688
|
+
const { node, width, height } = res;
|
|
23689
|
+
canvasSetting(node, width, height);
|
|
23690
|
+
}
|
|
23691
|
+
).exec();
|
|
23692
|
+
} else {
|
|
23693
|
+
const canvasDom = document.getElementById(
|
|
23694
|
+
`${canvasId}`
|
|
23695
|
+
);
|
|
23696
|
+
let canvas = canvasDom;
|
|
23697
|
+
if ((canvasDom == null ? void 0 : canvasDom.tagName) !== "CANVAS") {
|
|
23698
|
+
canvas = canvasDom == null ? void 0 : canvasDom.getElementsByTagName(
|
|
23699
|
+
"canvas"
|
|
23700
|
+
)[0];
|
|
23701
|
+
}
|
|
23702
|
+
canvasSetting(
|
|
23703
|
+
canvas,
|
|
23704
|
+
canvasDom == null ? void 0 : canvasDom.offsetWidth,
|
|
23705
|
+
canvasDom == null ? void 0 : canvasDom.offsetHeight
|
|
23706
|
+
);
|
|
23671
23707
|
}
|
|
23672
|
-
}
|
|
23673
|
-
)
|
|
23708
|
+
}, 1e3);
|
|
23709
|
+
});
|
|
23674
23710
|
};
|
|
23711
|
+
useEffect(() => {
|
|
23712
|
+
initCanvas();
|
|
23713
|
+
}, []);
|
|
23675
23714
|
return /* @__PURE__ */ React__default.createElement("div", {
|
|
23676
23715
|
className: `${b2()} ${className}`,
|
|
23677
23716
|
...rest
|
|
23678
23717
|
}, /* @__PURE__ */ React__default.createElement("div", {
|
|
23679
|
-
className: `${b2("inner")}`,
|
|
23718
|
+
className: `${b2("inner")} spcanvas_WEAPP`,
|
|
23680
23719
|
ref: wrapRef
|
|
23681
|
-
}, /* @__PURE__ */ React__default.createElement("canvas", {
|
|
23720
|
+
}, Taro.getEnv() === "WEAPP" || Taro.getEnv() === "JD" ? /* @__PURE__ */ React__default.createElement("canvas", {
|
|
23682
23721
|
id: canvasId,
|
|
23722
|
+
ref: canvasRef,
|
|
23683
23723
|
canvasId,
|
|
23684
|
-
|
|
23724
|
+
disalbeScroll: true,
|
|
23685
23725
|
type: "2d",
|
|
23686
23726
|
onTouchStart: startEventHandler,
|
|
23687
23727
|
onTouchMove: moveEventHandler,
|
|
23688
23728
|
onTouchEnd: endEventHandler
|
|
23729
|
+
}) : /* @__PURE__ */ React__default.createElement("canvas", {
|
|
23730
|
+
id: canvasId,
|
|
23731
|
+
ref: canvasRef,
|
|
23732
|
+
"canvas-id": canvasId,
|
|
23733
|
+
"disalbe-scroll": disalbeScroll,
|
|
23734
|
+
onTouchStart: startEventHandler,
|
|
23735
|
+
onTouchMove: moveEventHandler,
|
|
23736
|
+
onTouchEnd: endEventHandler,
|
|
23737
|
+
onTouchCancel: endEventHandler
|
|
23689
23738
|
})), /* @__PURE__ */ React__default.createElement(Button, {
|
|
23690
23739
|
className: `${b2("btn")}`,
|
|
23691
23740
|
type: "default",
|
|
@@ -23972,4 +24021,4 @@ const TimeSelect = (props) => {
|
|
|
23972
24021
|
};
|
|
23973
24022
|
TimeSelect.defaultProps = defaultProps;
|
|
23974
24023
|
TimeSelect.displayName = "NutTimeSelect";
|
|
23975
|
-
export { ActionSheet, Address, Animate, AnimatingNumbers, Audio, Avatar, AvatarGroup, BackTop, Badge, Barrage, Button, Calendar, CalendarItem, Card, Cascader, Cell, CellGroup, Checkbox, CheckboxGroup, CircleProgress, Col, Collapse, CollapseItem, ConfigProvider, CountDown, DatePicker, Dialog, Divider, Drag, Elevator, Ellipsis, Empty, FixedNav, Form, FormItem, Grid, GridItem, Icon$1 as Icon, Image, ImagePreview, Indicator, Infiniteloading, Input, InputNumber, Layout, Menu, MenuItem, NavBar, NoticeBar, Notify, NumberKeyboard, Overlay, Pagination, Picker, Popover, Popup, Price, Progress, PullToRefresh, Radio, RadioGroup, Range, Rate, Row, SearchBar, ShortPassword, SideNavBar, SideNavBarItem, Signature, Skeleton, Step, Steps, Sticky, SubSideNavBar, Swipe, Swiper, SwiperItem, Switch, TabPane, Tabbar, TabbarItem, Table, Tabs, Tag, TextArea, TimeDetail, TimePannel, TimeSelect, Toast, TrendArrow, Uploader, Video, VirtualList, WaterMark };
|
|
24024
|
+
export { ActionSheet, Address, Animate, AnimatingNumbers, Audio, Avatar, AvatarGroup, BackTop, Badge, Barrage, Button, Calendar, CalendarItem, Card, Cascader, Cell, CellGroup, Checkbox, CheckboxGroup, CircleProgress, Col, Collapse, CollapseItem, ConfigProvider, CountDown, DatePicker, Dialog, Divider, Drag, Elevator, Ellipsis, Empty, FixedNav, Form, FormItem, Grid, GridItem, Icon$1 as Icon, Image$1 as Image, ImagePreview, Indicator, Infiniteloading, Input, InputNumber, Layout, Menu, MenuItem, NavBar, NoticeBar, Notify, NumberKeyboard, Overlay, Pagination, Picker, Popover, Popup, Price, Progress, PullToRefresh, Radio, RadioGroup, Range, Rate, Row, SearchBar, ShortPassword, SideNavBar, SideNavBarItem, Signature, Skeleton, Step, Steps, Sticky, SubSideNavBar, Swipe, Swiper, SwiperItem, Switch, TabPane, Tabbar, TabbarItem, Table, Tabs, Tag, TextArea, TimeDetail, TimePannel, TimeSelect, Toast, TrendArrow, Uploader, Video, VirtualList, WaterMark };
|