@nutui/nutui-react-taro 2.0.0-alpha.7 → 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 +26 -0
- package/dist/esm/Address.js +2 -2
- package/dist/esm/Audio.js +7 -6
- package/dist/esm/Card.js +5 -5
- package/dist/esm/Cascader.js +2 -2
- 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/Range/style/index.js +1 -1
- package/dist/esm/Range.js +5 -7
- package/dist/esm/Sticky.js +1 -2
- package/dist/esm/Swiper.js +3 -5
- package/dist/esm/SwiperItem.js +1 -5
- package/dist/esm/Tabs.js +1 -1
- package/dist/esm/{address.taro-1c534feb.js → address.taro-1a8ab3f1.js} +1 -1
- package/dist/esm/{audio.taro-ec96ef80.js → audio.taro-bbd39f93.js} +2 -2
- package/dist/esm/{card.taro-a46fdf25.js → card.taro-2080f4d2.js} +1 -1
- package/dist/esm/{cascader.taro-0a2694ed.js → cascader.taro-fb7a0230.js} +21 -13
- 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 +20 -25
- 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/range.taro-615e193a.js +259 -0
- 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/esm/{tabs.taro-b75f20ff.js → tabs.taro-66164782.js} +8 -1
- 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 +1634 -6666
- package/dist/nutui.react.umd.js +2047 -7095
- 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/range/range.scss +24 -49
- 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 +61 -61
- package/dist/styles/variables.scss +61 -60
- package/dist/types/index.d.ts +83 -118
- 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/range.taro-52cda918.js +0 -325
- 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
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import React, { useState, useRef, useEffect, useCallback } from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import { View } from "@tarojs/components";
|
|
4
|
+
import { u as useTouch } from "./use-touch-ff43512c.js";
|
|
5
|
+
import { g as getRectByTaro } from "./use-client-rect-f317804e.js";
|
|
6
|
+
import { C as ComponentDefaults } from "./typings-11d83a22.js";
|
|
7
|
+
import { u as usePropsValue } from "./use-props-value-7ac1b1b5.js";
|
|
8
|
+
const defaultProps = {
|
|
9
|
+
...ComponentDefaults,
|
|
10
|
+
range: false,
|
|
11
|
+
min: 0,
|
|
12
|
+
max: 100,
|
|
13
|
+
step: 1,
|
|
14
|
+
vertical: false,
|
|
15
|
+
marks: {}
|
|
16
|
+
};
|
|
17
|
+
const Range = (props) => {
|
|
18
|
+
const { className, range, disabled, button, vertical, marks, onChange, onStart, onEnd, minDescription, maxDescription, currentDescription, min, max, step, value, defaultValue } = { ...defaultProps, ...props };
|
|
19
|
+
const classPrefix = "nut-range";
|
|
20
|
+
const [buttonIndex, setButtonIndex] = useState(0);
|
|
21
|
+
const [dragStatus, setDragStatus] = useState("start");
|
|
22
|
+
const touch = useTouch();
|
|
23
|
+
const root = useRef(null);
|
|
24
|
+
const [marksList, setMarksList] = useState([]);
|
|
25
|
+
const [startValue, setStartValue] = useState(0);
|
|
26
|
+
const handleChange = (value2) => {
|
|
27
|
+
onChange && onChange(value2);
|
|
28
|
+
};
|
|
29
|
+
const [current, setCurrent] = usePropsValue({
|
|
30
|
+
value,
|
|
31
|
+
defaultValue,
|
|
32
|
+
finalValue: 0,
|
|
33
|
+
onChange: handleChange
|
|
34
|
+
});
|
|
35
|
+
const [exactValue, setEaxctValue] = useState(() => value || defaultValue || 0);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (marks) {
|
|
38
|
+
const marksKeys = Object.keys(marks);
|
|
39
|
+
const list = marksKeys.map(parseFloat).sort((a, b) => a - b).filter((point) => point >= min && point <= max);
|
|
40
|
+
setMarksList(list);
|
|
41
|
+
}
|
|
42
|
+
}, [marks]);
|
|
43
|
+
const scope = () => {
|
|
44
|
+
return max - min;
|
|
45
|
+
};
|
|
46
|
+
const classes = classNames(classPrefix, {
|
|
47
|
+
[`${classPrefix}-disabled`]: disabled,
|
|
48
|
+
[`${classPrefix}-vertical`]: vertical
|
|
49
|
+
});
|
|
50
|
+
const containerClasses = classNames(`${classPrefix}-container`, className, {
|
|
51
|
+
[`${classPrefix}-container-vertical`]: vertical
|
|
52
|
+
});
|
|
53
|
+
const markClassName = useCallback((mark) => {
|
|
54
|
+
const classPrefix2 = "nut-range-mark";
|
|
55
|
+
let lowerBound = min;
|
|
56
|
+
let upperBound = max;
|
|
57
|
+
if (range && Array.isArray(current)) {
|
|
58
|
+
lowerBound = current[0];
|
|
59
|
+
upperBound = current[1];
|
|
60
|
+
} else {
|
|
61
|
+
upperBound = current;
|
|
62
|
+
}
|
|
63
|
+
const isActive = mark <= upperBound && mark >= lowerBound;
|
|
64
|
+
return [
|
|
65
|
+
`${classPrefix2}-text`,
|
|
66
|
+
`${isActive ? `${classPrefix2}-text-active` : ""}`
|
|
67
|
+
].join(" ");
|
|
68
|
+
}, [range, current, min, max]);
|
|
69
|
+
const isRange = (val) => {
|
|
70
|
+
return !!range && Array.isArray(val);
|
|
71
|
+
};
|
|
72
|
+
const calcMainAxis = () => {
|
|
73
|
+
const modelVal = current;
|
|
74
|
+
if (isRange(modelVal)) {
|
|
75
|
+
return `${(modelVal[1] - modelVal[0]) * 100 / scope()}%`;
|
|
76
|
+
}
|
|
77
|
+
return `${(modelVal - min) * 100 / scope()}%`;
|
|
78
|
+
};
|
|
79
|
+
const calcOffset = () => {
|
|
80
|
+
const modelVal = current;
|
|
81
|
+
if (isRange(modelVal)) {
|
|
82
|
+
return `${(modelVal[0] - min) * 100 / scope()}%`;
|
|
83
|
+
}
|
|
84
|
+
return `0%`;
|
|
85
|
+
};
|
|
86
|
+
const barStyle = () => {
|
|
87
|
+
if (vertical) {
|
|
88
|
+
return {
|
|
89
|
+
height: calcMainAxis(),
|
|
90
|
+
top: calcOffset(),
|
|
91
|
+
transition: dragStatus ? "none" : void 0
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
width: calcMainAxis(),
|
|
96
|
+
left: calcOffset(),
|
|
97
|
+
transition: dragStatus ? "none" : void 0
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
const marksStyle = (mark) => {
|
|
101
|
+
let style = {
|
|
102
|
+
left: `${(mark - min) / scope() * 100}%`
|
|
103
|
+
};
|
|
104
|
+
if (vertical) {
|
|
105
|
+
style = {
|
|
106
|
+
top: `${(mark - min) / scope() * 100}%`
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
return style;
|
|
110
|
+
};
|
|
111
|
+
const tickClass = (mark) => {
|
|
112
|
+
if (range && Array.isArray(current)) {
|
|
113
|
+
return mark <= current[1] && mark >= current[0];
|
|
114
|
+
}
|
|
115
|
+
return mark <= current;
|
|
116
|
+
};
|
|
117
|
+
const format = (value2) => {
|
|
118
|
+
value2 = Math.max(+min, Math.min(value2, +max));
|
|
119
|
+
return Math.round(value2 / +step) * +step;
|
|
120
|
+
};
|
|
121
|
+
const isSameValue = (newValue, oldValue) => {
|
|
122
|
+
return JSON.stringify(newValue) === JSON.stringify(oldValue);
|
|
123
|
+
};
|
|
124
|
+
const handleOverlap = (value2) => {
|
|
125
|
+
if (value2[0] > value2[1]) {
|
|
126
|
+
return value2.slice(0).reverse();
|
|
127
|
+
}
|
|
128
|
+
return value2;
|
|
129
|
+
};
|
|
130
|
+
const updateValue = (value2, end) => {
|
|
131
|
+
if (isRange(value2)) {
|
|
132
|
+
value2 = handleOverlap(value2).map(format);
|
|
133
|
+
} else {
|
|
134
|
+
value2 = format(value2);
|
|
135
|
+
}
|
|
136
|
+
if (!isSameValue(value2, current)) {
|
|
137
|
+
setCurrent(value2);
|
|
138
|
+
}
|
|
139
|
+
end && onEnd && onEnd(value2);
|
|
140
|
+
};
|
|
141
|
+
const click = async (event) => {
|
|
142
|
+
if (disabled || !root.current) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
setDragStatus("");
|
|
146
|
+
const rect = await getRectByTaro(root.current);
|
|
147
|
+
let delta = (event.detail.x ? event.detail.x : event.clientX) - rect.left;
|
|
148
|
+
let total = rect.width;
|
|
149
|
+
if (vertical) {
|
|
150
|
+
delta = (event.detail.y ? event.detail.y : event.clientY) - rect.top;
|
|
151
|
+
total = rect.height;
|
|
152
|
+
}
|
|
153
|
+
const value2 = min + delta / total * scope();
|
|
154
|
+
setEaxctValue(current);
|
|
155
|
+
if (isRange(current)) {
|
|
156
|
+
const [left, right] = current;
|
|
157
|
+
const middle = (left + right) / 2;
|
|
158
|
+
if (value2 <= middle) {
|
|
159
|
+
updateValue([value2, right], true);
|
|
160
|
+
} else {
|
|
161
|
+
updateValue([left, value2], true);
|
|
162
|
+
}
|
|
163
|
+
} else {
|
|
164
|
+
updateValue(value2, true);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
const onTouchStart = (event) => {
|
|
168
|
+
if (disabled) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
touch.start(event);
|
|
172
|
+
setEaxctValue(current);
|
|
173
|
+
if (isRange(current)) {
|
|
174
|
+
setStartValue(current.map(format));
|
|
175
|
+
} else {
|
|
176
|
+
setStartValue(format(current));
|
|
177
|
+
}
|
|
178
|
+
setDragStatus("start");
|
|
179
|
+
};
|
|
180
|
+
const onTouchMove = async (event) => {
|
|
181
|
+
if (disabled || !root.current) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (dragStatus === "start") {
|
|
185
|
+
onStart && onStart();
|
|
186
|
+
}
|
|
187
|
+
touch.move(event);
|
|
188
|
+
setDragStatus("draging");
|
|
189
|
+
const rect = await getRectByTaro(root.current);
|
|
190
|
+
let delta = touch.deltaX;
|
|
191
|
+
let total = rect.width;
|
|
192
|
+
let diff = delta / total * scope();
|
|
193
|
+
if (vertical) {
|
|
194
|
+
delta = touch.deltaY;
|
|
195
|
+
total = rect.height;
|
|
196
|
+
diff = delta / total * scope();
|
|
197
|
+
}
|
|
198
|
+
let newValue;
|
|
199
|
+
if (isRange(startValue)) {
|
|
200
|
+
newValue = exactValue.slice();
|
|
201
|
+
newValue[buttonIndex] = startValue[buttonIndex] + diff;
|
|
202
|
+
} else {
|
|
203
|
+
newValue = startValue + diff;
|
|
204
|
+
}
|
|
205
|
+
setEaxctValue(newValue);
|
|
206
|
+
updateValue(newValue);
|
|
207
|
+
};
|
|
208
|
+
const onTouchEnd = (event) => {
|
|
209
|
+
if (disabled) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (dragStatus === "draging") {
|
|
213
|
+
updateValue(current, true);
|
|
214
|
+
}
|
|
215
|
+
setDragStatus("");
|
|
216
|
+
};
|
|
217
|
+
const curValue = (idx) => {
|
|
218
|
+
const modelVal = current;
|
|
219
|
+
const value2 = typeof idx === "number" ? modelVal[idx] : modelVal;
|
|
220
|
+
return value2;
|
|
221
|
+
};
|
|
222
|
+
const renderButton = (index) => {
|
|
223
|
+
return React.createElement(React.Fragment, null, button || React.createElement("div", { className: "nut-range-button" }, currentDescription !== null && React.createElement("div", { className: "number" }, currentDescription ? currentDescription(curValue(index)) : curValue(index))));
|
|
224
|
+
};
|
|
225
|
+
return React.createElement(
|
|
226
|
+
"div",
|
|
227
|
+
{ className: containerClasses },
|
|
228
|
+
minDescription !== null && React.createElement("div", { className: "min" }, minDescription || min),
|
|
229
|
+
React.createElement(
|
|
230
|
+
"div",
|
|
231
|
+
{ ref: root, className: classes, onClick: (e) => click(e) },
|
|
232
|
+
marksList.length > 0 && React.createElement("div", { className: "nut-range-mark" }, marksList.map((marks2) => {
|
|
233
|
+
return React.createElement(
|
|
234
|
+
"span",
|
|
235
|
+
{ key: marks2, className: markClassName(marks2), style: marksStyle(marks2) },
|
|
236
|
+
marks2,
|
|
237
|
+
React.createElement("span", { className: classNames("nut-range-tick", {
|
|
238
|
+
active: tickClass(marks2)
|
|
239
|
+
}) })
|
|
240
|
+
);
|
|
241
|
+
})),
|
|
242
|
+
React.createElement("div", { className: "nut-range-bar", style: barStyle() }, range ? [0, 1].map((item, index) => {
|
|
243
|
+
return React.createElement("div", { key: index, className: `${index === 0 ? "nut-range-button-wrapper-left" : ""}
|
|
244
|
+
${index === 1 ? "nut-range-button-wrapper-right" : ""}`, onTouchStart: (e) => {
|
|
245
|
+
if (typeof index === "number") {
|
|
246
|
+
setButtonIndex(index);
|
|
247
|
+
}
|
|
248
|
+
onTouchStart(e);
|
|
249
|
+
}, onTouchMove: (e) => onTouchMove(e), onTouchEnd: (e) => onTouchEnd(), onTouchCancel: (e) => onTouchEnd(), onClick: (e) => e.stopPropagation() }, renderButton(index));
|
|
250
|
+
}) : React.createElement(View, { catchMove: true, className: "nut-range-button-wrapper", onTouchStart: (e) => onTouchStart(e), onTouchMove: (e) => onTouchMove(e), onTouchEnd: (e) => onTouchEnd(), onTouchCancel: (e) => onTouchEnd(), onClick: (e) => e.stopPropagation() }, renderButton()))
|
|
251
|
+
),
|
|
252
|
+
maxDescription !== null && React.createElement("div", { className: "max" }, maxDescription || max)
|
|
253
|
+
);
|
|
254
|
+
};
|
|
255
|
+
Range.defaultProps = defaultProps;
|
|
256
|
+
Range.displayName = "NutRange";
|
|
257
|
+
export {
|
|
258
|
+
Range as R
|
|
259
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -5,6 +5,10 @@ import { JoySmile } from "@nutui/icons-react-taro";
|
|
|
5
5
|
import { C as ComponentDefaults } from "./typings-11d83a22.js";
|
|
6
6
|
import { T as TabPane } from "./tabpane.taro-f8d92ece.js";
|
|
7
7
|
import { u as usePropsValue } from "./use-props-value-7ac1b1b5.js";
|
|
8
|
+
function useForceUpdate() {
|
|
9
|
+
const [, updateState] = React.useState();
|
|
10
|
+
return React.useCallback(() => updateState({}), []);
|
|
11
|
+
}
|
|
8
12
|
const defaultProps = {
|
|
9
13
|
...ComponentDefaults,
|
|
10
14
|
tabStyle: {},
|
|
@@ -46,6 +50,7 @@ const Tabs = (props) => {
|
|
|
46
50
|
return titles2;
|
|
47
51
|
};
|
|
48
52
|
const titles = useRef(getTitles());
|
|
53
|
+
const forceUpdate = useForceUpdate();
|
|
49
54
|
useEffect(() => {
|
|
50
55
|
titles.current = getTitles();
|
|
51
56
|
let current = "";
|
|
@@ -54,8 +59,10 @@ const Tabs = (props) => {
|
|
|
54
59
|
current = value;
|
|
55
60
|
}
|
|
56
61
|
});
|
|
57
|
-
if (current !== "") {
|
|
62
|
+
if (current !== "" && current !== value) {
|
|
58
63
|
setValue(current);
|
|
64
|
+
} else {
|
|
65
|
+
forceUpdate();
|
|
59
66
|
}
|
|
60
67
|
}, [children]);
|
|
61
68
|
const classes = classNames(classPrefix, `${classPrefix}--${direction}`, className);
|
package/dist/locales/base.js
CHANGED
package/dist/locales/en-US.js
CHANGED
package/dist/locales/id-ID.js
CHANGED
package/dist/locales/zh-CN.js
CHANGED
package/dist/locales/zh-TW.js
CHANGED
package/dist/locales/zh-UG.js
CHANGED