@nutui/nutui-react 2.6.14 → 2.6.16
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 +931 -909
- package/README.md +21 -28
- package/dist/esm/Audio.js +10 -11
- package/dist/esm/CalendarItem.js +3 -1
- package/dist/esm/CheckboxGroup.js +4 -5
- package/dist/esm/DatePicker.js +3 -4
- package/dist/esm/Dialog.js +1 -2
- package/dist/esm/InputNumber.js +26 -9
- package/dist/esm/Menu.js +11 -4
- package/dist/esm/NumberKeyboard.js +38 -27
- package/dist/esm/PullToRefresh.js +0 -1
- package/dist/esm/RadioGroup.js +0 -1
- package/dist/esm/Sticky.js +24 -30
- package/dist/esm/Swipe.js +0 -1
- package/dist/esm/Swiper.js +0 -1
- package/dist/esm/SwiperItem.js +0 -1
- package/dist/esm/Table.js +6 -5
- package/dist/esm/Uploader/style/style.css +1 -1
- package/dist/esm/Uploader.js +12 -11
- package/dist/esm/WaterMark.js +3 -3
- package/dist/esm/formitem2.js +2 -2
- package/dist/esm/menuitem2.js +1 -1
- package/dist/esm/radio2.js +0 -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/tr-TR.js +1 -1
- package/dist/locales/zh-CN.js +1 -1
- package/dist/locales/zh-TW.js +1 -1
- package/dist/locales/zh-UG.js +1 -1
- package/dist/nutui.react.es.js +257 -224
- package/dist/nutui.react.umd.js +257 -224
- package/dist/packages/uploader/uploader.scss +3 -1
- package/dist/style.css +1 -1
- package/dist/types/packages/cell/cell.d.ts +2 -2
- package/dist/types/packages/cell/cell.taro.d.ts +1 -1
- package/dist/types/packages/formitem/formitem.d.ts +5 -0
- package/dist/types/packages/formitem/formitem.taro.d.ts +1 -0
- package/dist/types/packages/inputnumber/inputnumber.d.ts +1 -1
- package/dist/types/packages/inputnumber/inputnumber.taro.d.ts +1 -1
- package/dist/types/packages/menuitem/menuitem.d.ts +5 -0
- package/dist/types/packages/menuitem/menuitem.taro.d.ts +1 -0
- package/dist/types/packages/swiper/swiper.taro.d.ts +2 -1
- package/dist/types/packages/swiperitem/swiperitem.d.ts +0 -1
- package/dist/types/packages/watermark/watermark.d.ts +10 -0
- package/dist/types/packages/watermark/watermark.taro.d.ts +2 -0
- package/dist/types/utils/get-scroll-parent.d.ts +1 -1
- package/dist/types/utils/use-client-rect.d.ts +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
<p align="center">
|
|
3
2
|
<img alt="logo" src="https://img11.360buyimg.com/imagetools/jfs/t1/211965/25/7152/22022/61b16785E433119bb/aa41d7a9f7e823f3.png" width="150" style="margin-bottom: 10px;">
|
|
4
3
|
</p>
|
|
@@ -36,27 +35,26 @@
|
|
|
36
35
|
|
|
37
36
|
---
|
|
38
37
|
|
|
39
|
-
> Nut[nʌt]: the one Squirrel Scrat pursues resolutely for a lifetime and will never let go even if it causes a catastrophe from the animated film
|
|
38
|
+
> Nut[nʌt]: the one Squirrel Scrat pursues resolutely for a lifetime and will never let go even if it causes a catastrophe from the animated film **_Ice Age_**.
|
|
40
39
|
|
|
41
40
|
[简体中文](./README_ZH.md) | English
|
|
42
41
|
|
|
43
42
|
## Features
|
|
44
43
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
- 🚀 70+ High Quality Components
|
|
45
|
+
- 📖 Based on JD APP 11.0 Visual Specifications
|
|
46
|
+
- 🍭 Support Tree Shaking
|
|
47
|
+
- 📖 Extensive Documentation and Demos
|
|
48
|
+
- 💪 Written in TypeScript
|
|
49
|
+
- 💪 Support SSR (Experimental)
|
|
50
|
+
- 🍭 Support Custom Themes
|
|
51
|
+
- 🍭 90%+ Unit Test Coverage
|
|
52
|
+
- 📖 Provide Sketch Design Resources
|
|
56
53
|
|
|
57
54
|
## Running locally
|
|
58
55
|
|
|
59
56
|
### running with H5
|
|
57
|
+
|
|
60
58
|
```sh
|
|
61
59
|
# Clone repository
|
|
62
60
|
git clone https://github.com/jdf2e/nutui-react.git
|
|
@@ -72,7 +70,9 @@ pnpm run dev
|
|
|
72
70
|
|
|
73
71
|
# visit in browser: http:http://localhost:3000 (you don't have to open it manually if you've run it in the browser again)
|
|
74
72
|
```
|
|
73
|
+
|
|
75
74
|
### running with mini-program
|
|
75
|
+
|
|
76
76
|
```sh
|
|
77
77
|
# Clone repository
|
|
78
78
|
git clone https://github.com/jdf2e/nutui-react.git
|
|
@@ -96,12 +96,11 @@ pnpm run dev:taro:jd
|
|
|
96
96
|
|
|
97
97
|
> If you are using AMD environment or build tools such as Webpack, Vite, etc., we recommend using the `es` version. If it is a non-module environment (such as direct reference through the `<script>` tag), it is recommended to use the `umd` compressed version.
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
* umd **nutui.umd.js**
|
|
99
|
+
- es **nutui.es.js**
|
|
102
100
|
|
|
101
|
+
- umd **nutui.umd.js**
|
|
103
102
|
|
|
104
|
-
##
|
|
103
|
+
## Links
|
|
105
104
|
|
|
106
105
|
<ul>
|
|
107
106
|
<li>
|
|
@@ -126,33 +125,30 @@ pnpm run dev:taro:jd
|
|
|
126
125
|
</li>
|
|
127
126
|
</ul>
|
|
128
127
|
|
|
129
|
-
|
|
130
128
|
## Communication
|
|
131
129
|
|
|
132
130
|
| Version | WeChat Group | JD Dongdong Group |
|
|
133
|
-
| --- | ---
|
|
131
|
+
| --- | --- | --- |
|
|
134
132
|
| [NutUI React](https://github.com/jdf2e/nutui-react/issues) | <img src="https://storage.360buyimg.com/imgtools/17c67beff6-4acf07c0-609c-11ed-a6ef-69df15b605e4.png" width="100" /> Reply 「NutUI-React」 after following | 1025679314 |
|
|
135
133
|
| [NutUI x Taro](https://github.com/jdf2e/nutui/issues) | <img src="https://camo.githubusercontent.com/db4276b4ee4b443158195e943e9e678cb4d2afb7580f70d4d817ef0a90413aec/687474703a2f2f73746f726167652e333630627579696d672e636f6d2f7461726f2d6a642d636f6d2f7374617469632f636f6e746163745f7461726f5f6e757475695f71722e706e67" width="100" />Reply 「NutUI-React」 after following | 1022545110 |
|
|
136
134
|
|
|
137
|
-
|
|
138
135
|
## Join Us
|
|
139
136
|
|
|
140
137
|
#### NutUI Community
|
|
141
138
|
|
|
142
|
-
[
|
|
139
|
+
[_Welcome To NutUI-React Community_](https://github.com/jdf2e/nutui-react/discussions/348)
|
|
143
140
|
|
|
144
141
|
#### Contribute to NutUI
|
|
145
142
|
|
|
146
143
|
There are some choices of contributing to NutUI as follows, solving issues, fixing bugs, adding new components, i18n, UI customization, platform and cross-end adaptation, etc.
|
|
147
144
|
|
|
148
|
-
You are very welcome to contribute code to NutUI. Before your pull requests, please read [
|
|
149
|
-
|
|
145
|
+
You are very welcome to contribute code to NutUI. Before your pull requests, please read [_NutUI Developer Contributing Guide_](https://github.com/jdf2e/nutui-react/discussions/348)。
|
|
150
146
|
|
|
151
147
|
## Issue & Discussion
|
|
152
148
|
|
|
153
149
|
[Report issues to NutUI](https://nutui.jd.com/nutui-issue-helper/?repo=jdf2e/nutui-react&lang=zh-cn)
|
|
154
150
|
|
|
155
|
-
> It is highly recommended to read [*How To Ask Questions The Smart Way*](https://github.com/ryanhanwu/, [
|
|
151
|
+
> It is highly recommended to read [*How To Ask Questions The Smart Way*](https://github.com/ryanhanwu/, [_How To Ask Questions Of GitHub Community_](https://github.com/seajs/seajs/issues/545) and [_How to Report Bugs Effectively_](https://www.chiark.greenend.org.uk/~sgtatham/bugs.html), then you can get understanding and help more easily.
|
|
156
152
|
|
|
157
153
|
[NutUI Discussion](https://github.com/jdf2e/nutui-react/discussions)
|
|
158
154
|
|
|
@@ -162,13 +158,11 @@ If you have any ideas, questions or suggestions, you can share your opinions her
|
|
|
162
158
|
|
|
163
159
|
Thanks to all the following [developers](https://github.com/jdf2e/nutui-react/graphs/contributors)。 who have contributed code to NutUI.
|
|
164
160
|
|
|
165
|
-
|
|
166
161
|
<a href="https://github.com/jdf2e/nutui-react/graphs/contributors">
|
|
167
162
|
<img src="https://contrib.rocks/image?repo=jdf2e/nutui-react" alt="contributors"/>
|
|
168
163
|
</a>
|
|
169
164
|
|
|
170
|
-
|
|
171
|
-
## Stargazers
|
|
165
|
+
## Stargazers
|
|
172
166
|
|
|
173
167
|
[](https://github.com/jdf2e/nutui-react/stargazers)
|
|
174
168
|
|
|
@@ -184,7 +178,6 @@ Thanks to all the following [developers](https://github.com/jdf2e/nutui-react/gr
|
|
|
184
178
|
|
|
185
179
|
NutUI follows [Angular Style Commit Message Conventions](https://gist.github.com/stephenparish/9941e89d80e2bc58a153). The up-to-date release notes are available on [Release](https://github.com/jdf2e/nutui-react/releases)
|
|
186
180
|
|
|
187
|
-
|
|
188
181
|
## Open Source License
|
|
189
182
|
|
|
190
183
|
This project is based on **MIT** protocol
|
package/dist/esm/Audio.js
CHANGED
|
@@ -27,16 +27,16 @@ const Audio = (props) => {
|
|
|
27
27
|
percent: 0,
|
|
28
28
|
duration: "00:00:00",
|
|
29
29
|
second: 0,
|
|
30
|
-
hanMuted:
|
|
31
|
-
playing:
|
|
30
|
+
hanMuted: muted,
|
|
31
|
+
playing: autoPlay,
|
|
32
32
|
handPlaying: false
|
|
33
33
|
});
|
|
34
34
|
const classPrefix = "nut-audio";
|
|
35
35
|
const handleEnded = (e) => {
|
|
36
|
-
if (
|
|
36
|
+
if (loop) {
|
|
37
37
|
console.warn(locale.audio.tips || "onPlayEnd事件在loop=false时才会触发");
|
|
38
38
|
} else {
|
|
39
|
-
|
|
39
|
+
onEnd === null || onEnd === void 0 ? void 0 : onEnd(e);
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
function watch() {
|
|
@@ -75,25 +75,25 @@ const Audio = (props) => {
|
|
|
75
75
|
if (statusRef.current.currentTime > 0 && AudioRef.current) {
|
|
76
76
|
statusRef.current.currentTime--;
|
|
77
77
|
AudioRef.current.currentTime = statusRef.current.currentTime;
|
|
78
|
-
|
|
78
|
+
onBack === null || onBack === void 0 ? void 0 : onBack(AudioRef.current);
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
81
|
const handleForward = () => {
|
|
82
82
|
if (AudioRef.current) {
|
|
83
83
|
statusRef.current.currentTime++;
|
|
84
84
|
AudioRef.current.currentTime = statusRef.current.currentTime;
|
|
85
|
-
|
|
85
|
+
onForward === null || onForward === void 0 ? void 0 : onForward(AudioRef.current);
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
88
|
const handleMute = () => {
|
|
89
89
|
if (AudioRef.current) {
|
|
90
90
|
AudioRef.current.muted = !AudioRef.current.muted;
|
|
91
|
-
|
|
91
|
+
onMute === null || onMute === void 0 ? void 0 : onMute(AudioRef.current);
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
94
|
const handlePause = (e) => {
|
|
95
95
|
setPlaying(false);
|
|
96
|
-
|
|
96
|
+
onPause === null || onPause === void 0 ? void 0 : onPause(e);
|
|
97
97
|
};
|
|
98
98
|
const formatSeconds = (value) => {
|
|
99
99
|
if (!value) {
|
|
@@ -151,12 +151,12 @@ const Audio = (props) => {
|
|
|
151
151
|
};
|
|
152
152
|
const handleCanplay = (e) => {
|
|
153
153
|
setIsCanPlay(true);
|
|
154
|
-
if (
|
|
154
|
+
if (autoPlay && !playing) {
|
|
155
155
|
AudioRef && AudioRef.current && AudioRef.current.play();
|
|
156
156
|
}
|
|
157
157
|
if (AudioRef.current) {
|
|
158
158
|
statusRef.current.second = AudioRef.current.duration || 0;
|
|
159
|
-
|
|
159
|
+
onCanPlay === null || onCanPlay === void 0 ? void 0 : onCanPlay(e);
|
|
160
160
|
}
|
|
161
161
|
};
|
|
162
162
|
const onTimeupdate = (e) => {
|
|
@@ -178,7 +178,6 @@ const Audio = (props) => {
|
|
|
178
178
|
)
|
|
179
179
|
);
|
|
180
180
|
};
|
|
181
|
-
Audio.defaultProps = defaultProps;
|
|
182
181
|
Audio.displayName = "NutAudio";
|
|
183
182
|
export {
|
|
184
183
|
Audio as default
|
package/dist/esm/CalendarItem.js
CHANGED
|
@@ -307,8 +307,10 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
|
|
|
307
307
|
};
|
|
308
308
|
useEffect(() => {
|
|
309
309
|
setCurrentDate(resetDefaultValue() || []);
|
|
310
|
-
popup && resetRender();
|
|
311
310
|
}, [defaultValue]);
|
|
311
|
+
useEffect(() => {
|
|
312
|
+
popup && resetRender();
|
|
313
|
+
}, [currentDate]);
|
|
312
314
|
const scrollToDate = (date) => {
|
|
313
315
|
if (Utils.compareDate(date, propStartDate)) {
|
|
314
316
|
date = propStartDate;
|
|
@@ -17,7 +17,7 @@ const defaultProps = {
|
|
|
17
17
|
};
|
|
18
18
|
const classPrefix = "nut-checkboxgroup";
|
|
19
19
|
const CheckboxGroup = React__default.forwardRef((props, ref) => {
|
|
20
|
-
const _a = Object.assign(Object.assign({}, defaultProps), props), { children, className, disabled, list,
|
|
20
|
+
const _a = Object.assign(Object.assign({}, defaultProps), props), { children, className, disabled, list, value, defaultValue, max, min, labelPosition, direction, options, onChange, onLimit } = _a, rest = __rest(_a, ["children", "className", "disabled", "list", "value", "defaultValue", "max", "min", "labelPosition", "direction", "options", "onChange", "onLimit"]);
|
|
21
21
|
useImperativeHandle(ref, () => ({
|
|
22
22
|
toggle(state) {
|
|
23
23
|
if (state === false) {
|
|
@@ -42,8 +42,8 @@ const CheckboxGroup = React__default.forwardRef((props, ref) => {
|
|
|
42
42
|
}
|
|
43
43
|
}));
|
|
44
44
|
const [_value, setValue] = usePropsValue({
|
|
45
|
-
value
|
|
46
|
-
defaultValue
|
|
45
|
+
value,
|
|
46
|
+
defaultValue,
|
|
47
47
|
finalValue: [],
|
|
48
48
|
onChange
|
|
49
49
|
});
|
|
@@ -80,12 +80,11 @@ const CheckboxGroup = React__default.forwardRef((props, ref) => {
|
|
|
80
80
|
}
|
|
81
81
|
} },
|
|
82
82
|
React__default.createElement("div", Object.assign({ className: classNames(classPrefix, {
|
|
83
|
-
[`nut-checkboxgroup-${
|
|
83
|
+
[`nut-checkboxgroup-${direction}`]: direction,
|
|
84
84
|
[`nut-checkboxgroup-list`]: list
|
|
85
85
|
}, className) }, rest), (options === null || options === void 0 ? void 0 : options.length) ? renderOptions() : children)
|
|
86
86
|
);
|
|
87
87
|
});
|
|
88
|
-
CheckboxGroup.defaultProps = defaultProps;
|
|
89
88
|
CheckboxGroup.displayName = "NutCheckboxGroup";
|
|
90
89
|
export {
|
|
91
90
|
CheckboxGroup as default
|
package/dist/esm/DatePicker.js
CHANGED
|
@@ -131,7 +131,7 @@ const DatePicker = (props) => {
|
|
|
131
131
|
if (!isEqual) {
|
|
132
132
|
setSelectedDate(formatValue(newDate));
|
|
133
133
|
}
|
|
134
|
-
|
|
134
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(selectedOptions, [
|
|
135
135
|
String(newDate.getFullYear()),
|
|
136
136
|
String(newDate.getMonth() + 1),
|
|
137
137
|
String(newDate.getDate())
|
|
@@ -202,8 +202,8 @@ const DatePicker = (props) => {
|
|
|
202
202
|
}
|
|
203
203
|
pickerValue[columnIndex] = (_a2 = arr[index]) === null || _a2 === void 0 ? void 0 : _a2.value;
|
|
204
204
|
setPickerValue([...pickerValue]);
|
|
205
|
-
if (
|
|
206
|
-
return
|
|
205
|
+
if (filter === null || filter === void 0 ? void 0 : filter(type2, arr)) {
|
|
206
|
+
return filter === null || filter === void 0 ? void 0 : filter(type2, arr);
|
|
207
207
|
}
|
|
208
208
|
return arr;
|
|
209
209
|
};
|
|
@@ -242,7 +242,6 @@ const DatePicker = (props) => {
|
|
|
242
242
|
}, [selectedDate, startDate, endDate]);
|
|
243
243
|
return React__default.createElement("div", Object.assign({ className: `nut-datepicker ${className}`, style }, rest), pickerOptions.length && React__default.createElement(Picker__default, Object.assign({}, pickerProps, { title, visible, options: pickerOptions, onClose, onCancel, value: pickerValue, onConfirm: (options, value) => onConfirm && onConfirm(options, value), onChange: (options, value, index) => handlePickerChange(options, value, index), threeDimensional })));
|
|
244
244
|
};
|
|
245
|
-
DatePicker.defaultProps = defaultProps;
|
|
246
245
|
DatePicker.displayName = "NutDatePicker";
|
|
247
246
|
export {
|
|
248
247
|
DatePicker as default
|
package/dist/esm/Dialog.js
CHANGED
|
@@ -122,7 +122,7 @@ const Content = (props) => {
|
|
|
122
122
|
);
|
|
123
123
|
};
|
|
124
124
|
Content.displayName = "NutContent";
|
|
125
|
-
|
|
125
|
+
Object.assign(Object.assign(Object.assign({}, ComponentDefaults), { overlay: true, overlayStyle: {}, overlayClassName: "", onCancel: () => {
|
|
126
126
|
}, onClose: () => {
|
|
127
127
|
}, onOverlayClick: (e) => true }), defaultOverlayProps);
|
|
128
128
|
const DialogWrap = (props) => {
|
|
@@ -145,7 +145,6 @@ const DialogWrap = (props) => {
|
|
|
145
145
|
)
|
|
146
146
|
);
|
|
147
147
|
};
|
|
148
|
-
DialogWrap.defaultProps = defaultDialogProps;
|
|
149
148
|
DialogWrap.displayName = "NutDialogWrap";
|
|
150
149
|
const defaultProps = Object.assign(Object.assign({}, ComponentDefaults), { confirmText: "", cancelText: "", overlay: true, closeOnOverlayClick: true, hideConfirmButton: false, hideCancelButton: false, disableConfirmButton: false, footerDirection: "horizontal", lockScroll: true, closeIconPosition: "bottom", closeIcon: false, beforeCancel: () => true, beforeClose: () => true });
|
|
151
150
|
const BaseDialog = (props, ref) => {
|
package/dist/esm/InputNumber.js
CHANGED
|
@@ -98,6 +98,18 @@ const InputNumber = (props) => {
|
|
|
98
98
|
return null;
|
|
99
99
|
return text;
|
|
100
100
|
};
|
|
101
|
+
const clampValue = (valueStr) => {
|
|
102
|
+
if (valueStr === null)
|
|
103
|
+
return defaultValue;
|
|
104
|
+
const val = Number(parseFloat(valueStr || "0").toFixed(digits));
|
|
105
|
+
return Math.max(Number(min), Math.min(Number(max), val));
|
|
106
|
+
};
|
|
107
|
+
const handleValueChange = (valueStr, e) => {
|
|
108
|
+
const val = clampValue(valueStr);
|
|
109
|
+
if (val !== Number(shadowValue)) {
|
|
110
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(val, e);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
101
113
|
const handleInputChange = (e) => {
|
|
102
114
|
setInputValue(e.target.value);
|
|
103
115
|
const valueStr = parseValue(e.target.value);
|
|
@@ -108,24 +120,29 @@ const InputNumber = (props) => {
|
|
|
108
120
|
setShadowValue(defaultValue);
|
|
109
121
|
}
|
|
110
122
|
} else {
|
|
111
|
-
setShadowValue(valueStr);
|
|
112
|
-
}
|
|
113
|
-
if (!async) {
|
|
114
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(parseFloat(valueStr || "0").toFixed(digits), e);
|
|
123
|
+
setShadowValue(clampValue(valueStr));
|
|
115
124
|
}
|
|
125
|
+
!async && handleValueChange(valueStr, e);
|
|
116
126
|
};
|
|
117
127
|
const handleFocus = (e) => {
|
|
118
128
|
setFocused(true);
|
|
119
129
|
setInputValue(shadowValue !== void 0 && shadowValue !== null ? bound(Number(shadowValue), Number(min), Number(max)).toString() : "");
|
|
120
|
-
onFocus
|
|
130
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
|
|
121
131
|
};
|
|
122
132
|
const handleBlur = (e) => {
|
|
123
133
|
setFocused(false);
|
|
124
|
-
onBlur
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
134
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
|
135
|
+
const valueStr = parseValue(e.target.value);
|
|
136
|
+
if (valueStr === null) {
|
|
137
|
+
if (allowEmpty) {
|
|
138
|
+
setShadowValue(null);
|
|
139
|
+
} else {
|
|
140
|
+
setShadowValue(defaultValue);
|
|
141
|
+
}
|
|
142
|
+
} else {
|
|
143
|
+
setShadowValue(clampValue(valueStr));
|
|
128
144
|
}
|
|
145
|
+
async && handleValueChange(valueStr, e);
|
|
129
146
|
};
|
|
130
147
|
return React__default.createElement(
|
|
131
148
|
"div",
|
package/dist/esm/Menu.js
CHANGED
|
@@ -68,7 +68,7 @@ const Menu = (props) => {
|
|
|
68
68
|
const menuTitle = () => {
|
|
69
69
|
return React__default.Children.map(children, (child, index) => {
|
|
70
70
|
if (React__default.isValidElement(child)) {
|
|
71
|
-
const { title, options, value, defaultValue, disabled, direction } = child.props;
|
|
71
|
+
const { title, titleIcon, options, value, defaultValue, disabled, direction } = child.props;
|
|
72
72
|
const selected = options === null || options === void 0 ? void 0 : options.filter((option) => option.value === (value !== void 0 ? value : defaultValue));
|
|
73
73
|
const finallyTitle = () => {
|
|
74
74
|
if (title)
|
|
@@ -79,19 +79,26 @@ const Menu = (props) => {
|
|
|
79
79
|
return selected[0].text;
|
|
80
80
|
return "";
|
|
81
81
|
};
|
|
82
|
+
const finallyIcon = () => {
|
|
83
|
+
if (titleIcon)
|
|
84
|
+
return titleIcon;
|
|
85
|
+
if (icon)
|
|
86
|
+
return icon;
|
|
87
|
+
return direction === "up" ? React__default.createElement(ArrowUp, { className: "nut-menu-title-icon", width: "12px", height: "12px" }) : React__default.createElement(ArrowDown, { className: "nut-menu-title-icon", width: "12px", height: "12px" });
|
|
88
|
+
};
|
|
82
89
|
return React__default.createElement(
|
|
83
90
|
"div",
|
|
84
|
-
{ className: classNames("nut-menu-title
|
|
91
|
+
{ className: classNames("nut-menu-title", `nut-menu-title-${index}`, {
|
|
85
92
|
active: showMenuItem[index],
|
|
86
93
|
disabled
|
|
87
|
-
}
|
|
94
|
+
}), style: { color: showMenuItem[index] ? activeColor : "" }, key: index, onClick: (e) => {
|
|
88
95
|
e.stopPropagation();
|
|
89
96
|
if ((!options || !options.length) && !child.props.children)
|
|
90
97
|
return;
|
|
91
98
|
!disabled && toggleMenuItem(index);
|
|
92
99
|
} },
|
|
93
100
|
React__default.createElement("div", { className: "nut-menu-title-text" }, finallyTitle()),
|
|
94
|
-
|
|
101
|
+
finallyIcon()
|
|
95
102
|
);
|
|
96
103
|
}
|
|
97
104
|
return null;
|
|
@@ -5,11 +5,11 @@ import { ArrowDown } from "@nutui/icons-react";
|
|
|
5
5
|
import Popup__default from "./Popup.js";
|
|
6
6
|
import { useConfig } from "./ConfigProvider.js";
|
|
7
7
|
import { C as ComponentDefaults } from "./typings.js";
|
|
8
|
-
Object.assign(Object.assign({}, ComponentDefaults), { visible: false, rightActions: "", type: "default", custom: [], random: false, onClose: () => {
|
|
8
|
+
const defaultProps = Object.assign(Object.assign({}, ComponentDefaults), { visible: false, rightActions: "", type: "default", custom: [], random: false, onClose: () => {
|
|
9
9
|
} });
|
|
10
10
|
const NumberKeyboard = (props) => {
|
|
11
11
|
const { locale } = useConfig();
|
|
12
|
-
const { title, rightActions, confirmText, visible, type, custom, random, style, className, onChange, onDelete, onClose, onConfirm } =
|
|
12
|
+
const _a = Object.assign(Object.assign({}, defaultProps), props), { title, rightActions, confirmText, visible, type, custom, random, style, className, onChange, onDelete, onClose, onConfirm } = _a, rest = __rest(_a, ["title", "rightActions", "confirmText", "visible", "type", "custom", "random", "style", "className", "onChange", "onDelete", "onClose", "onConfirm"]);
|
|
13
13
|
const classPrefix = "nut-numberkeyboard";
|
|
14
14
|
const getBasicKeys = () => {
|
|
15
15
|
const keys = new Array(9).fill(0).map((_, index) => {
|
|
@@ -55,41 +55,52 @@ const NumberKeyboard = (props) => {
|
|
|
55
55
|
};
|
|
56
56
|
const onTouchEnd = (item2) => {
|
|
57
57
|
setActive(false);
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
switch (item2.type) {
|
|
59
|
+
case "num":
|
|
60
|
+
case "custom":
|
|
61
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(item2.id);
|
|
62
|
+
break;
|
|
63
|
+
case "close":
|
|
64
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
65
|
+
break;
|
|
66
|
+
case "delete":
|
|
67
|
+
onDelete === null || onDelete === void 0 ? void 0 : onDelete();
|
|
68
|
+
break;
|
|
69
|
+
case "confirm":
|
|
70
|
+
onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm();
|
|
71
|
+
break;
|
|
60
72
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
73
|
+
};
|
|
74
|
+
const renderContent = (item2) => {
|
|
75
|
+
switch (item2.type) {
|
|
76
|
+
case "num":
|
|
77
|
+
case "custom":
|
|
78
|
+
return React__default.createElement("div", null, item2.id);
|
|
79
|
+
case "delete":
|
|
80
|
+
return React__default.createElement(DeleteIcon, null);
|
|
81
|
+
case "close":
|
|
82
|
+
return React__default.createElement(ArrowDown, { width: 18, height: 18 });
|
|
83
|
+
case "confirm":
|
|
84
|
+
return React__default.createElement(React__default.Fragment, null, confirmText || locale.done);
|
|
85
|
+
default:
|
|
86
|
+
return null;
|
|
69
87
|
}
|
|
70
88
|
};
|
|
71
89
|
return React__default.createElement(
|
|
72
90
|
"div",
|
|
73
91
|
{ key: item.id, className: `${classPrefix}-body-wrapper` },
|
|
74
|
-
React__default.createElement(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
confirm: item.type === "confirm"
|
|
82
|
-
}), onTouchStart: () => onTouchStart(), onTouchEnd: () => onTouchEnd(item), onTouchCancel: () => onTouchEnd(item) },
|
|
83
|
-
(item.type === "num" || item.type === "custom") && React__default.createElement("div", null, item.id),
|
|
84
|
-
item.type === "delete" && React__default.createElement(DeleteIcon, null),
|
|
85
|
-
item.type === "close" && React__default.createElement(ArrowDown, { width: 18, height: 18 }),
|
|
86
|
-
item.type === "confirm" && React__default.createElement(React__default.Fragment, null, confirmText || locale.done)
|
|
87
|
-
)
|
|
92
|
+
React__default.createElement("div", { className: classNames({
|
|
93
|
+
key: true,
|
|
94
|
+
active,
|
|
95
|
+
close: item.type === "close",
|
|
96
|
+
delete: item.type === "delete",
|
|
97
|
+
confirm: item.type === "confirm"
|
|
98
|
+
}), onTouchStart: () => onTouchStart(), onTouchEnd: () => onTouchEnd(item), onTouchCancel: () => onTouchEnd(item) }, renderContent(item))
|
|
88
99
|
);
|
|
89
100
|
};
|
|
90
101
|
return React__default.createElement(
|
|
91
102
|
Popup__default,
|
|
92
|
-
Object.assign({ visible, position: "bottom", onOverlayClick: onClose, onCloseIconClick: onClose, zIndex: 9999, overlayStyle: { backgroundColor: "rgba(0, 0, 0, 0)" } }
|
|
103
|
+
Object.assign({}, rest, { visible, position: "bottom", onOverlayClick: onClose, onCloseIconClick: onClose, zIndex: 9999, overlayStyle: { backgroundColor: "rgba(0, 0, 0, 0)" } }),
|
|
93
104
|
React__default.createElement(
|
|
94
105
|
"div",
|
|
95
106
|
{ className: classNames(classPrefix, className), style },
|
|
@@ -190,7 +190,6 @@ const PullToRefresh = (p) => {
|
|
|
190
190
|
React__default.createElement("div", { className: `${classPrefix}-content` }, props.children)
|
|
191
191
|
);
|
|
192
192
|
};
|
|
193
|
-
PullToRefresh.defaultProps = defaultProps;
|
|
194
193
|
PullToRefresh.displayName = "NutPullToRefresh";
|
|
195
194
|
export {
|
|
196
195
|
PullToRefresh as default
|
package/dist/esm/RadioGroup.js
CHANGED
|
@@ -44,7 +44,6 @@ const RadioGroup = React__default.forwardRef((props, ref) => {
|
|
|
44
44
|
}, className) }, rest), (options === null || options === void 0 ? void 0 : options.length) ? renderOptionsChildren() : children)
|
|
45
45
|
);
|
|
46
46
|
});
|
|
47
|
-
RadioGroup.defaultProps = defaultProps;
|
|
48
47
|
RadioGroup.displayName = "NutRadioGroup";
|
|
49
48
|
export {
|
|
50
49
|
RadioGroup as default
|
package/dist/esm/Sticky.js
CHANGED
|
@@ -45,14 +45,15 @@ const Sticky = (props) => {
|
|
|
45
45
|
useEffect(() => {
|
|
46
46
|
if (position === "top")
|
|
47
47
|
return;
|
|
48
|
-
const containerEle = container
|
|
49
|
-
|
|
48
|
+
const containerEle = container && container.current;
|
|
49
|
+
const rootEle = rootRef.current;
|
|
50
|
+
const stickyEle = stickyRef.current;
|
|
51
|
+
if (!rootEle && !containerEle)
|
|
50
52
|
return;
|
|
51
|
-
const rootRect = getRect(
|
|
53
|
+
const rootRect = getRect(rootEle);
|
|
52
54
|
const containerRect = getRect(containerEle);
|
|
53
55
|
const clientHeight = document.documentElement.clientHeight;
|
|
54
|
-
const
|
|
55
|
-
const stickyRect = getRect(stCurrent);
|
|
56
|
+
const stickyRect = getRect(stickyEle);
|
|
56
57
|
let fixed = clientHeight - threshold < rootRect.bottom;
|
|
57
58
|
if (containerEle) {
|
|
58
59
|
fixed = containerRect.bottom > clientHeight - threshold - stickyRect.height && clientHeight - threshold - stickyRect.height > containerRect.top;
|
|
@@ -64,17 +65,16 @@ const Sticky = (props) => {
|
|
|
64
65
|
setIsFixed(fixed);
|
|
65
66
|
}, [position, container, threshold]);
|
|
66
67
|
const handleScroll = useCallback(() => {
|
|
67
|
-
const containerEle = container
|
|
68
|
-
|
|
68
|
+
const containerEle = container && container.current;
|
|
69
|
+
const rootEle = rootRef.current;
|
|
70
|
+
const stickyEle = stickyRef.current;
|
|
71
|
+
if (!rootEle && !containerEle)
|
|
69
72
|
return;
|
|
70
|
-
const rootRect = getRect(
|
|
71
|
-
const
|
|
72
|
-
const stickyRect = getRect(stCurrent);
|
|
73
|
+
const rootRect = getRect(rootEle);
|
|
74
|
+
const stickyRect = getRect(stickyEle);
|
|
73
75
|
const containerRect = getRect(containerEle);
|
|
74
76
|
if (rootRect.height) {
|
|
75
|
-
setRootStyle((prev) => {
|
|
76
|
-
return Object.assign(Object.assign({}, prev), { height: rootRect.height });
|
|
77
|
-
});
|
|
77
|
+
setRootStyle((prev) => Object.assign(Object.assign({}, prev), { height: rootRect.height }));
|
|
78
78
|
}
|
|
79
79
|
const getFixed = () => {
|
|
80
80
|
let fixed2 = false;
|
|
@@ -90,22 +90,16 @@ const Sticky = (props) => {
|
|
|
90
90
|
};
|
|
91
91
|
};
|
|
92
92
|
const getTransform = () => {
|
|
93
|
-
if (position === "top") {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return { transform: `translate3d(0, ${transform}px, 0)` };
|
|
98
|
-
}
|
|
99
|
-
return {};
|
|
93
|
+
if (position === "top" && containerEle) {
|
|
94
|
+
const diff = containerRect.bottom - threshold - stickyRect.height;
|
|
95
|
+
const transform = diff < 0 ? diff : 0;
|
|
96
|
+
return { transform: `translate3d(0, ${transform}px, 0)` };
|
|
100
97
|
}
|
|
101
|
-
if (position === "bottom") {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return { transform: `translate3d(0, ${transform}px, 0)` };
|
|
107
|
-
}
|
|
108
|
-
return {};
|
|
98
|
+
if (position === "bottom" && containerEle) {
|
|
99
|
+
const clientHeight = document.documentElement.clientHeight;
|
|
100
|
+
const diff = containerRect.bottom - (clientHeight - threshold);
|
|
101
|
+
const transform = diff < 0 ? diff : 0;
|
|
102
|
+
return { transform: `translate3d(0, ${transform}px, 0)` };
|
|
109
103
|
}
|
|
110
104
|
return {};
|
|
111
105
|
};
|
|
@@ -120,9 +114,9 @@ const Sticky = (props) => {
|
|
|
120
114
|
});
|
|
121
115
|
useEffect(() => {
|
|
122
116
|
const el = getElement();
|
|
123
|
-
el.addEventListener("scroll", handleScroll, false);
|
|
117
|
+
el === null || el === void 0 ? void 0 : el.addEventListener("scroll", handleScroll, false);
|
|
124
118
|
return () => {
|
|
125
|
-
el.removeEventListener("scroll", handleScroll);
|
|
119
|
+
el === null || el === void 0 ? void 0 : el.removeEventListener("scroll", handleScroll);
|
|
126
120
|
};
|
|
127
121
|
}, [getElement, handleScroll]);
|
|
128
122
|
return React__default.createElement(
|
package/dist/esm/Swipe.js
CHANGED
package/dist/esm/Swiper.js
CHANGED
package/dist/esm/SwiperItem.js
CHANGED
|
@@ -9,7 +9,6 @@ const SwiperItem = (props) => {
|
|
|
9
9
|
const classes = classNames(classPrefix, className);
|
|
10
10
|
return React__default.createElement("div", { className: classes, onClick: props.onClick, style }, children);
|
|
11
11
|
};
|
|
12
|
-
SwiperItem.defaultProps = defaultProps;
|
|
13
12
|
SwiperItem.displayName = "NutSwiperItem";
|
|
14
13
|
export {
|
|
15
14
|
SwiperItem as default
|
package/dist/esm/Table.js
CHANGED
|
@@ -130,17 +130,18 @@ const Table = (props) => {
|
|
|
130
130
|
});
|
|
131
131
|
};
|
|
132
132
|
const renderBodyTds = (item, rowIndex) => {
|
|
133
|
-
const { rowRender } = item;
|
|
134
|
-
if (rowRender && typeof rowRender === "function") {
|
|
135
|
-
return rowRender(item, rowIndex);
|
|
136
|
-
}
|
|
137
133
|
return sortDataItem().map(([value, render]) => {
|
|
138
134
|
return React__default.createElement("div", { className: classNames(`${bodyClassPrefix}-td`, cellClasses(getColumnItem(value)), getStickyClass(value)), key: value, style: getStickyStyle(value) }, typeof item[value] === "function" || typeof render === "function" ? React__default.createElement("div", null, render ? render(item, rowIndex) : item[value](item)) : item[value]);
|
|
139
135
|
});
|
|
140
136
|
};
|
|
141
137
|
const renderBodyTrs = () => {
|
|
142
138
|
return innerValue.map((item, index) => {
|
|
143
|
-
|
|
139
|
+
const inner = renderBodyTds(item, index);
|
|
140
|
+
const { rowRender } = item;
|
|
141
|
+
if (rowRender && typeof rowRender === "function") {
|
|
142
|
+
return rowRender(item, index, { inner });
|
|
143
|
+
}
|
|
144
|
+
return React__default.createElement("div", { className: bodyClassPrefix, key: index }, inner);
|
|
144
145
|
});
|
|
145
146
|
};
|
|
146
147
|
return React__default.createElement(
|