@nutui/nutui-react-taro 2.0.0-alpha.8 → 2.0.0-alpha.9
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 +20 -0
- package/dist/esm/Address.js +2 -2
- package/dist/esm/Card.js +5 -5
- package/dist/esm/DatePicker.js +2 -3
- package/dist/esm/Elevator.js +1 -1
- package/dist/esm/ImagePreview.js +4 -7
- package/dist/esm/Indicator.js +1 -1
- package/dist/esm/InputNumber.js +1 -1
- package/dist/esm/Notify.js +2 -3
- package/dist/esm/NumberKeyboard.js +3 -5
- package/dist/esm/Picker.js +1 -2
- package/dist/esm/Price.js +2 -3
- package/dist/esm/PullToRefresh.js +4 -6
- package/dist/esm/Radio.js +3 -3
- package/dist/esm/RadioGroup.js +3 -3
- package/dist/esm/Step.js +1 -1
- package/dist/esm/Steps.js +1 -1
- package/dist/esm/Sticky.js +1 -2
- package/dist/esm/Swiper.js +3 -5
- package/dist/esm/SwiperItem.js +1 -5
- package/dist/esm/{address.taro-1c534feb.js → address.taro-1a8ab3f1.js} +1 -1
- package/dist/esm/{card.taro-a46fdf25.js → card.taro-2080f4d2.js} +1 -1
- package/dist/esm/{datepicker.taro-3f718964.js → datepicker.taro-65dbeceb.js} +1 -1
- package/dist/esm/{elevator.taro-bc162e4f.js → elevator.taro-df8fde9d.js} +20 -15
- package/dist/esm/{imagepreview.taro-8832dc01.js → imagepreview.taro-2508d412.js} +8 -5
- package/dist/esm/{indicator.taro-f2bd212f.js → indicator.taro-edbc71df.js} +3 -3
- package/dist/esm/{inputnumber.taro-877dc947.js → inputnumber.taro-6657d2c1.js} +1 -1
- package/dist/esm/{notify.taro-6b6eb6bf.js → notify.taro-5768403d.js} +11 -18
- package/dist/esm/numberkeyboard.taro-ad8afaf9.js +136 -0
- package/dist/esm/nutui-react.es.js +16 -21
- package/dist/esm/{picker.taro-a5603921.js → picker.taro-0570ec32.js} +14 -1
- package/dist/esm/{price.taro-c4f45310.js → price.taro-479f1b82.js} +17 -17
- package/dist/esm/pulltorefresh.taro-6afe4805.js +138 -0
- package/dist/esm/radio.taro-5d6ca4ad.js +153 -0
- package/dist/esm/step.taro-3bc01c0c.js +1 -1
- package/dist/esm/steps.taro-77e301ab.js +1 -1
- package/dist/esm/{sticky.taro-3c03eb0a.js → sticky.taro-f8ae8d5e.js} +21 -1
- package/dist/esm/swiper.taro-53a36427.js +83 -0
- package/dist/esm/swiperitem.taro-ef7342e8.js +14 -0
- 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.mjs +1162 -6119
- package/dist/nutui.react.umd.js +1546 -6519
- package/dist/packages/imagepreview/imagepreview.scss +5 -0
- package/dist/packages/notify/notify.scss +1 -1
- package/dist/packages/numberkeyboard/numberkeyboard.scss +29 -77
- package/dist/packages/price/price.scss +8 -0
- package/dist/packages/pulltorefresh/pulltorefresh.scss +0 -8
- package/dist/packages/radio/radio.scss +13 -32
- package/dist/packages/radiogroup/radiogroup.scss +17 -51
- package/dist/packages/swiper/swiper.scss +0 -15
- package/dist/style.css +1 -1
- package/dist/style.mjs +1 -1
- package/dist/styles/variables-jmapp.scss +50 -44
- package/dist/styles/variables.scss +50 -46
- package/dist/types/index.d.ts +63 -92
- package/package.json +1 -1
- package/dist/esm/UserContext-735db09f.js +0 -5
- package/dist/esm/get-scroll-parent-8da04f2e.js +0 -24
- package/dist/esm/numberkeyboard.taro-0a0e866a.js +0 -183
- package/dist/esm/pulltorefresh.taro-c611fd92.js +0 -179
- package/dist/esm/radio.taro-3a54f4c8.js +0 -152
- package/dist/esm/supports-passive-aaaf0eff.js +0 -17
- package/dist/esm/swiper.taro-74cf9306.js +0 -430
- package/dist/esm/swiperitem-80df464a.js +0 -29
|
@@ -10,9 +10,9 @@ import { G } from "./grid.taro-fbbd8618.js";
|
|
|
10
10
|
import { G as G2 } from "./griditem.taro-b0c37077.js";
|
|
11
11
|
import { L } from "./layout.taro-9659a928.js";
|
|
12
12
|
import { R } from "./row.taro-8b7febd4.js";
|
|
13
|
-
import { S } from "./sticky.taro-
|
|
13
|
+
import { S } from "./sticky.taro-f8ae8d5e.js";
|
|
14
14
|
import { B as B2 } from "./backtop.taro-7de36464.js";
|
|
15
|
-
import { E } from "./elevator.taro-
|
|
15
|
+
import { E } from "./elevator.taro-df8fde9d.js";
|
|
16
16
|
import { F } from "./fixednav.taro-28e5f776.js";
|
|
17
17
|
import { N } from "./navbar.taro-5e1a0835.js";
|
|
18
18
|
import { S as S2 } from "./sidenavbar.taro-9f210df4.js";
|
|
@@ -22,21 +22,21 @@ import { T } from "./tabbar.taro-18eee41f.js";
|
|
|
22
22
|
import { T as T2 } from "./tabbaritem.taro-89646ca1.js";
|
|
23
23
|
import { T as T3 } from "./tabpane.taro-f8d92ece.js";
|
|
24
24
|
import { T as T4 } from "./tabs.taro-66164782.js";
|
|
25
|
-
import { A } from "./address.taro-
|
|
25
|
+
import { A } from "./address.taro-1a8ab3f1.js";
|
|
26
26
|
import { C as C5 } from "./calendar.taro-10a6cb11.js";
|
|
27
27
|
import { C as C6 } from "./calendaritem.taro-3e5f114e.js";
|
|
28
28
|
import { C as C7 } from "./cascader.taro-fb7a0230.js";
|
|
29
29
|
import { C as C8, a } from "./checkbox.taro-016074da.js";
|
|
30
|
-
import { D as D2 } from "./datepicker.taro-
|
|
30
|
+
import { D as D2 } from "./datepicker.taro-65dbeceb.js";
|
|
31
31
|
import { F as F2 } from "./form.taro-b06754e8.js";
|
|
32
32
|
import { F as F3 } from "./formitem.taro-b326809d.js";
|
|
33
33
|
import { I as I2 } from "./input.taro-27d686c9.js";
|
|
34
|
-
import { I as I3 } from "./inputnumber.taro-
|
|
34
|
+
import { I as I3 } from "./inputnumber.taro-6657d2c1.js";
|
|
35
35
|
import { M } from "./menu.taro-cd0fef41.js";
|
|
36
36
|
import { M as M2 } from "./menuitem.taro-6076bffa.js";
|
|
37
|
-
import { N as N2 } from "./numberkeyboard.taro-
|
|
38
|
-
import { P } from "./picker.taro-
|
|
39
|
-
import { R as R2, a as a2 } from "./radio.taro-
|
|
37
|
+
import { N as N2 } from "./numberkeyboard.taro-ad8afaf9.js";
|
|
38
|
+
import { P } from "./picker.taro-0570ec32.js";
|
|
39
|
+
import { R as R2, a as a2 } from "./radio.taro-5d6ca4ad.js";
|
|
40
40
|
import { R as R3 } from "./range.taro-615e193a.js";
|
|
41
41
|
import { R as R4 } from "./rate.taro-78c66969.js";
|
|
42
42
|
import { S as S5 } from "./searchbar.taro-37ade36e.js";
|
|
@@ -52,9 +52,9 @@ import { D as D3 } from "./drag.taro-48e1ff38.js";
|
|
|
52
52
|
import { E as E2 } from "./empty.taro-ca792f57.js";
|
|
53
53
|
import { I as I4 } from "./infiniteloading.taro-f8f23ac6.js";
|
|
54
54
|
import { N as N3 } from "./noticebar.taro-b3bfd4fe.js";
|
|
55
|
-
import { N as N4 } from "./notify.taro-
|
|
55
|
+
import { N as N4 } from "./notify.taro-5768403d.js";
|
|
56
56
|
import { P as P2 } from "./popover.taro-ad483372.js";
|
|
57
|
-
import { P as P3 } from "./pulltorefresh.taro-
|
|
57
|
+
import { P as P3 } from "./pulltorefresh.taro-6afe4805.js";
|
|
58
58
|
import { S as S9 } from "./skeleton.taro-9ff9baf4.js";
|
|
59
59
|
import { S as S10 } from "./swipe.taro-de80fcd8.js";
|
|
60
60
|
import { P as P4 } from "./popup.taro-e756f3fc.js";
|
|
@@ -69,21 +69,21 @@ import { C as C10 } from "./collapse.taro-3d997680.js";
|
|
|
69
69
|
import { C as C11 } from "./collapseitem-f4571575.js";
|
|
70
70
|
import { C as C12 } from "./countdown.taro-22200811.js";
|
|
71
71
|
import { E as E3 } from "./ellipsis.taro-f9688dd7.js";
|
|
72
|
-
import { I as I5 } from "./imagepreview.taro-
|
|
73
|
-
import { I as I6 } from "./indicator.taro-
|
|
72
|
+
import { I as I5 } from "./imagepreview.taro-2508d412.js";
|
|
73
|
+
import { I as I6 } from "./indicator.taro-edbc71df.js";
|
|
74
74
|
import { V } from "./virtuallist.taro-99f03769.js";
|
|
75
75
|
import { P as P5 } from "./pagination.taro-63607c3b.js";
|
|
76
|
-
import { P as P6 } from "./price.taro-
|
|
76
|
+
import { P as P6 } from "./price.taro-479f1b82.js";
|
|
77
77
|
import { P as P7 } from "./progress.taro-ff63be75.js";
|
|
78
78
|
import { S as S11 } from "./step.taro-3bc01c0c.js";
|
|
79
79
|
import { S as S12 } from "./steps.taro-77e301ab.js";
|
|
80
|
-
import { S as S13 } from "./swiper.taro-
|
|
81
|
-
import { S as S14 } from "./swiperitem-
|
|
80
|
+
import { S as S13 } from "./swiper.taro-53a36427.js";
|
|
81
|
+
import { S as S14 } from "./swiperitem.taro-ef7342e8.js";
|
|
82
82
|
import { T as T7 } from "./table.taro-15a55c5d.js";
|
|
83
83
|
import { T as T8 } from "./tag.taro-1b4134a5.js";
|
|
84
84
|
import { V as V2 } from "./video-5d106e33.js";
|
|
85
85
|
import { B as B5 } from "./barrage.taro-c8cb9864.js";
|
|
86
|
-
import { C as C13 } from "./card.taro-
|
|
86
|
+
import { C as C13 } from "./card.taro-2080f4d2.js";
|
|
87
87
|
import { T as T9 } from "./timedetail.taro-8d2acbbf.js";
|
|
88
88
|
import { T as T10 } from "./timepannel.taro-ee4c5dfa.js";
|
|
89
89
|
import { T as T11 } from "./timeselect.taro-069deedd.js";
|
|
@@ -97,7 +97,6 @@ import "@tarojs/components";
|
|
|
97
97
|
import "./UserContext-ab42ba7f.js";
|
|
98
98
|
import "@tarojs/taro";
|
|
99
99
|
import "./use-client-rect-f317804e.js";
|
|
100
|
-
import "./get-scroll-parent-8da04f2e.js";
|
|
101
100
|
import "./can-use-dom-0e539bd3.js";
|
|
102
101
|
import "./offsetContext-f32a9246.js";
|
|
103
102
|
import "./use-props-value-7ac1b1b5.js";
|
|
@@ -106,13 +105,9 @@ import "@bem-react/classname";
|
|
|
106
105
|
import "./ConfigProvider.js";
|
|
107
106
|
import "react-transition-group";
|
|
108
107
|
import "./use-touch-ff43512c.js";
|
|
109
|
-
import "./supports-passive-aaaf0eff.js";
|
|
110
108
|
import "./index-e3184f19.js";
|
|
111
|
-
import "@use-gesture/react";
|
|
112
|
-
import "@react-spring/web";
|
|
113
109
|
import "react-dom";
|
|
114
110
|
import "./context-d0fccf11.js";
|
|
115
|
-
import "./UserContext-735db09f.js";
|
|
116
111
|
import "./UserContext-fde5badc.js";
|
|
117
112
|
export {
|
|
118
113
|
A2 as ActionSheet,
|
|
@@ -5,10 +5,23 @@ import { View, PickerView, PickerViewColumn } from "@tarojs/components";
|
|
|
5
5
|
import { P as Popup } from "./popup.taro-e756f3fc.js";
|
|
6
6
|
import { u as useTouch } from "./use-touch-ff43512c.js";
|
|
7
7
|
import { g as getRectByTaro } from "./use-client-rect-f317804e.js";
|
|
8
|
-
import {
|
|
8
|
+
import { c as canUseDom } from "./can-use-dom-0e539bd3.js";
|
|
9
9
|
import { u as useConfig } from "./configprovider.taro-25758d9f.js";
|
|
10
10
|
import { u as usePropsValue } from "./use-props-value-7ac1b1b5.js";
|
|
11
11
|
import { C as ComponentDefaults } from "./typings-11d83a22.js";
|
|
12
|
+
let passiveSupported = false;
|
|
13
|
+
if (canUseDom) {
|
|
14
|
+
try {
|
|
15
|
+
const opts = Object.defineProperty({}, "passive", {
|
|
16
|
+
get() {
|
|
17
|
+
passiveSupported = true;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
window.addEventListener("test-passive-supported", null, opts);
|
|
21
|
+
} catch (e) {
|
|
22
|
+
console.log(e);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
12
25
|
const InternalPickerPanel = (props, ref) => {
|
|
13
26
|
const { keyIndex = 0, defaultValue, options = [], threeDimensional = true, duration = 1e3, itemShow = false, chooseItem } = props;
|
|
14
27
|
const touch = useTouch();
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { C as ComponentDefaults } from "./typings-11d83a22.js";
|
|
3
3
|
const defaultProps = {
|
|
4
|
+
...ComponentDefaults,
|
|
4
5
|
price: 0,
|
|
5
|
-
needSymbol: true,
|
|
6
6
|
symbol: "¥",
|
|
7
|
-
|
|
7
|
+
digits: 2,
|
|
8
8
|
thousands: false,
|
|
9
9
|
position: "before",
|
|
10
10
|
size: "large",
|
|
11
|
-
|
|
11
|
+
line: false
|
|
12
12
|
};
|
|
13
13
|
const Price = (props) => {
|
|
14
|
-
const { price,
|
|
14
|
+
const { price, symbol, digits, thousands, position, size, line, className, style, ...rest } = {
|
|
15
15
|
...defaultProps,
|
|
16
16
|
...props
|
|
17
17
|
};
|
|
18
|
-
const
|
|
18
|
+
const classPrefix = "nut-price";
|
|
19
19
|
const replaceSpecialChar = (url) => {
|
|
20
20
|
url = url.replace(/"/g, '"');
|
|
21
21
|
url = url.replace(/&/g, "&");
|
|
@@ -26,7 +26,7 @@ const Price = (props) => {
|
|
|
26
26
|
return url;
|
|
27
27
|
};
|
|
28
28
|
const showSymbol = () => {
|
|
29
|
-
return { __html:
|
|
29
|
+
return { __html: symbol ? replaceSpecialChar(symbol) : "" };
|
|
30
30
|
};
|
|
31
31
|
const checkPoint = (price2) => {
|
|
32
32
|
return String(price2).indexOf(".") > 0;
|
|
@@ -36,7 +36,7 @@ const Price = (props) => {
|
|
|
36
36
|
num = 0;
|
|
37
37
|
}
|
|
38
38
|
if (checkPoint(num)) {
|
|
39
|
-
num = Number(num).toFixed(
|
|
39
|
+
num = Number(num).toFixed(digits);
|
|
40
40
|
num = typeof num.split(".") === "string" ? num.split(".") : num.split(".")[0];
|
|
41
41
|
} else {
|
|
42
42
|
num = num.toString();
|
|
@@ -51,26 +51,26 @@ const Price = (props) => {
|
|
|
51
51
|
decimalNum = 0;
|
|
52
52
|
}
|
|
53
53
|
if (checkPoint(decimalNum)) {
|
|
54
|
-
decimalNum = Number(decimalNum).toFixed(
|
|
54
|
+
decimalNum = Number(decimalNum).toFixed(digits);
|
|
55
55
|
decimalNum = typeof decimalNum.split(".") === "string" ? 0 : decimalNum.split(".")[1] || 0;
|
|
56
56
|
} else {
|
|
57
57
|
decimalNum = 0;
|
|
58
58
|
}
|
|
59
59
|
const result = `0.${decimalNum}`;
|
|
60
|
-
const resultFixed = Number(result).toFixed(
|
|
60
|
+
const resultFixed = Number(result).toFixed(digits);
|
|
61
61
|
return String(resultFixed).substring(2, resultFixed.length);
|
|
62
62
|
};
|
|
63
63
|
const renderSymbol = () => {
|
|
64
|
-
return React.createElement("div", { className: `${
|
|
64
|
+
return React.createElement("div", { className: `${classPrefix}__symbol ${classPrefix}__symbol-${size}`, dangerouslySetInnerHTML: showSymbol() });
|
|
65
65
|
};
|
|
66
66
|
return React.createElement(
|
|
67
67
|
"div",
|
|
68
|
-
{ className: `${
|
|
69
|
-
|
|
70
|
-
React.createElement("div", { className: `${
|
|
71
|
-
|
|
72
|
-
React.createElement("div", { className: `${
|
|
73
|
-
|
|
68
|
+
{ className: `${classPrefix} ${className} ${line ? `${classPrefix}--line` : ""}`, style, ...rest },
|
|
69
|
+
symbol && position === "before" ? renderSymbol() : null,
|
|
70
|
+
React.createElement("div", { className: `${classPrefix}__integer ${classPrefix}__integer-${size}` }, formatThousands(price)),
|
|
71
|
+
digits !== 0 ? React.createElement("div", { className: `${classPrefix}__decimal ${classPrefix}__decimal-${size}` }, ".") : null,
|
|
72
|
+
React.createElement("div", { className: `${classPrefix}__decimal ${classPrefix}__decimal-${size}` }, formatDecimal(price)),
|
|
73
|
+
symbol && position === "after" ? renderSymbol() : null
|
|
74
74
|
);
|
|
75
75
|
};
|
|
76
76
|
Price.defaultProps = defaultProps;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import React, { useRef, useState } from "react";
|
|
2
|
+
import { View } from "@tarojs/components";
|
|
3
|
+
import { u as useConfig } from "./configprovider.taro-25758d9f.js";
|
|
4
|
+
import { u as useTouch } from "./use-touch-ff43512c.js";
|
|
5
|
+
import { C as ComponentDefaults } from "./typings-11d83a22.js";
|
|
6
|
+
function bound(position, min, max) {
|
|
7
|
+
let ret = position;
|
|
8
|
+
if (min !== void 0) {
|
|
9
|
+
ret = Math.max(position, min);
|
|
10
|
+
}
|
|
11
|
+
if (max !== void 0) {
|
|
12
|
+
ret = Math.min(ret, max);
|
|
13
|
+
}
|
|
14
|
+
return ret;
|
|
15
|
+
}
|
|
16
|
+
function rubberband(distance, dimension, constant) {
|
|
17
|
+
return distance * dimension * constant / (dimension + constant * distance);
|
|
18
|
+
}
|
|
19
|
+
function rubberbandIfOutOfBounds(position, min, max, dimension, constant = 0.15) {
|
|
20
|
+
if (constant === 0)
|
|
21
|
+
return bound(position, min, max);
|
|
22
|
+
if (position < min)
|
|
23
|
+
return -rubberband(min - position, dimension, constant) + min;
|
|
24
|
+
if (position > max)
|
|
25
|
+
return +rubberband(position - max, dimension, constant) + max;
|
|
26
|
+
return position;
|
|
27
|
+
}
|
|
28
|
+
const sleep = (time) => new Promise((resolve) => setTimeout(resolve, time));
|
|
29
|
+
const defaultProps = {
|
|
30
|
+
...ComponentDefaults,
|
|
31
|
+
pullingText: "",
|
|
32
|
+
canReleaseText: "",
|
|
33
|
+
refreshingText: "",
|
|
34
|
+
completeText: "",
|
|
35
|
+
completeDelay: 500,
|
|
36
|
+
disabled: false,
|
|
37
|
+
headHeight: 40,
|
|
38
|
+
threshold: 60,
|
|
39
|
+
scrollTop: 0,
|
|
40
|
+
onRefresh: () => {
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const PullToRefresh = (p) => {
|
|
44
|
+
const classPrefix = "nut-pulltorefresh";
|
|
45
|
+
const { locale } = useConfig();
|
|
46
|
+
const touch = useTouch();
|
|
47
|
+
const props = {
|
|
48
|
+
...defaultProps,
|
|
49
|
+
...p,
|
|
50
|
+
...{
|
|
51
|
+
pullingText: p.pullingText || locale.pullToRefresh.pullingText,
|
|
52
|
+
canReleaseText: p.canReleaseText || locale.pullToRefresh.canReleaseText,
|
|
53
|
+
refreshingText: p.refreshingText || locale.pullToRefresh.refreshingText,
|
|
54
|
+
completeText: p.completeText || locale.pullToRefresh.completeText
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const headHeight = props.headHeight;
|
|
58
|
+
const threshold = props.threshold;
|
|
59
|
+
const heightRef = useRef(0);
|
|
60
|
+
const pullingRef = useRef(false);
|
|
61
|
+
const [status, setStatus] = useState("pulling");
|
|
62
|
+
const renderStatusText = () => {
|
|
63
|
+
var _a;
|
|
64
|
+
if (props.renderText) {
|
|
65
|
+
return (_a = props.renderText) == null ? void 0 : _a.call(props, status);
|
|
66
|
+
}
|
|
67
|
+
if (status === "pulling")
|
|
68
|
+
return props.pullingText;
|
|
69
|
+
if (status === "canRelease")
|
|
70
|
+
return props.canReleaseText;
|
|
71
|
+
if (status === "refreshing")
|
|
72
|
+
return props.refreshingText;
|
|
73
|
+
if (status === "complete")
|
|
74
|
+
return props.completeText;
|
|
75
|
+
return "";
|
|
76
|
+
};
|
|
77
|
+
const handleTouchStart = (e) => {
|
|
78
|
+
touch.start(e);
|
|
79
|
+
};
|
|
80
|
+
const handleTouchMove = (e) => {
|
|
81
|
+
if (props.scrollTop > 0) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (status === "refreshing" || status === "complete")
|
|
85
|
+
return;
|
|
86
|
+
touch.move(e);
|
|
87
|
+
if (touch.isVertical()) {
|
|
88
|
+
pullingRef.current = true;
|
|
89
|
+
heightRef.current = Math.max(rubberbandIfOutOfBounds(touch.deltaY, 0, 0, headHeight * 5, 0.5), 0);
|
|
90
|
+
setStatus(heightRef.current > threshold ? "canRelease" : "pulling");
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
async function doRefresh() {
|
|
94
|
+
heightRef.current = headHeight;
|
|
95
|
+
setStatus("refreshing");
|
|
96
|
+
try {
|
|
97
|
+
await props.onRefresh();
|
|
98
|
+
setStatus("complete");
|
|
99
|
+
} catch (e) {
|
|
100
|
+
heightRef.current = 0;
|
|
101
|
+
setStatus("pulling");
|
|
102
|
+
throw e;
|
|
103
|
+
}
|
|
104
|
+
if (props.completeDelay > 0) {
|
|
105
|
+
await sleep(props.completeDelay);
|
|
106
|
+
}
|
|
107
|
+
heightRef.current = 0;
|
|
108
|
+
setStatus("pulling");
|
|
109
|
+
}
|
|
110
|
+
const handleTouchEnd = () => {
|
|
111
|
+
pullingRef.current = false;
|
|
112
|
+
if (status === "canRelease") {
|
|
113
|
+
doRefresh();
|
|
114
|
+
} else {
|
|
115
|
+
heightRef.current = 0;
|
|
116
|
+
setStatus("pulling");
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
const springStyles = {
|
|
120
|
+
height: `${heightRef.current}px`,
|
|
121
|
+
...!pullingRef.current ? { transition: "height .3s ease" } : {}
|
|
122
|
+
};
|
|
123
|
+
return React.createElement(
|
|
124
|
+
View,
|
|
125
|
+
{ className: `${classPrefix} ${props.className}`, style: props.style, onTouchStart: handleTouchStart, onTouchMove: handleTouchMove, onTouchEnd: handleTouchEnd },
|
|
126
|
+
React.createElement(
|
|
127
|
+
View,
|
|
128
|
+
{ style: springStyles, className: `${classPrefix}-head` },
|
|
129
|
+
React.createElement("div", { className: `${classPrefix}-head-content`, style: { height: headHeight } }, renderStatusText())
|
|
130
|
+
),
|
|
131
|
+
React.createElement("div", { className: `${classPrefix}-content` }, props.children)
|
|
132
|
+
);
|
|
133
|
+
};
|
|
134
|
+
PullToRefresh.defaultProps = defaultProps;
|
|
135
|
+
PullToRefresh.displayName = "NutPullToRefresh";
|
|
136
|
+
export {
|
|
137
|
+
PullToRefresh as P
|
|
138
|
+
};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import React, { useCallback, useContext } from "react";
|
|
2
|
+
import { CheckChecked, CheckNormal } from "@nutui/icons-react-taro";
|
|
3
|
+
import classNames from "classnames";
|
|
4
|
+
import { C as ComponentDefaults } from "./typings-11d83a22.js";
|
|
5
|
+
import { u as usePropsValue } from "./use-props-value-7ac1b1b5.js";
|
|
6
|
+
const RadioContext = React.createContext(null);
|
|
7
|
+
const defaultProps$1 = {
|
|
8
|
+
labelPosition: "right",
|
|
9
|
+
onChange: (value) => {
|
|
10
|
+
},
|
|
11
|
+
direction: "vertical",
|
|
12
|
+
options: []
|
|
13
|
+
};
|
|
14
|
+
const classPrefix = "nut-radiogroup";
|
|
15
|
+
const RadioGroup = React.forwardRef((props, ref) => {
|
|
16
|
+
const { children, className, value, defaultValue, onChange, labelPosition, direction, options, disabled, ...rest } = { ...defaultProps$1, ...props };
|
|
17
|
+
const [val2State, setVal2State] = usePropsValue({
|
|
18
|
+
defaultValue: props.defaultValue,
|
|
19
|
+
value: props.value,
|
|
20
|
+
finalValue: "",
|
|
21
|
+
onChange
|
|
22
|
+
});
|
|
23
|
+
const renderOptionsChildren = useCallback(() => {
|
|
24
|
+
return options == null ? void 0 : options.map(({ label, value: value2, disabled: disabled2, onChange: onChange2, ...rest2 }) => {
|
|
25
|
+
return React.createElement(Radio, { ...rest2, key: value2 == null ? void 0 : value2.toString(), children: label, value: value2, disabled: disabled2, onChange: onChange2, labelPosition, checked: value2 === val2State });
|
|
26
|
+
});
|
|
27
|
+
}, [options]);
|
|
28
|
+
return React.createElement(
|
|
29
|
+
RadioContext.Provider,
|
|
30
|
+
{ value: {
|
|
31
|
+
labelPosition: labelPosition || "right",
|
|
32
|
+
disabled,
|
|
33
|
+
value: val2State,
|
|
34
|
+
check: (value2) => {
|
|
35
|
+
setVal2State(value2);
|
|
36
|
+
},
|
|
37
|
+
uncheck: () => {
|
|
38
|
+
setVal2State("");
|
|
39
|
+
}
|
|
40
|
+
} },
|
|
41
|
+
React.createElement("div", { className: classNames(classPrefix, className, {
|
|
42
|
+
[`${classPrefix}--${props.direction}`]: props.direction
|
|
43
|
+
}), ...rest }, (options == null ? void 0 : options.length) ? renderOptionsChildren() : children)
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
RadioGroup.defaultProps = defaultProps$1;
|
|
47
|
+
RadioGroup.displayName = "NutRadioGroup";
|
|
48
|
+
const defaultProps = {
|
|
49
|
+
...ComponentDefaults,
|
|
50
|
+
disabled: false,
|
|
51
|
+
shape: "round",
|
|
52
|
+
value: "",
|
|
53
|
+
labelPosition: "right",
|
|
54
|
+
icon: null,
|
|
55
|
+
activeIcon: null,
|
|
56
|
+
onChange: (checked) => {
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const Radio = (props) => {
|
|
60
|
+
const classPrefix2 = "nut-radio";
|
|
61
|
+
const { children, className, style, checked, defaultChecked, shape, value, icon, activeIcon, onChange, ...others } = {
|
|
62
|
+
...defaultProps,
|
|
63
|
+
...props
|
|
64
|
+
};
|
|
65
|
+
let { labelPosition, disabled, ...rest } = others;
|
|
66
|
+
let [checkedStatement, setCheckedStatement] = usePropsValue({
|
|
67
|
+
value: checked,
|
|
68
|
+
defaultValue: defaultChecked,
|
|
69
|
+
finalValue: false,
|
|
70
|
+
onChange
|
|
71
|
+
});
|
|
72
|
+
const context = useContext(RadioContext);
|
|
73
|
+
if (context) {
|
|
74
|
+
checkedStatement = context.value === value;
|
|
75
|
+
if (context.labelPosition !== void 0) {
|
|
76
|
+
labelPosition = context.labelPosition;
|
|
77
|
+
}
|
|
78
|
+
if (context.disabled !== void 0) {
|
|
79
|
+
disabled = context.disabled;
|
|
80
|
+
}
|
|
81
|
+
setCheckedStatement = (value2) => {
|
|
82
|
+
if (value2) {
|
|
83
|
+
context.check(props.value === void 0 ? "" : props.value);
|
|
84
|
+
} else {
|
|
85
|
+
context.uncheck();
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const renderLabel = () => {
|
|
90
|
+
return React.createElement("div", { className: classNames(`${classPrefix2}__label`, {
|
|
91
|
+
[`${classPrefix2}__label--disabled`]: disabled
|
|
92
|
+
}) }, children);
|
|
93
|
+
};
|
|
94
|
+
const renderButton = () => {
|
|
95
|
+
return React.createElement("div", { className: classNames(`${classPrefix2}__button`, {
|
|
96
|
+
[`${classPrefix2}__button--active`]: checkedStatement,
|
|
97
|
+
[`${classPrefix2}__button--disabled`]: disabled
|
|
98
|
+
}) }, children);
|
|
99
|
+
};
|
|
100
|
+
const color = () => {
|
|
101
|
+
return {
|
|
102
|
+
[`${classPrefix2}__icon--disable`]: disabled,
|
|
103
|
+
[`${classPrefix2}__icon`]: checkedStatement,
|
|
104
|
+
[`${classPrefix2}__icon--unchecked`]: !checkedStatement
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
const renderIcon = () => {
|
|
108
|
+
const { icon: icon2, activeIcon: activeIcon2 } = props;
|
|
109
|
+
if (checkedStatement) {
|
|
110
|
+
return React.isValidElement(activeIcon2) ? React.cloneElement(activeIcon2, {
|
|
111
|
+
...activeIcon2.props,
|
|
112
|
+
className: classNames(color())
|
|
113
|
+
}) : React.createElement(CheckChecked, { className: classNames(color()) });
|
|
114
|
+
}
|
|
115
|
+
return React.isValidElement(icon2) ? React.cloneElement(icon2, {
|
|
116
|
+
...icon2.props,
|
|
117
|
+
className: classNames(color())
|
|
118
|
+
}) : React.createElement(CheckNormal, { className: classNames(color()) });
|
|
119
|
+
};
|
|
120
|
+
const reverse = labelPosition === "left";
|
|
121
|
+
const renderRadioItem = () => {
|
|
122
|
+
if (shape === "button") {
|
|
123
|
+
return renderButton();
|
|
124
|
+
}
|
|
125
|
+
if (reverse) {
|
|
126
|
+
return React.createElement(
|
|
127
|
+
React.Fragment,
|
|
128
|
+
null,
|
|
129
|
+
renderLabel(),
|
|
130
|
+
renderIcon()
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
return React.createElement(
|
|
134
|
+
React.Fragment,
|
|
135
|
+
null,
|
|
136
|
+
renderIcon(),
|
|
137
|
+
renderLabel()
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
const handleClick = (e) => {
|
|
141
|
+
if (disabled || checkedStatement)
|
|
142
|
+
return;
|
|
143
|
+
setCheckedStatement(!checkedStatement);
|
|
144
|
+
};
|
|
145
|
+
return React.createElement("div", { className: `${classPrefix2} ${className} ${reverse ? `${classPrefix2}--reverse` : ""}`, style, onClick: handleClick, ...rest }, renderRadioItem());
|
|
146
|
+
};
|
|
147
|
+
Radio.defaultProps = defaultProps;
|
|
148
|
+
Radio.displayName = "NutRadio";
|
|
149
|
+
Radio.Group = RadioGroup;
|
|
150
|
+
export {
|
|
151
|
+
Radio as R,
|
|
152
|
+
RadioGroup as a
|
|
153
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useContext } from "react";
|
|
2
2
|
import classNames from "classnames";
|
|
3
|
-
import { D as DataContext } from "./UserContext-
|
|
3
|
+
import { D as DataContext } from "./UserContext-fde5badc.js";
|
|
4
4
|
import { c as cn } from "./bem-cdccae08.js";
|
|
5
5
|
import { C as ComponentDefaults } from "./typings-11d83a22.js";
|
|
6
6
|
const defaultProps = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import classNames from "classnames";
|
|
3
|
-
import { D as DataContext } from "./UserContext-
|
|
3
|
+
import { D as DataContext } from "./UserContext-fde5badc.js";
|
|
4
4
|
import { c as cn } from "./bem-cdccae08.js";
|
|
5
5
|
const defaultProps = {
|
|
6
6
|
current: 0,
|
|
@@ -3,7 +3,7 @@ import classNames from "classnames";
|
|
|
3
3
|
import { getEnv, usePageScroll, getSystemInfoSync } from "@tarojs/taro";
|
|
4
4
|
import { C as ComponentDefaults } from "./typings-11d83a22.js";
|
|
5
5
|
import { g as getRectByTaro } from "./use-client-rect-f317804e.js";
|
|
6
|
-
import {
|
|
6
|
+
import { c as canUseDom } from "./can-use-dom-0e539bd3.js";
|
|
7
7
|
function useWatch(dep, callback, config = { immediate: false }) {
|
|
8
8
|
const { immediate } = config;
|
|
9
9
|
const prev = useRef();
|
|
@@ -27,6 +27,26 @@ function useWatch(dep, callback, config = { immediate: false }) {
|
|
|
27
27
|
stop.current = true;
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
+
const defaultRoot = canUseDom ? window : void 0;
|
|
31
|
+
const overflowStylePatterns = ["scroll", "auto", "overlay"];
|
|
32
|
+
function isElement(node) {
|
|
33
|
+
const ELEMENT_NODE_TYPE = 1;
|
|
34
|
+
return node.nodeType === ELEMENT_NODE_TYPE;
|
|
35
|
+
}
|
|
36
|
+
function getScrollParent(el, root = defaultRoot) {
|
|
37
|
+
let node = el;
|
|
38
|
+
while (node && node !== root && isElement(node)) {
|
|
39
|
+
if (node === document.body) {
|
|
40
|
+
return root;
|
|
41
|
+
}
|
|
42
|
+
const { overflowY } = window.getComputedStyle(node);
|
|
43
|
+
if (overflowStylePatterns.includes(overflowY) && node.scrollHeight > node.clientHeight) {
|
|
44
|
+
return node;
|
|
45
|
+
}
|
|
46
|
+
node = node.parentNode;
|
|
47
|
+
}
|
|
48
|
+
return root;
|
|
49
|
+
}
|
|
30
50
|
const defaultProps = {
|
|
31
51
|
...ComponentDefaults,
|
|
32
52
|
position: "top",
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React, { forwardRef, useState, useRef, Children, useImperativeHandle } from "react";
|
|
2
|
+
import { View, Swiper as Swiper$1, SwiperItem } from "@tarojs/components";
|
|
3
|
+
import classNames from "classnames";
|
|
4
|
+
import { I as Indicator } from "./indicator.taro-edbc71df.js";
|
|
5
|
+
const defaultProps = {
|
|
6
|
+
direction: "horizontal",
|
|
7
|
+
indicator: false,
|
|
8
|
+
autoPlay: false,
|
|
9
|
+
loop: false,
|
|
10
|
+
defaultValue: 0
|
|
11
|
+
};
|
|
12
|
+
const classPrefix = "nut-swiper";
|
|
13
|
+
const Swiper = forwardRef((props, ref) => {
|
|
14
|
+
const { width, height, className, children, indicator, loop, autoPlay, duration, direction, defaultValue, ...rest } = {
|
|
15
|
+
...defaultProps,
|
|
16
|
+
...props
|
|
17
|
+
};
|
|
18
|
+
const [current, setCurrent] = useState(defaultValue);
|
|
19
|
+
const childrenCount = useRef(Children.toArray(children).length);
|
|
20
|
+
const renderIndicator = () => {
|
|
21
|
+
if (React.isValidElement(indicator))
|
|
22
|
+
return indicator;
|
|
23
|
+
if (indicator === true) {
|
|
24
|
+
return React.createElement(
|
|
25
|
+
"div",
|
|
26
|
+
{ className: classNames({
|
|
27
|
+
[`${classPrefix}__pagination`]: true,
|
|
28
|
+
[`${classPrefix}__pagination-vertical`]: direction === "vertical"
|
|
29
|
+
}) },
|
|
30
|
+
React.createElement(Indicator, { current, total: childrenCount.current, direction })
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
};
|
|
35
|
+
const handleOnChange = (value) => {
|
|
36
|
+
setCurrent(value.detail.current);
|
|
37
|
+
};
|
|
38
|
+
useImperativeHandle(ref, () => ({
|
|
39
|
+
to: (value) => {
|
|
40
|
+
setCurrent(value);
|
|
41
|
+
},
|
|
42
|
+
next: () => {
|
|
43
|
+
if (loop) {
|
|
44
|
+
setCurrent((current + 1) % childrenCount.current);
|
|
45
|
+
} else {
|
|
46
|
+
setCurrent(current + 1 >= childrenCount.current ? current : current + 1);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
prev: () => {
|
|
50
|
+
if (loop) {
|
|
51
|
+
let next = current - 1;
|
|
52
|
+
next = next < 0 ? childrenCount.current + next : next;
|
|
53
|
+
setCurrent(next % childrenCount.current);
|
|
54
|
+
} else {
|
|
55
|
+
setCurrent(current - 1 <= 0 ? 0 : current - 1);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}));
|
|
59
|
+
return React.createElement(
|
|
60
|
+
View,
|
|
61
|
+
{ className: classNames(classPrefix, className), style: {
|
|
62
|
+
width: !width ? "100%" : `${width}px`,
|
|
63
|
+
height: !height ? "150px" : `${height}px`
|
|
64
|
+
} },
|
|
65
|
+
React.createElement(
|
|
66
|
+
View,
|
|
67
|
+
{ className: "nut-swiper__inner", style: {
|
|
68
|
+
width: !width ? "100%" : `${width}px`,
|
|
69
|
+
height: !height ? "150px" : `${height}px`
|
|
70
|
+
} },
|
|
71
|
+
React.createElement(Swiper$1, { current, circular: loop, autoplay: autoPlay, vertical: direction === "vertical", indicatorDots: false, onChange: handleOnChange, style: {
|
|
72
|
+
width: !width ? "100%" : `${width}px`,
|
|
73
|
+
height: !height ? "150px" : `${height}px`
|
|
74
|
+
}, ...rest }, Children.toArray(children).map((child, index) => React.createElement(SwiperItem, { key: index }, child)))
|
|
75
|
+
),
|
|
76
|
+
renderIndicator()
|
|
77
|
+
);
|
|
78
|
+
});
|
|
79
|
+
Swiper.defaultProps = defaultProps;
|
|
80
|
+
Swiper.displayName = "NutSwiper";
|
|
81
|
+
export {
|
|
82
|
+
Swiper as S
|
|
83
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
const defaultProps = {
|
|
3
|
+
itemId: "",
|
|
4
|
+
skipHiddenItemLayout: false
|
|
5
|
+
};
|
|
6
|
+
const SwiperItem = (props) => {
|
|
7
|
+
const { children, ...rest } = props;
|
|
8
|
+
return React.createElement(React.Fragment, null, children);
|
|
9
|
+
};
|
|
10
|
+
SwiperItem.defaultProps = defaultProps;
|
|
11
|
+
SwiperItem.displayName = "NutSwiperItem";
|
|
12
|
+
export {
|
|
13
|
+
SwiperItem as S
|
|
14
|
+
};
|
package/dist/locales/base.js
CHANGED
package/dist/locales/en-US.js
CHANGED