@nutui/nutui-react-taro 2.3.2 → 2.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/esm/ActionSheet/style/style.css +1 -1
- package/dist/esm/Address.js +3 -3
- package/dist/esm/Audio/style/style.css +1 -1
- package/dist/esm/Button/style/style.css +1 -1
- package/dist/esm/Calendar.js +2 -2
- package/dist/esm/CalendarItem.js +1 -1
- package/dist/esm/Cascader.js +2 -2
- package/dist/esm/Checkbox/style/style.css +1 -1
- package/dist/esm/CountDown.js +2 -1
- package/dist/esm/DatePicker.js +3 -2
- package/dist/esm/Dialog/style/style.css +1 -1
- package/dist/esm/Empty.js +1 -1
- package/dist/esm/Form.js +1 -0
- package/dist/esm/InfiniteLoading.js +1 -1
- package/dist/esm/InputNumber.js +1 -1
- package/dist/esm/Menu/style/style.css +1 -1
- package/dist/esm/MenuItem/style/style.css +1 -1
- package/dist/esm/Picker.js +1 -1
- package/dist/esm/PullToRefresh.js +2 -1
- package/dist/esm/Radio/style/style.css +1 -1
- package/dist/esm/Tabbar.js +2 -2
- package/dist/esm/TabbarItem.js +1 -1
- package/dist/esm/Table/style/style.css +1 -1
- package/dist/esm/Table.js +1 -1
- package/dist/esm/Tabs.js +1 -1
- package/dist/esm/{address.taro-DwplktN_.js → address.taro-sTqrtuxC.js} +1 -1
- package/dist/esm/{calendar.taro-Tuy-Kr-q.js → calendar.taro-Kf91Qo5t.js} +1 -1
- package/dist/esm/{calendaritem.taro-22chQZnN.js → calendaritem.taro-G5BaVw8e.js} +9 -3
- package/dist/esm/{cascader.taro-gspYp5PT.js → cascader.taro-DYMZD6ik.js} +18 -4
- package/dist/esm/{countdown.taro-_7iZfeff.js → countdown.taro-rJngrZUZ.js} +1 -7
- package/dist/esm/{datepicker.taro-a2BIZNUH.js → datepicker.taro-7xNSgNRT.js} +53 -73
- package/dist/esm/{empty.taro-9bGPftO1.js → empty.taro-CE-H96el.js} +212 -220
- package/dist/esm/{infiniteloading.taro-cQRDXtbb.js → infiniteloading.taro-eSS7cIsT.js} +2 -2
- package/dist/esm/{inputnumber.taro-XcwIk4rB.js → inputnumber.taro-7QptygT3.js} +2 -2
- package/dist/esm/nutui-react.es.js +16 -15
- package/dist/esm/pad-zero-iY-0-oys.js +10 -0
- package/dist/esm/{picker.taro-4lJuJ4rX.js → picker.taro-pRzPNgyZ.js} +1 -1
- package/dist/esm/{pulltorefresh.taro-GxK5LBIE.js → pulltorefresh.taro-h0P58sPG.js} +12 -18
- package/dist/esm/{tabbar.taro-lM7-vxOz.js → tabbar.taro-QE0rjSKE.js} +13 -13
- package/dist/esm/{tabbaritem.taro-Q5uY6b9_.js → tabbaritem.taro-t9C07OYX.js} +23 -8
- package/dist/esm/table.taro-Zyemar_o.js +184 -0
- package/dist/esm/{tabs.taro-HezOZhRs.js → tabs.taro-uXbRqGVo.js} +22 -7
- package/dist/esm/types/src/packages/cascader/cascader.d.ts +4 -0
- package/dist/esm/types/src/packages/cascader/cascader.taro.d.ts +4 -0
- package/dist/esm/types/src/packages/configprovider/types.d.ts +1 -1
- package/dist/esm/types/src/packages/pulltorefresh/pulltorefresh.d.ts +1 -0
- package/dist/esm/types/src/packages/pulltorefresh/pulltorefresh.taro.d.ts +1 -0
- package/dist/esm/types/src/packages/tabbar/context.d.ts +9 -0
- package/dist/esm/types/src/packages/tabbar/index.d.ts +1 -0
- package/dist/esm/types/src/packages/tabbar/index.taro.d.ts +1 -0
- package/dist/esm/types/src/packages/tabbaritem/tabbaritem.d.ts +0 -5
- package/dist/esm/types/src/packages/tabbaritem/tabbaritem.taro.d.ts +0 -5
- package/dist/esm/types/src/packages/table/types.d.ts +2 -0
- package/dist/esm/types/src/packages/table/useTableSticky.d.ts +8 -0
- package/dist/esm/types/src/utils/is-date.d.ts +1 -0
- package/dist/esm/types/src/utils/pad-zero.d.ts +1 -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/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 +1525 -1463
- package/dist/nutui.react.umd.js +1534 -1472
- package/dist/packages/checkbox/checkbox.scss +3 -0
- package/dist/packages/menuitem/menuitem.scss +1 -1
- package/dist/packages/table/table.scss +82 -9
- package/dist/style.css +1 -1
- package/dist/style.mjs +1 -1
- package/dist/styles/variables-jmapp.scss +9 -2
- package/dist/styles/variables.scss +10 -3
- package/dist/types/packages/cascader/cascader.d.ts +4 -0
- package/dist/types/packages/cascader/cascader.taro.d.ts +4 -0
- package/dist/types/packages/configprovider/types.d.ts +1 -1
- package/dist/types/packages/pulltorefresh/pulltorefresh.d.ts +1 -0
- package/dist/types/packages/pulltorefresh/pulltorefresh.taro.d.ts +7 -2
- package/dist/types/packages/tabbar/context.d.ts +9 -0
- package/dist/types/packages/tabbar/index.d.ts +1 -0
- package/dist/types/packages/tabbar/index.taro.d.ts +1 -0
- package/dist/types/packages/tabbaritem/tabbaritem.d.ts +0 -5
- package/dist/types/packages/tabbaritem/tabbaritem.taro.d.ts +0 -5
- package/dist/types/packages/table/types.d.ts +2 -0
- package/dist/types/packages/table/useTableSticky.d.ts +8 -0
- package/dist/types/utils/is-date.d.ts +1 -0
- package/dist/types/utils/pad-zero.d.ts +1 -0
- package/package.json +2 -2
- package/dist/esm/table.taro-NO-C8ayh.js +0 -109
|
@@ -4,12 +4,12 @@ var __publicField = (obj, key, value) => {
|
|
|
4
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
|
-
import React__default, { useState, useEffect, isValidElement } from "react";
|
|
7
|
+
import React__default, { useState, useImperativeHandle, useEffect, isValidElement } from "react";
|
|
8
8
|
import classNames from "classnames";
|
|
9
9
|
import { Loading, Checklist } from "@nutui/icons-react-taro";
|
|
10
10
|
import { ScrollView } from "@tarojs/components";
|
|
11
11
|
import { P as Popup } from "./popup.taro-2FdJu1kg.js";
|
|
12
|
-
import { T as Tabs } from "./tabs.taro-
|
|
12
|
+
import { T as Tabs } from "./tabs.taro-uXbRqGVo.js";
|
|
13
13
|
import { C as ComponentDefaults } from "./typings-buMpDfSR.js";
|
|
14
14
|
import { u as usePropsValue } from "./use-props-value-vKr0R0AX.js";
|
|
15
15
|
const formatTree = (tree, parent, config) => tree.map((node) => {
|
|
@@ -143,7 +143,6 @@ const defaultProps = {
|
|
|
143
143
|
activeColor: "",
|
|
144
144
|
activeIcon: "checklist",
|
|
145
145
|
popup: true,
|
|
146
|
-
visible: false,
|
|
147
146
|
options: [],
|
|
148
147
|
optionKey: { textKey: "text", valueKey: "value", childrenKey: "children" },
|
|
149
148
|
format: {},
|
|
@@ -170,6 +169,20 @@ const InternalCascader = (props, ref) => {
|
|
|
170
169
|
defaultValue,
|
|
171
170
|
finalValue: defaultValue
|
|
172
171
|
});
|
|
172
|
+
const [innerVisible, setInnerVisible] = usePropsValue({
|
|
173
|
+
value: props.visible,
|
|
174
|
+
defaultValue: void 0,
|
|
175
|
+
finalValue: false
|
|
176
|
+
});
|
|
177
|
+
const actions = {
|
|
178
|
+
open: () => {
|
|
179
|
+
setInnerVisible(true);
|
|
180
|
+
},
|
|
181
|
+
close: () => {
|
|
182
|
+
setInnerVisible(false);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
useImperativeHandle(ref, () => actions);
|
|
173
186
|
const [state] = useState({
|
|
174
187
|
optionsData: [],
|
|
175
188
|
panes: [
|
|
@@ -297,6 +310,7 @@ const InternalCascader = (props, ref) => {
|
|
|
297
310
|
state.lazyLoadMap.delete(node);
|
|
298
311
|
};
|
|
299
312
|
const close = () => {
|
|
313
|
+
setInnerVisible(false);
|
|
300
314
|
onClose && onClose();
|
|
301
315
|
};
|
|
302
316
|
const closePopup = () => {
|
|
@@ -419,7 +433,7 @@ const InternalCascader = (props, ref) => {
|
|
|
419
433
|
};
|
|
420
434
|
return React__default.createElement(React__default.Fragment, null, popup ? React__default.createElement(Popup, {
|
|
421
435
|
...popupProps,
|
|
422
|
-
visible,
|
|
436
|
+
visible: innerVisible,
|
|
423
437
|
position: "bottom",
|
|
424
438
|
style: { overflowY: "hidden" },
|
|
425
439
|
round: true,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React__default, { useState, useRef, useImperativeHandle, useEffect } from "react";
|
|
2
2
|
import { u as useConfig } from "./configprovider.taro-_wngOo0k.js";
|
|
3
3
|
import { C as ComponentDefaults } from "./typings-buMpDfSR.js";
|
|
4
|
+
import { p as padZero } from "./pad-zero-iY-0-oys.js";
|
|
4
5
|
const defaultProps = {
|
|
5
6
|
...ComponentDefaults,
|
|
6
7
|
paused: false,
|
|
@@ -124,13 +125,6 @@ const InternalCountDown = (props, ref) => {
|
|
|
124
125
|
}
|
|
125
126
|
return formatCache;
|
|
126
127
|
};
|
|
127
|
-
const padZero = (num, length = 2) => {
|
|
128
|
-
num += "";
|
|
129
|
-
while (num.length < length) {
|
|
130
|
-
num = `0${num}`;
|
|
131
|
-
}
|
|
132
|
-
return num.toString();
|
|
133
|
-
};
|
|
134
128
|
const pause = () => {
|
|
135
129
|
cancelAnimationFrame(stateRef.current.timer);
|
|
136
130
|
stateRef.current.counting = false;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import React__default, { useState, useEffect } from "react";
|
|
2
2
|
import { View } from "@tarojs/components";
|
|
3
|
-
import { P as Picker } from "./picker.taro-
|
|
3
|
+
import { P as Picker } from "./picker.taro-pRzPNgyZ.js";
|
|
4
4
|
import { u as useConfig } from "./configprovider.taro-_wngOo0k.js";
|
|
5
5
|
import { u as usePropsValue } from "./use-props-value-vKr0R0AX.js";
|
|
6
6
|
import { C as ComponentDefaults } from "./typings-buMpDfSR.js";
|
|
7
|
+
import { p as padZero } from "./pad-zero-iY-0-oys.js";
|
|
8
|
+
const isDate = (val) => {
|
|
9
|
+
return Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
|
|
10
|
+
};
|
|
7
11
|
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
8
12
|
const defaultProps = {
|
|
9
13
|
...ComponentDefaults,
|
|
@@ -22,35 +26,27 @@ const DatePicker = (props) => {
|
|
|
22
26
|
...props
|
|
23
27
|
};
|
|
24
28
|
const { locale } = useConfig();
|
|
25
|
-
const
|
|
29
|
+
const lang = locale.datepicker;
|
|
26
30
|
const zhCNType = {
|
|
27
|
-
day:
|
|
28
|
-
year:
|
|
29
|
-
month:
|
|
30
|
-
hour:
|
|
31
|
-
minute:
|
|
32
|
-
seconds:
|
|
33
|
-
};
|
|
34
|
-
const [defaultValueOfPicker, setDefaultValueOfPicker] = useState([]);
|
|
35
|
-
const [options, setOptions] = useState([]);
|
|
36
|
-
const isDate = (val) => {
|
|
37
|
-
return Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
|
|
31
|
+
day: lang.day,
|
|
32
|
+
year: lang.year,
|
|
33
|
+
month: lang.month,
|
|
34
|
+
hour: lang.hour,
|
|
35
|
+
minute: lang.min,
|
|
36
|
+
seconds: lang.seconds
|
|
38
37
|
};
|
|
38
|
+
const [pickerValue, setPickerValue] = useState([]);
|
|
39
|
+
const [pickerOptions, setPickerOptions] = useState([]);
|
|
39
40
|
const formatValue = (value) => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
cvalue = startDate;
|
|
41
|
+
if (!value || value && !isDate(value)) {
|
|
42
|
+
value = startDate;
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
timestmp = Math.min(timestmp, endDate.getTime());
|
|
46
|
-
return timestmp;
|
|
44
|
+
return Math.min(Math.max(value.getTime(), startDate.getTime()), endDate.getTime());
|
|
47
45
|
};
|
|
48
|
-
const [
|
|
46
|
+
const [selectedDate, setSelectedDate] = usePropsValue({
|
|
49
47
|
value: props.value && formatValue(props.value),
|
|
50
|
-
defaultValue: formatValue(props.defaultValue
|
|
51
|
-
finalValue: 0
|
|
52
|
-
onChange: (val) => {
|
|
53
|
-
}
|
|
48
|
+
defaultValue: props.defaultValue && formatValue(props.defaultValue),
|
|
49
|
+
finalValue: 0
|
|
54
50
|
});
|
|
55
51
|
function getMonthEndDay(year, month) {
|
|
56
52
|
return new Date(year, month, 0).getDate();
|
|
@@ -91,12 +87,12 @@ const DatePicker = (props) => {
|
|
|
91
87
|
};
|
|
92
88
|
};
|
|
93
89
|
const ranges = () => {
|
|
94
|
-
const
|
|
95
|
-
if (!
|
|
90
|
+
const selected = new Date(selectedDate);
|
|
91
|
+
if (!selected)
|
|
96
92
|
return [];
|
|
97
|
-
const { maxYear, maxDate, maxMonth, maxHour, maxMinute, maxSeconds } = getBoundary("max",
|
|
98
|
-
const { minYear, minDate, minMonth, minHour, minMinute, minSeconds } = getBoundary("min",
|
|
99
|
-
|
|
93
|
+
const { maxYear, maxDate, maxMonth, maxHour, maxMinute, maxSeconds } = getBoundary("max", selected);
|
|
94
|
+
const { minYear, minDate, minMonth, minHour, minMinute, minSeconds } = getBoundary("min", selected);
|
|
95
|
+
const result = [
|
|
100
96
|
{
|
|
101
97
|
type: "year",
|
|
102
98
|
range: [minYear, maxYear]
|
|
@@ -124,30 +120,24 @@ const DatePicker = (props) => {
|
|
|
124
120
|
];
|
|
125
121
|
switch (type.toLocaleLowerCase()) {
|
|
126
122
|
case "date":
|
|
127
|
-
|
|
128
|
-
break;
|
|
123
|
+
return result.slice(0, 3);
|
|
129
124
|
case "datetime":
|
|
130
|
-
|
|
131
|
-
break;
|
|
125
|
+
return result.slice(0, 5);
|
|
132
126
|
case "time":
|
|
133
|
-
|
|
134
|
-
break;
|
|
127
|
+
return result.slice(3, 6);
|
|
135
128
|
case "year-month":
|
|
136
|
-
|
|
137
|
-
break;
|
|
129
|
+
return result.slice(0, 2);
|
|
138
130
|
case "hour-minutes":
|
|
139
|
-
|
|
140
|
-
break;
|
|
131
|
+
return result.slice(3, 5);
|
|
141
132
|
case "month-day":
|
|
142
|
-
|
|
143
|
-
break;
|
|
133
|
+
return result.slice(1, 3);
|
|
144
134
|
case "datehour":
|
|
145
|
-
|
|
146
|
-
|
|
135
|
+
return result.slice(0, 4);
|
|
136
|
+
default:
|
|
137
|
+
return result;
|
|
147
138
|
}
|
|
148
|
-
return result;
|
|
149
139
|
};
|
|
150
|
-
const
|
|
140
|
+
const handlePickerChange = (selectedOptions, selectedValue, index) => {
|
|
151
141
|
var _a;
|
|
152
142
|
const rangeType = type.toLocaleLowerCase();
|
|
153
143
|
if (["date", "datetime", "datehour", "month-day", "year-month"].includes(rangeType)) {
|
|
@@ -172,39 +162,29 @@ const DatePicker = (props) => {
|
|
|
172
162
|
} else if (rangeType === "datehour") {
|
|
173
163
|
date = new Date(year, month, day, Number(formatDate[3]));
|
|
174
164
|
}
|
|
175
|
-
const isEqual = ((_a = new Date(
|
|
176
|
-
date && isDate(date) && !isEqual &&
|
|
165
|
+
const isEqual = ((_a = new Date(selectedDate)) == null ? void 0 : _a.getTime()) === (date == null ? void 0 : date.getTime());
|
|
166
|
+
date && isDate(date) && !isEqual && setSelectedDate(formatValue(date));
|
|
177
167
|
}
|
|
178
168
|
props.onChange && props.onChange(selectedOptions, selectedValue, index);
|
|
179
169
|
};
|
|
180
|
-
const
|
|
181
|
-
let str = `${num}`;
|
|
182
|
-
while (str.length < targetLength) {
|
|
183
|
-
str = `0${str}`;
|
|
184
|
-
}
|
|
185
|
-
return str;
|
|
186
|
-
};
|
|
187
|
-
const formatterOption = (type2, value) => {
|
|
188
|
-
let fOption = null;
|
|
170
|
+
const formatOption = (type2, value) => {
|
|
189
171
|
if (formatter) {
|
|
190
|
-
|
|
172
|
+
return formatter(type2, {
|
|
191
173
|
text: padZero(value, 2),
|
|
192
174
|
value: padZero(value, 2)
|
|
193
175
|
});
|
|
194
|
-
} else {
|
|
195
|
-
const padMin = padZero(value, 2);
|
|
196
|
-
const fatter = showChinese ? zhCNType[type2] : "";
|
|
197
|
-
fOption = { text: padMin + fatter, value: padMin };
|
|
198
176
|
}
|
|
199
|
-
|
|
177
|
+
const padMin = padZero(value, 2);
|
|
178
|
+
const fatter = showChinese ? zhCNType[type2] : "";
|
|
179
|
+
return { text: padMin + fatter, value: padMin };
|
|
200
180
|
};
|
|
201
|
-
const
|
|
181
|
+
const generateColumn = (min, max, val, type2, columnIndex) => {
|
|
202
182
|
var _a;
|
|
203
183
|
let cmin = min;
|
|
204
184
|
const arr = [];
|
|
205
185
|
let index = 0;
|
|
206
186
|
while (cmin <= max) {
|
|
207
|
-
arr.push(
|
|
187
|
+
arr.push(formatOption(type2, cmin));
|
|
208
188
|
if (type2 === "minute") {
|
|
209
189
|
cmin += minuteStep;
|
|
210
190
|
} else {
|
|
@@ -214,16 +194,16 @@ const DatePicker = (props) => {
|
|
|
214
194
|
index++;
|
|
215
195
|
}
|
|
216
196
|
}
|
|
217
|
-
|
|
218
|
-
|
|
197
|
+
pickerValue[columnIndex] = (_a = arr[index]) == null ? void 0 : _a.value;
|
|
198
|
+
setPickerValue([...pickerValue]);
|
|
219
199
|
if (props.filter && props.filter(type2, arr)) {
|
|
220
200
|
return props.filter(type2, arr);
|
|
221
201
|
}
|
|
222
202
|
return arr;
|
|
223
203
|
};
|
|
224
204
|
const getDateIndex = (type2) => {
|
|
225
|
-
const date = new Date(
|
|
226
|
-
if (!
|
|
205
|
+
const date = new Date(selectedDate);
|
|
206
|
+
if (!selectedDate)
|
|
227
207
|
return 0;
|
|
228
208
|
if (type2 === "year") {
|
|
229
209
|
return date.getFullYear();
|
|
@@ -247,16 +227,16 @@ const DatePicker = (props) => {
|
|
|
247
227
|
};
|
|
248
228
|
const columns = () => {
|
|
249
229
|
const val = ranges().map((res, columnIndex) => {
|
|
250
|
-
return
|
|
230
|
+
return generateColumn(res.range[0], res.range[1], getDateIndex(res.type), res.type, columnIndex);
|
|
251
231
|
});
|
|
252
232
|
return val || [];
|
|
253
233
|
};
|
|
254
234
|
useEffect(() => {
|
|
255
|
-
if (
|
|
256
|
-
|
|
235
|
+
if (selectedDate) {
|
|
236
|
+
setPickerOptions(columns());
|
|
257
237
|
}
|
|
258
|
-
}, [
|
|
259
|
-
return React__default.createElement(View, { className: `nut-datepicker ${className}`, style, catchMove: true, ...rest },
|
|
238
|
+
}, [selectedDate, startDate, endDate]);
|
|
239
|
+
return React__default.createElement(View, { className: `nut-datepicker ${className}`, style, catchMove: true, ...rest }, pickerOptions.length && React__default.createElement(Picker, { ...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 }));
|
|
260
240
|
};
|
|
261
241
|
DatePicker.defaultProps = defaultProps;
|
|
262
242
|
DatePicker.displayName = "NutDatePicker";
|