@nutui/nutui-react-taro 3.0.12 → 3.0.13-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -9
- package/dist/cjs/packages/input/input.js +3 -0
- package/dist/cjs/packages/lottie/lottiemp.js +7 -6
- package/dist/cjs/packages/swiper/swiper.js +22 -21
- package/dist/cjs/packages/textarea/textarea.d.ts +2 -2
- package/dist/cjs/packages/textarea/textarea.js +27 -8
- package/dist/cjs/types/spec/lottie/taro.d.ts +1 -0
- package/dist/cjs/types/spec/swiper/base.d.ts +4 -0
- package/dist/cjs/types/spec/swiper/taro.d.ts +4 -0
- package/dist/es/packages/input/input.js +3 -0
- package/dist/es/packages/lottie/lottiemp.js +7 -6
- package/dist/es/packages/swiper/swiper.js +23 -22
- package/dist/es/packages/textarea/textarea.d.ts +2 -2
- package/dist/es/packages/textarea/textarea.js +28 -9
- package/dist/es/types/spec/lottie/taro.d.ts +1 -0
- package/dist/es/types/spec/swiper/base.d.ts +5 -1
- package/dist/es/types/spec/swiper/taro.d.ts +4 -0
- package/dist/nutui.react.umd.js +61 -35
- package/dist/style-jmapp.css +1 -1
- package/dist/style-jmapp.scss +40 -40
- package/dist/style-jrkf.css +1 -1
- package/dist/style-jrkf.scss +24 -24
- package/dist/style.css +1 -1
- package/dist/style.scss +29 -29
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
# v3.0.12
|
|
2
|
-
`2025-05-17`
|
|
3
|
-
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
* :sparkles: feat(progress): 兼容并支持taro components的progressProps & v15适配 (#3202)
|
|
7
|
-
* :sparkles: feat(searchbar): v15 适配,增加了受控和默认值 (#3209)
|
|
8
|
-
* :sparkles: feat(steps): v15 (#3216)
|
|
9
|
-
* :bug: fix(uploader): beforeUpload failed to work (#3219)
|
|
10
|
-
* :bug: fix(uploader): 多端上传媒体文件逻辑与2x保持一致 (#3223)
|
|
11
|
-
* :bug: fix(address): 构建单一样式文件 (#3220)
|
|
3
|
+
`2025-05-17`
|
|
12
4
|
|
|
5
|
+
- :sparkles: feat(range): 鸿蒙适配,修订NaN,纵向mark时异常问题 (#3217)
|
|
6
|
+
- :sparkles: feat(progress): 兼容并支持taro components的progressProps & v15适配 (#3202)
|
|
7
|
+
- :sparkles: feat(searchbar): v15 适配,增加了受控和默认值 (#3209)
|
|
8
|
+
- :sparkles: feat(steps): v15 (#3216)
|
|
9
|
+
- :bug: fix(uploader): beforeUpload failed to work (#3219)
|
|
10
|
+
- :bug: fix(uploader): 多端上传媒体文件逻辑与2x保持一致 (#3223)
|
|
11
|
+
- :bug: fix(address): 构建单一样式文件 (#3220)
|
|
13
12
|
|
|
14
13
|
# v3.0.11
|
|
15
14
|
|
|
@@ -88,6 +88,9 @@ var Input = /*#__PURE__*/ (0, _react.forwardRef)(function(props, ref) {
|
|
|
88
88
|
var _inputRef_current;
|
|
89
89
|
(_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.blur();
|
|
90
90
|
},
|
|
91
|
+
get: function get() {
|
|
92
|
+
return inputRef.current;
|
|
93
|
+
},
|
|
91
94
|
get nativeElement () {
|
|
92
95
|
return inputRef.current;
|
|
93
96
|
}
|
|
@@ -20,7 +20,7 @@ var Lottie = /*#__PURE__*/ _react.default.forwardRef(function(props, ref) {
|
|
|
20
20
|
var id = "nutLottie-".concat(uuid);
|
|
21
21
|
var animation = (0, _react.useRef)();
|
|
22
22
|
var inited = (0, _react.useRef)(false);
|
|
23
|
-
var source = props.source, _props_loop = props.loop, loop = _props_loop === void 0 ? true : _props_loop, _props_autoPlay = props.autoPlay, autoPlay = _props_autoPlay === void 0 ? true : _props_autoPlay, onComplete = props.onComplete, style = props.style, _props_speed = props.speed, speed = _props_speed === void 0 ? 1 : _props_speed;
|
|
23
|
+
var source = props.source, _props_loop = props.loop, loop = _props_loop === void 0 ? true : _props_loop, _props_autoPlay = props.autoPlay, autoPlay = _props_autoPlay === void 0 ? true : _props_autoPlay, onComplete = props.onComplete, style = props.style, _props_speed = props.speed, speed = _props_speed === void 0 ? 1 : _props_speed, _props_dpr = props.dpr, dpr = _props_dpr === void 0 ? true : _props_dpr;
|
|
24
24
|
var setSpeed = function setSpeed() {
|
|
25
25
|
if (animation.current) {
|
|
26
26
|
animation.current.setSpeed(Math.abs(speed));
|
|
@@ -30,7 +30,7 @@ var Lottie = /*#__PURE__*/ _react.default.forwardRef(function(props, ref) {
|
|
|
30
30
|
(0, _react.useImperativeHandle)(ref, function() {
|
|
31
31
|
return animation.current || {};
|
|
32
32
|
});
|
|
33
|
-
var
|
|
33
|
+
var pixelRatio = (0, _react.useRef)((0, _getsysteminfo.getWindowInfo)().pixelRatio);
|
|
34
34
|
(0, _taro.useReady)(function() {
|
|
35
35
|
(0, _taro.createSelectorQuery)().select("#".concat(id)).fields({
|
|
36
36
|
node: true,
|
|
@@ -39,11 +39,12 @@ var Lottie = /*#__PURE__*/ _react.default.forwardRef(function(props, ref) {
|
|
|
39
39
|
try {
|
|
40
40
|
var canvas = res.node;
|
|
41
41
|
var context = canvas.getContext('2d');
|
|
42
|
-
// scale canvas to adapt
|
|
42
|
+
// scale canvas to adapt pixelRatio
|
|
43
43
|
if (style && style.width !== undefined && style.height !== undefined) {
|
|
44
|
-
|
|
45
|
-
canvas.
|
|
46
|
-
|
|
44
|
+
var finalDpr = dpr ? pixelRatio.current : 1;
|
|
45
|
+
canvas.width = parseFloat(style.width.toString()) * finalDpr;
|
|
46
|
+
canvas.height = parseFloat(style.height.toString()) * finalDpr;
|
|
47
|
+
context.scale(finalDpr, finalDpr);
|
|
47
48
|
}
|
|
48
49
|
_lottieminiprogram.default.setup(canvas);
|
|
49
50
|
animation.current = _lottieminiprogram.default.loadAnimation({
|
|
@@ -24,27 +24,33 @@ var defaultProps = {
|
|
|
24
24
|
direction: 'horizontal',
|
|
25
25
|
indicator: false,
|
|
26
26
|
autoPlay: false,
|
|
27
|
+
autoplay: false,
|
|
27
28
|
loop: false,
|
|
28
29
|
defaultValue: 0,
|
|
29
30
|
style: {}
|
|
30
31
|
};
|
|
31
32
|
var classPrefix = 'nut-swiper';
|
|
32
33
|
var Swiper = /*#__PURE__*/ _react.default.forwardRef(function(props, ref) {
|
|
33
|
-
var _ref = (0, _object_spread._)({}, defaultProps, props), width = _ref.width, height = _ref.height, className = _ref.className, children = _ref.children, indicator = _ref.indicator, loop = _ref.loop, autoPlay = _ref.autoPlay, duration = _ref.duration, direction = _ref.direction, defaultValue = _ref.defaultValue, onChange = _ref.onChange, style = _ref.style, rest = (0, _object_without_properties._)(_ref, [
|
|
34
|
+
var _ref = (0, _object_spread._)({}, defaultProps, props), width = _ref.width, height = _ref.height, className = _ref.className, children = _ref.children, indicator = _ref.indicator, indicatorDots = _ref.indicatorDots, loop = _ref.loop, circular = _ref.circular, autoPlay = _ref.autoPlay, autoplay = _ref.autoplay, duration = _ref.duration, vertical = _ref.vertical, direction = _ref.direction, defaultValue = _ref.defaultValue, current = _ref.current, onChange = _ref.onChange, style = _ref.style, rest = (0, _object_without_properties._)(_ref, [
|
|
34
35
|
"width",
|
|
35
36
|
"height",
|
|
36
37
|
"className",
|
|
37
38
|
"children",
|
|
38
39
|
"indicator",
|
|
40
|
+
"indicatorDots",
|
|
39
41
|
"loop",
|
|
42
|
+
"circular",
|
|
40
43
|
"autoPlay",
|
|
44
|
+
"autoplay",
|
|
41
45
|
"duration",
|
|
46
|
+
"vertical",
|
|
42
47
|
"direction",
|
|
43
48
|
"defaultValue",
|
|
49
|
+
"current",
|
|
44
50
|
"onChange",
|
|
45
51
|
"style"
|
|
46
52
|
]);
|
|
47
|
-
var _useState = (0, _sliced_to_array._)((0, _react.useState)(defaultValue), 2),
|
|
53
|
+
var _useState = (0, _sliced_to_array._)((0, _react.useState)(current || defaultValue), 2), innerValue = _useState[0], setInnerValue = _useState[1];
|
|
48
54
|
var childrenCount = (0, _react.useMemo)(function() {
|
|
49
55
|
var c = 0;
|
|
50
56
|
_react.default.Children.map(children, function(child, index) {
|
|
@@ -54,47 +60,42 @@ var Swiper = /*#__PURE__*/ _react.default.forwardRef(function(props, ref) {
|
|
|
54
60
|
}, [
|
|
55
61
|
children
|
|
56
62
|
]);
|
|
57
|
-
(0, _react.useEffect)(function() {
|
|
58
|
-
setCurrent(defaultValue);
|
|
59
|
-
}, [
|
|
60
|
-
defaultValue
|
|
61
|
-
]);
|
|
62
63
|
var renderIndicator = function renderIndicator() {
|
|
63
64
|
if (/*#__PURE__*/ _react.default.isValidElement(indicator)) return indicator;
|
|
64
|
-
if (indicator) {
|
|
65
|
+
if (indicator || indicatorDots) {
|
|
65
66
|
var _obj;
|
|
66
67
|
return /*#__PURE__*/ _react.default.createElement(_components.View, {
|
|
67
|
-
className: (0, _classnames.default)((_obj = {}, (0, _define_property._)(_obj, "".concat(classPrefix, "-indicator"), true), (0, _define_property._)(_obj, "".concat(classPrefix, "-indicator-vertical"), direction === 'vertical'), _obj))
|
|
68
|
+
className: (0, _classnames.default)((_obj = {}, (0, _define_property._)(_obj, "".concat(classPrefix, "-indicator"), true), (0, _define_property._)(_obj, "".concat(classPrefix, "-indicator-vertical"), direction === 'vertical' || vertical), _obj))
|
|
68
69
|
}, /*#__PURE__*/ _react.default.createElement(_index.default, {
|
|
69
|
-
current:
|
|
70
|
+
current: innerValue,
|
|
70
71
|
total: childrenCount,
|
|
71
|
-
direction: direction
|
|
72
|
+
direction: vertical ? 'vertical' : direction
|
|
72
73
|
}));
|
|
73
74
|
}
|
|
74
75
|
return null;
|
|
75
76
|
};
|
|
76
77
|
var handleOnChange = function handleOnChange(value) {
|
|
77
|
-
|
|
78
|
+
setInnerValue(value.detail.current);
|
|
78
79
|
};
|
|
79
80
|
(0, _react.useImperativeHandle)(ref, function() {
|
|
80
81
|
return {
|
|
81
82
|
to: function to(value) {
|
|
82
|
-
|
|
83
|
+
setInnerValue(value);
|
|
83
84
|
},
|
|
84
85
|
next: function next() {
|
|
85
86
|
if (loop) {
|
|
86
|
-
|
|
87
|
+
setInnerValue((innerValue + 1) % childrenCount);
|
|
87
88
|
} else {
|
|
88
|
-
|
|
89
|
+
setInnerValue(innerValue + 1 >= childrenCount ? innerValue : innerValue + 1);
|
|
89
90
|
}
|
|
90
91
|
},
|
|
91
92
|
prev: function prev() {
|
|
92
93
|
if (loop) {
|
|
93
|
-
var next =
|
|
94
|
+
var next = innerValue - 1;
|
|
94
95
|
next = next < 0 ? childrenCount + next : next;
|
|
95
|
-
|
|
96
|
+
setInnerValue(next % childrenCount);
|
|
96
97
|
} else {
|
|
97
|
-
|
|
98
|
+
setInnerValue(innerValue - 1 <= 0 ? 0 : innerValue - 1);
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
};
|
|
@@ -112,10 +113,10 @@ var Swiper = /*#__PURE__*/ _react.default.forwardRef(function(props, ref) {
|
|
|
112
113
|
height: !height ? (0, _pxtransform.pxTransform)(150) : height
|
|
113
114
|
}
|
|
114
115
|
}, /*#__PURE__*/ _react.default.createElement(_components.Swiper, (0, _object_spread._)({
|
|
115
|
-
current:
|
|
116
|
+
current: innerValue,
|
|
116
117
|
circular: loop,
|
|
117
|
-
autoplay: autoPlay,
|
|
118
|
-
vertical: direction === 'vertical',
|
|
118
|
+
autoplay: autoplay || autoPlay,
|
|
119
|
+
vertical: direction === 'vertical' || vertical,
|
|
119
120
|
indicatorDots: false,
|
|
120
121
|
onChange: function onChange(e) {
|
|
121
122
|
var _props_onChange;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { TaroTextAreaProps } from "../../types";
|
|
3
|
-
export declare const TextArea:
|
|
3
|
+
export declare const TextArea: React.ForwardRefExoticComponent<Omit<Partial<TaroTextAreaProps>, "ref"> & React.RefAttributes<unknown>>;
|
|
@@ -26,14 +26,13 @@ var defaultProps = (0, _object_spread_props._)((0, _object_spread._)({}, _typing
|
|
|
26
26
|
defaultValue: '',
|
|
27
27
|
showCount: false,
|
|
28
28
|
maxLength: 140,
|
|
29
|
-
placeholder: '',
|
|
30
29
|
readOnly: false,
|
|
31
30
|
disabled: false,
|
|
32
31
|
autoSize: false,
|
|
33
32
|
plain: false,
|
|
34
33
|
status: 'default'
|
|
35
34
|
});
|
|
36
|
-
var TextArea =
|
|
35
|
+
var TextArea = /*#__PURE__*/ (0, _react.forwardRef)(function(props, ref) {
|
|
37
36
|
var locale = (0, _index.useConfig)().locale;
|
|
38
37
|
var _ref = (0, _object_spread._)({}, defaultProps, props), className = _ref.className, value = _ref.value, defaultValue = _ref.defaultValue, showCount = _ref.showCount, maxLength = _ref.maxLength, rows = _ref.rows, placeholder = _ref.placeholder, readOnly = _ref.readOnly, disabled = _ref.disabled, autoSize = _ref.autoSize, style = _ref.style, plain = _ref.plain, status = _ref.status, onChange = _ref.onChange, onBlur = _ref.onBlur, onFocus = _ref.onFocus, rest = (0, _object_without_properties._)(_ref, [
|
|
39
38
|
"className",
|
|
@@ -67,15 +66,16 @@ var TextArea = function TextArea(props) {
|
|
|
67
66
|
defaultValue: defaultValue,
|
|
68
67
|
finalValue: format(defaultValue),
|
|
69
68
|
onChange: onChange
|
|
70
|
-
}), 2),
|
|
69
|
+
}), 2), innerValue = _usePropsValue[0], setInnerValue = _usePropsValue[1];
|
|
70
|
+
var textareaRef = (0, _react.useRef)(null);
|
|
71
71
|
var handleChange = function handleChange(event) {
|
|
72
72
|
var _event_detail;
|
|
73
73
|
var text = event === null || event === void 0 ? void 0 : (_event_detail = event.detail) === null || _event_detail === void 0 ? void 0 : _event_detail.value;
|
|
74
74
|
if (text) {
|
|
75
75
|
var value = compositionRef.current ? text : format(text);
|
|
76
|
-
|
|
76
|
+
setInnerValue(value);
|
|
77
77
|
} else {
|
|
78
|
-
|
|
78
|
+
setInnerValue('');
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
81
|
var isDisabled = function isDisabled() {
|
|
@@ -89,10 +89,29 @@ var TextArea = function TextArea(props) {
|
|
|
89
89
|
if (isDisabled()) return;
|
|
90
90
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
91
91
|
};
|
|
92
|
+
(0, _react.useImperativeHandle)(ref, function() {
|
|
93
|
+
return {
|
|
94
|
+
clear: function clear() {
|
|
95
|
+
setInnerValue('');
|
|
96
|
+
},
|
|
97
|
+
focus: function focus() {
|
|
98
|
+
var _textareaRef_current;
|
|
99
|
+
return (_textareaRef_current = textareaRef.current) === null || _textareaRef_current === void 0 ? void 0 : _textareaRef_current.focus();
|
|
100
|
+
},
|
|
101
|
+
blur: function blur() {
|
|
102
|
+
var _textareaRef_current;
|
|
103
|
+
return (_textareaRef_current = textareaRef.current) === null || _textareaRef_current === void 0 ? void 0 : _textareaRef_current.blur();
|
|
104
|
+
},
|
|
105
|
+
get nativeElement () {
|
|
106
|
+
return textareaRef.current;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
});
|
|
92
110
|
var _obj;
|
|
93
111
|
return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/ _react.default.createElement(_components.View, {
|
|
94
112
|
className: (0, _classnames.default)(classPrefix, (_obj = {}, (0, _define_property._)(_obj, "".concat(classPrefix, "-disabled"), disabled), (0, _define_property._)(_obj, "".concat(classPrefix, "-readonly"), readOnly), (0, _define_property._)(_obj, "".concat(classPrefix, "-rtl"), rtl), (0, _define_property._)(_obj, "".concat(classPrefix, "-plain"), plain), (0, _define_property._)(_obj, "".concat(classPrefix, "-container"), !plain), (0, _define_property._)(_obj, "".concat(classPrefix, "-").concat(status), status), _obj), className)
|
|
95
113
|
}, /*#__PURE__*/ _react.default.createElement(_components.Textarea, (0, _object_spread_props._)((0, _object_spread._)({}, rest), {
|
|
114
|
+
ref: textareaRef,
|
|
96
115
|
nativeProps: {
|
|
97
116
|
style: style,
|
|
98
117
|
readOnly: readOnly,
|
|
@@ -108,7 +127,7 @@ var TextArea = function TextArea(props) {
|
|
|
108
127
|
style: _taro.default.getEnv() === 'WEB' ? undefined : style,
|
|
109
128
|
disabled: _taro.default.getEnv() === 'WEB' ? disabled : disabled || readOnly,
|
|
110
129
|
// @ts-ignore
|
|
111
|
-
value:
|
|
130
|
+
value: innerValue,
|
|
112
131
|
onInput: handleChange,
|
|
113
132
|
onBlur: handleBlur,
|
|
114
133
|
onFocus: handleFocus,
|
|
@@ -117,6 +136,6 @@ var TextArea = function TextArea(props) {
|
|
|
117
136
|
placeholder: placeholder !== undefined ? placeholder : locale.placeholder
|
|
118
137
|
})), showCount && /*#__PURE__*/ _react.default.createElement(_components.View, {
|
|
119
138
|
className: (0, _classnames.default)("".concat(classPrefix, "-limit"), (0, _define_property._)({}, "".concat(classPrefix, "-limit-disabled"), disabled))
|
|
120
|
-
},
|
|
121
|
-
};
|
|
139
|
+
}, innerValue.length, "/", maxLength < 0 ? 0 : maxLength)));
|
|
140
|
+
});
|
|
122
141
|
TextArea.displayName = 'NutTextArea';
|
|
@@ -15,7 +15,11 @@ export interface BaseSwiper extends BaseProps {
|
|
|
15
15
|
indicator: ReactNode;
|
|
16
16
|
loop: boolean;
|
|
17
17
|
duration: SimpleValue;
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated Please use `autoplay` prop instead.
|
|
20
|
+
*/
|
|
18
21
|
autoPlay: boolean | number;
|
|
22
|
+
autoplay: boolean | number;
|
|
19
23
|
defaultValue: number;
|
|
20
24
|
touchable: boolean;
|
|
21
25
|
effect: FocusEffect | undefined;
|
|
@@ -9,7 +9,11 @@ export type TaroSwiperProps = Omit<BaseSwiper, OmittedKeys> & OmittedSwiperProps
|
|
|
9
9
|
height?: SimpleValue;
|
|
10
10
|
direction: Direction;
|
|
11
11
|
indicator: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Please use `autoplay` prop instead.
|
|
14
|
+
*/
|
|
12
15
|
autoPlay: boolean;
|
|
16
|
+
autoplay: boolean;
|
|
13
17
|
loop: boolean;
|
|
14
18
|
defaultValue: number;
|
|
15
19
|
};
|
|
@@ -77,6 +77,9 @@ export var Input = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
77
77
|
var _inputRef_current;
|
|
78
78
|
(_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.blur();
|
|
79
79
|
},
|
|
80
|
+
get: function() {
|
|
81
|
+
return inputRef.current;
|
|
82
|
+
},
|
|
80
83
|
get nativeElement () {
|
|
81
84
|
return inputRef.current;
|
|
82
85
|
}
|
|
@@ -8,7 +8,7 @@ export var Lottie = /*#__PURE__*/ React.forwardRef(function(props, ref) {
|
|
|
8
8
|
var id = "nutLottie-".concat(uuid);
|
|
9
9
|
var animation = useRef();
|
|
10
10
|
var inited = useRef(false);
|
|
11
|
-
var source = props.source, _props_loop = props.loop, loop = _props_loop === void 0 ? true : _props_loop, _props_autoPlay = props.autoPlay, autoPlay = _props_autoPlay === void 0 ? true : _props_autoPlay, onComplete = props.onComplete, style = props.style, _props_speed = props.speed, speed = _props_speed === void 0 ? 1 : _props_speed;
|
|
11
|
+
var source = props.source, _props_loop = props.loop, loop = _props_loop === void 0 ? true : _props_loop, _props_autoPlay = props.autoPlay, autoPlay = _props_autoPlay === void 0 ? true : _props_autoPlay, onComplete = props.onComplete, style = props.style, _props_speed = props.speed, speed = _props_speed === void 0 ? 1 : _props_speed, _props_dpr = props.dpr, dpr = _props_dpr === void 0 ? true : _props_dpr;
|
|
12
12
|
var setSpeed = function() {
|
|
13
13
|
if (animation.current) {
|
|
14
14
|
animation.current.setSpeed(Math.abs(speed));
|
|
@@ -18,7 +18,7 @@ export var Lottie = /*#__PURE__*/ React.forwardRef(function(props, ref) {
|
|
|
18
18
|
useImperativeHandle(ref, function() {
|
|
19
19
|
return animation.current || {};
|
|
20
20
|
});
|
|
21
|
-
var
|
|
21
|
+
var pixelRatio = useRef(getWindowInfo().pixelRatio);
|
|
22
22
|
useReady(function() {
|
|
23
23
|
createSelectorQuery().select("#".concat(id)).fields({
|
|
24
24
|
node: true,
|
|
@@ -27,11 +27,12 @@ export var Lottie = /*#__PURE__*/ React.forwardRef(function(props, ref) {
|
|
|
27
27
|
try {
|
|
28
28
|
var canvas = res.node;
|
|
29
29
|
var context = canvas.getContext('2d');
|
|
30
|
-
// scale canvas to adapt
|
|
30
|
+
// scale canvas to adapt pixelRatio
|
|
31
31
|
if (style && style.width !== undefined && style.height !== undefined) {
|
|
32
|
-
|
|
33
|
-
canvas.
|
|
34
|
-
|
|
32
|
+
var finalDpr = dpr ? pixelRatio.current : 1;
|
|
33
|
+
canvas.width = parseFloat(style.width.toString()) * finalDpr;
|
|
34
|
+
canvas.height = parseFloat(style.height.toString()) * finalDpr;
|
|
35
|
+
context.scale(finalDpr, finalDpr);
|
|
35
36
|
}
|
|
36
37
|
lottie.setup(canvas);
|
|
37
38
|
animation.current = lottie.loadAnimation({
|
|
@@ -3,7 +3,7 @@ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
|
3
3
|
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
4
4
|
import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties";
|
|
5
5
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
6
|
-
import React, { Children,
|
|
6
|
+
import React, { Children, useImperativeHandle, useMemo, useState } from "react";
|
|
7
7
|
import { Swiper as TaroSwiper, SwiperItem as TSwiperItem, View } from "@tarojs/components";
|
|
8
8
|
import classNames from "classnames";
|
|
9
9
|
import Indicator from "../indicator/index";
|
|
@@ -12,27 +12,33 @@ var defaultProps = {
|
|
|
12
12
|
direction: 'horizontal',
|
|
13
13
|
indicator: false,
|
|
14
14
|
autoPlay: false,
|
|
15
|
+
autoplay: false,
|
|
15
16
|
loop: false,
|
|
16
17
|
defaultValue: 0,
|
|
17
18
|
style: {}
|
|
18
19
|
};
|
|
19
20
|
var classPrefix = 'nut-swiper';
|
|
20
21
|
export var Swiper = /*#__PURE__*/ React.forwardRef(function(props, ref) {
|
|
21
|
-
var _ref = _object_spread({}, defaultProps, props), width = _ref.width, height = _ref.height, className = _ref.className, children = _ref.children, indicator = _ref.indicator, loop = _ref.loop, autoPlay = _ref.autoPlay, duration = _ref.duration, direction = _ref.direction, defaultValue = _ref.defaultValue, onChange = _ref.onChange, style = _ref.style, rest = _object_without_properties(_ref, [
|
|
22
|
+
var _ref = _object_spread({}, defaultProps, props), width = _ref.width, height = _ref.height, className = _ref.className, children = _ref.children, indicator = _ref.indicator, indicatorDots = _ref.indicatorDots, loop = _ref.loop, circular = _ref.circular, autoPlay = _ref.autoPlay, autoplay = _ref.autoplay, duration = _ref.duration, vertical = _ref.vertical, direction = _ref.direction, defaultValue = _ref.defaultValue, current = _ref.current, onChange = _ref.onChange, style = _ref.style, rest = _object_without_properties(_ref, [
|
|
22
23
|
"width",
|
|
23
24
|
"height",
|
|
24
25
|
"className",
|
|
25
26
|
"children",
|
|
26
27
|
"indicator",
|
|
28
|
+
"indicatorDots",
|
|
27
29
|
"loop",
|
|
30
|
+
"circular",
|
|
28
31
|
"autoPlay",
|
|
32
|
+
"autoplay",
|
|
29
33
|
"duration",
|
|
34
|
+
"vertical",
|
|
30
35
|
"direction",
|
|
31
36
|
"defaultValue",
|
|
37
|
+
"current",
|
|
32
38
|
"onChange",
|
|
33
39
|
"style"
|
|
34
40
|
]);
|
|
35
|
-
var _useState = _sliced_to_array(useState(defaultValue), 2),
|
|
41
|
+
var _useState = _sliced_to_array(useState(current || defaultValue), 2), innerValue = _useState[0], setInnerValue = _useState[1];
|
|
36
42
|
var childrenCount = useMemo(function() {
|
|
37
43
|
var c = 0;
|
|
38
44
|
React.Children.map(children, function(child, index) {
|
|
@@ -42,47 +48,42 @@ export var Swiper = /*#__PURE__*/ React.forwardRef(function(props, ref) {
|
|
|
42
48
|
}, [
|
|
43
49
|
children
|
|
44
50
|
]);
|
|
45
|
-
useEffect(function() {
|
|
46
|
-
setCurrent(defaultValue);
|
|
47
|
-
}, [
|
|
48
|
-
defaultValue
|
|
49
|
-
]);
|
|
50
51
|
var renderIndicator = function() {
|
|
51
52
|
if (/*#__PURE__*/ React.isValidElement(indicator)) return indicator;
|
|
52
|
-
if (indicator) {
|
|
53
|
+
if (indicator || indicatorDots) {
|
|
53
54
|
var _obj;
|
|
54
55
|
return /*#__PURE__*/ React.createElement(View, {
|
|
55
|
-
className: classNames((_obj = {}, _define_property(_obj, "".concat(classPrefix, "-indicator"), true), _define_property(_obj, "".concat(classPrefix, "-indicator-vertical"), direction === 'vertical'), _obj))
|
|
56
|
+
className: classNames((_obj = {}, _define_property(_obj, "".concat(classPrefix, "-indicator"), true), _define_property(_obj, "".concat(classPrefix, "-indicator-vertical"), direction === 'vertical' || vertical), _obj))
|
|
56
57
|
}, /*#__PURE__*/ React.createElement(Indicator, {
|
|
57
|
-
current:
|
|
58
|
+
current: innerValue,
|
|
58
59
|
total: childrenCount,
|
|
59
|
-
direction: direction
|
|
60
|
+
direction: vertical ? 'vertical' : direction
|
|
60
61
|
}));
|
|
61
62
|
}
|
|
62
63
|
return null;
|
|
63
64
|
};
|
|
64
65
|
var handleOnChange = function(value) {
|
|
65
|
-
|
|
66
|
+
setInnerValue(value.detail.current);
|
|
66
67
|
};
|
|
67
68
|
useImperativeHandle(ref, function() {
|
|
68
69
|
return {
|
|
69
70
|
to: function(value) {
|
|
70
|
-
|
|
71
|
+
setInnerValue(value);
|
|
71
72
|
},
|
|
72
73
|
next: function() {
|
|
73
74
|
if (loop) {
|
|
74
|
-
|
|
75
|
+
setInnerValue((innerValue + 1) % childrenCount);
|
|
75
76
|
} else {
|
|
76
|
-
|
|
77
|
+
setInnerValue(innerValue + 1 >= childrenCount ? innerValue : innerValue + 1);
|
|
77
78
|
}
|
|
78
79
|
},
|
|
79
80
|
prev: function() {
|
|
80
81
|
if (loop) {
|
|
81
|
-
var next =
|
|
82
|
+
var next = innerValue - 1;
|
|
82
83
|
next = next < 0 ? childrenCount + next : next;
|
|
83
|
-
|
|
84
|
+
setInnerValue(next % childrenCount);
|
|
84
85
|
} else {
|
|
85
|
-
|
|
86
|
+
setInnerValue(innerValue - 1 <= 0 ? 0 : innerValue - 1);
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
89
|
};
|
|
@@ -100,10 +101,10 @@ export var Swiper = /*#__PURE__*/ React.forwardRef(function(props, ref) {
|
|
|
100
101
|
height: !height ? pxTransform(150) : height
|
|
101
102
|
}
|
|
102
103
|
}, /*#__PURE__*/ React.createElement(TaroSwiper, _object_spread({
|
|
103
|
-
current:
|
|
104
|
+
current: innerValue,
|
|
104
105
|
circular: loop,
|
|
105
|
-
autoplay: autoPlay,
|
|
106
|
-
vertical: direction === 'vertical',
|
|
106
|
+
autoplay: autoplay || autoPlay,
|
|
107
|
+
vertical: direction === 'vertical' || vertical,
|
|
107
108
|
indicatorDots: false,
|
|
108
109
|
onChange: function(e) {
|
|
109
110
|
var _props_onChange;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { TaroTextAreaProps } from "../../types";
|
|
3
|
-
export declare const TextArea:
|
|
3
|
+
export declare const TextArea: React.ForwardRefExoticComponent<Omit<Partial<TaroTextAreaProps>, "ref"> & React.RefAttributes<unknown>>;
|
|
@@ -3,7 +3,7 @@ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
|
3
3
|
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
4
4
|
import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties";
|
|
5
5
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
6
|
-
import React, { useRef } from "react";
|
|
6
|
+
import React, { forwardRef, useRef, useImperativeHandle } from "react";
|
|
7
7
|
import classNames from "classnames";
|
|
8
8
|
import Taro from "@tarojs/taro";
|
|
9
9
|
import { Textarea, View } from "@tarojs/components";
|
|
@@ -14,14 +14,13 @@ var defaultProps = _object_spread_props(_object_spread({}, ComponentDefaults), {
|
|
|
14
14
|
defaultValue: '',
|
|
15
15
|
showCount: false,
|
|
16
16
|
maxLength: 140,
|
|
17
|
-
placeholder: '',
|
|
18
17
|
readOnly: false,
|
|
19
18
|
disabled: false,
|
|
20
19
|
autoSize: false,
|
|
21
20
|
plain: false,
|
|
22
21
|
status: 'default'
|
|
23
22
|
});
|
|
24
|
-
export var TextArea = function(props) {
|
|
23
|
+
export var TextArea = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
25
24
|
var locale = useConfig().locale;
|
|
26
25
|
var _ref = _object_spread({}, defaultProps, props), className = _ref.className, value = _ref.value, defaultValue = _ref.defaultValue, showCount = _ref.showCount, maxLength = _ref.maxLength, rows = _ref.rows, placeholder = _ref.placeholder, readOnly = _ref.readOnly, disabled = _ref.disabled, autoSize = _ref.autoSize, style = _ref.style, plain = _ref.plain, status = _ref.status, onChange = _ref.onChange, onBlur = _ref.onBlur, onFocus = _ref.onFocus, rest = _object_without_properties(_ref, [
|
|
27
26
|
"className",
|
|
@@ -55,15 +54,16 @@ export var TextArea = function(props) {
|
|
|
55
54
|
defaultValue: defaultValue,
|
|
56
55
|
finalValue: format(defaultValue),
|
|
57
56
|
onChange: onChange
|
|
58
|
-
}), 2),
|
|
57
|
+
}), 2), innerValue = _usePropsValue[0], setInnerValue = _usePropsValue[1];
|
|
58
|
+
var textareaRef = useRef(null);
|
|
59
59
|
var handleChange = function(event) {
|
|
60
60
|
var _event_detail;
|
|
61
61
|
var text = event === null || event === void 0 ? void 0 : (_event_detail = event.detail) === null || _event_detail === void 0 ? void 0 : _event_detail.value;
|
|
62
62
|
if (text) {
|
|
63
63
|
var value = compositionRef.current ? text : format(text);
|
|
64
|
-
|
|
64
|
+
setInnerValue(value);
|
|
65
65
|
} else {
|
|
66
|
-
|
|
66
|
+
setInnerValue('');
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
69
|
var isDisabled = function() {
|
|
@@ -77,10 +77,29 @@ export var TextArea = function(props) {
|
|
|
77
77
|
if (isDisabled()) return;
|
|
78
78
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
79
79
|
};
|
|
80
|
+
useImperativeHandle(ref, function() {
|
|
81
|
+
return {
|
|
82
|
+
clear: function() {
|
|
83
|
+
setInnerValue('');
|
|
84
|
+
},
|
|
85
|
+
focus: function() {
|
|
86
|
+
var _textareaRef_current;
|
|
87
|
+
return (_textareaRef_current = textareaRef.current) === null || _textareaRef_current === void 0 ? void 0 : _textareaRef_current.focus();
|
|
88
|
+
},
|
|
89
|
+
blur: function() {
|
|
90
|
+
var _textareaRef_current;
|
|
91
|
+
return (_textareaRef_current = textareaRef.current) === null || _textareaRef_current === void 0 ? void 0 : _textareaRef_current.blur();
|
|
92
|
+
},
|
|
93
|
+
get nativeElement () {
|
|
94
|
+
return textareaRef.current;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
});
|
|
80
98
|
var _obj;
|
|
81
99
|
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(View, {
|
|
82
100
|
className: classNames(classPrefix, (_obj = {}, _define_property(_obj, "".concat(classPrefix, "-disabled"), disabled), _define_property(_obj, "".concat(classPrefix, "-readonly"), readOnly), _define_property(_obj, "".concat(classPrefix, "-rtl"), rtl), _define_property(_obj, "".concat(classPrefix, "-plain"), plain), _define_property(_obj, "".concat(classPrefix, "-container"), !plain), _define_property(_obj, "".concat(classPrefix, "-").concat(status), status), _obj), className)
|
|
83
101
|
}, /*#__PURE__*/ React.createElement(Textarea, _object_spread_props(_object_spread({}, rest), {
|
|
102
|
+
ref: textareaRef,
|
|
84
103
|
nativeProps: {
|
|
85
104
|
style: style,
|
|
86
105
|
readOnly: readOnly,
|
|
@@ -96,7 +115,7 @@ export var TextArea = function(props) {
|
|
|
96
115
|
style: Taro.getEnv() === 'WEB' ? undefined : style,
|
|
97
116
|
disabled: Taro.getEnv() === 'WEB' ? disabled : disabled || readOnly,
|
|
98
117
|
// @ts-ignore
|
|
99
|
-
value:
|
|
118
|
+
value: innerValue,
|
|
100
119
|
onInput: handleChange,
|
|
101
120
|
onBlur: handleBlur,
|
|
102
121
|
onFocus: handleFocus,
|
|
@@ -105,6 +124,6 @@ export var TextArea = function(props) {
|
|
|
105
124
|
placeholder: placeholder !== undefined ? placeholder : locale.placeholder
|
|
106
125
|
})), showCount && /*#__PURE__*/ React.createElement(View, {
|
|
107
126
|
className: classNames("".concat(classPrefix, "-limit"), _define_property({}, "".concat(classPrefix, "-limit-disabled"), disabled))
|
|
108
|
-
},
|
|
109
|
-
};
|
|
127
|
+
}, innerValue.length, "/", maxLength < 0 ? 0 : maxLength)));
|
|
128
|
+
});
|
|
110
129
|
TextArea.displayName = 'NutTextArea';
|
|
@@ -24,10 +24,14 @@ export interface BaseSwiper extends BaseProps {
|
|
|
24
24
|
*/
|
|
25
25
|
loop: boolean
|
|
26
26
|
duration: SimpleValue;
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated Please use `autoplay` prop instead.
|
|
29
|
+
*/
|
|
30
|
+
autoPlay: boolean | number;
|
|
27
31
|
/**
|
|
28
32
|
* 自动轮播
|
|
29
33
|
*/
|
|
30
|
-
|
|
34
|
+
autoplay: boolean | number
|
|
31
35
|
/**
|
|
32
36
|
* 初始化索引值
|
|
33
37
|
*/
|
|
@@ -9,7 +9,11 @@ export type TaroSwiperProps = Omit<BaseSwiper, OmittedKeys> & OmittedSwiperProps
|
|
|
9
9
|
height?: SimpleValue;
|
|
10
10
|
direction: Direction;
|
|
11
11
|
indicator: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Please use `autoplay` prop instead.
|
|
14
|
+
*/
|
|
12
15
|
autoPlay: boolean;
|
|
16
|
+
autoplay: boolean;
|
|
13
17
|
loop: boolean;
|
|
14
18
|
defaultValue: number;
|
|
15
19
|
};
|