@nutui/nutui-react-taro 2.0.0-alpha.15 → 2.0.0-alpha.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/esm/DatePicker.js +2 -2
  3. package/dist/esm/Dialog/style/index.js +1 -0
  4. package/dist/esm/Dialog/style/style.css +1 -1
  5. package/dist/esm/Menu/style/style.css +1 -1
  6. package/dist/esm/MenuItem/style/style.css +1 -1
  7. package/dist/esm/MenuItem.js +1 -1
  8. package/dist/esm/NoticeBar.js +1 -1
  9. package/dist/esm/Picker.js +1 -1
  10. package/dist/esm/{datepicker.taro-8c9230b6.js → datepicker.taro-b480d072.js} +43 -45
  11. package/dist/esm/{menuitem.taro-6aa35a00.js → menuitem.taro-7f8c12cf.js} +11 -8
  12. package/dist/esm/{noticebar.taro-8d496dd6.js → noticebar.taro-dc895cc5.js} +1 -1
  13. package/dist/esm/nutui-react.es.js +4 -4
  14. package/dist/esm/{picker.taro-6b672469.js → picker.taro-3781a455.js} +1 -1
  15. package/dist/esm/types/src/packages/datepicker/datepicker.d.ts +11 -17
  16. package/dist/esm/types/src/packages/datepicker/datepicker.taro.d.ts +11 -17
  17. package/dist/esm/types/src/packages/datepicker/index.d.ts +1 -0
  18. package/dist/esm/types/src/packages/datepicker/index.taro.d.ts +1 -0
  19. package/dist/esm/types/src/packages/toast/Notification.d.ts +4 -1
  20. package/dist/locales/base.js +1 -1
  21. package/dist/locales/en-US.js +1 -1
  22. package/dist/locales/id-ID.js +1 -1
  23. package/dist/locales/tr-TR.js +1 -1
  24. package/dist/locales/zh-CN.js +1 -1
  25. package/dist/locales/zh-TW.js +1 -1
  26. package/dist/locales/zh-UG.js +1 -1
  27. package/dist/nutui.react.es.js +138 -129
  28. package/dist/nutui.react.umd.js +138 -129
  29. package/dist/packages/menuitem/menuitem.scss +1 -1
  30. package/dist/packages/noticebar/noticebar.scss +0 -3
  31. package/dist/style.css +1 -1
  32. package/dist/style.mjs +1 -1
  33. package/dist/types/packages/datepicker/datepicker.taro.d.ts +11 -17
  34. package/dist/types/packages/datepicker/index.taro.d.ts +1 -0
  35. package/dist/types/packages/picker/index.d.ts +4 -0
  36. package/dist/types/packages/picker/picker.d.ts +18 -0
  37. package/dist/types/packages/picker/pickerpanel.d.ts +15 -0
  38. package/dist/types/packages/popup/index.d.ts +3 -0
  39. package/dist/types/packages/popup/popup.d.ts +22 -0
  40. package/package.json +1 -1
@@ -5,7 +5,7 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  /*!
8
- * @nutui/nutui-react-taro v2.0.0-alpha.15 Wed Jun 07 2023 16:24:05 GMT+0800 (China Standard Time)
8
+ * @nutui/nutui-react-taro v2.0.0-alpha.16 Fri Jun 09 2023 18:38:16 GMT+0800 (China Standard Time)
9
9
  * (c) 2023 @jdf2e.
10
10
  * Released under the MIT License.
11
11
  */
@@ -8880,7 +8880,7 @@ const InternalPicker = (props, ref) => {
8880
8880
  {
8881
8881
  visible,
8882
8882
  position: "bottom",
8883
- onClose: () => {
8883
+ afterClose: () => {
8884
8884
  closePicker();
8885
8885
  }
8886
8886
  },
@@ -8929,29 +8929,29 @@ const Picker = React.forwardRef(InternalPicker);
8929
8929
  const Picker$1 = Picker;
8930
8930
  const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
8931
8931
  const defaultProps$X = {
8932
- modelValue: null,
8932
+ ...ComponentDefaults,
8933
8933
  visible: false,
8934
8934
  title: "",
8935
8935
  type: "date",
8936
- isShowChinese: false,
8936
+ showChinese: false,
8937
8937
  threeDimensional: true,
8938
8938
  minuteStep: 1,
8939
- minDate: new Date(currentYear - 10, 0, 1),
8940
- maxDate: new Date(currentYear + 10, 11, 31)
8939
+ startDate: new Date(currentYear - 10, 0, 1),
8940
+ endDate: new Date(currentYear + 10, 11, 31)
8941
8941
  };
8942
8942
  const DatePicker = (props) => {
8943
8943
  const {
8944
- minDate,
8945
- maxDate,
8944
+ startDate,
8945
+ endDate,
8946
8946
  type,
8947
- isShowChinese,
8947
+ showChinese,
8948
8948
  minuteStep,
8949
- modelValue,
8950
8949
  visible,
8951
8950
  title,
8951
+ defaultValue,
8952
8952
  formatter,
8953
- onCloseDatePicker,
8954
- onConfirmDatePicker,
8953
+ onClose,
8954
+ onConfirm,
8955
8955
  filter,
8956
8956
  onChange,
8957
8957
  threeDimensional,
@@ -8963,14 +8963,6 @@ const DatePicker = (props) => {
8963
8963
  ...props
8964
8964
  };
8965
8965
  const { locale } = useConfig$1();
8966
- const [show, setShow] = useState(false);
8967
- const [currentDate, setCurrentDate] = useState(modelValue);
8968
- const [defaultValue, setDefaultValue] = useState([]);
8969
- const [options, setListData] = useState([]);
8970
- const pickerRef = useRef(null);
8971
- const isDate = (val) => {
8972
- return Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
8973
- };
8974
8966
  const datepickerLang = locale.datepicker;
8975
8967
  const zhCNType = {
8976
8968
  day: datepickerLang.day,
@@ -8980,20 +8972,32 @@ const DatePicker = (props) => {
8980
8972
  minute: datepickerLang.min,
8981
8973
  seconds: datepickerLang.seconds
8982
8974
  };
8975
+ const [defaultValueOfPicker, setDefaultValueOfPicker] = useState([]);
8976
+ const [options, setOptions] = useState([]);
8977
+ const isDate = (val) => {
8978
+ return Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
8979
+ };
8983
8980
  const formatValue = (value) => {
8984
8981
  let cvalue = value;
8985
8982
  if (!cvalue || cvalue && !isDate(cvalue)) {
8986
- cvalue = minDate;
8983
+ cvalue = startDate;
8987
8984
  }
8988
- let timestmp = Math.max(cvalue.getTime(), minDate.getTime());
8989
- timestmp = Math.min(timestmp, maxDate.getTime());
8985
+ let timestmp = Math.max(cvalue.getTime(), startDate.getTime());
8986
+ timestmp = Math.min(timestmp, endDate.getTime());
8990
8987
  return new Date(timestmp);
8991
8988
  };
8989
+ const [currentDate, setCurrentDate] = usePropsValue({
8990
+ value: props.value && formatValue(props.value),
8991
+ defaultValue: formatValue(props.defaultValue || null),
8992
+ finalValue: null,
8993
+ onChange: (val) => {
8994
+ }
8995
+ });
8992
8996
  function getMonthEndDay(year, month) {
8993
8997
  return new Date(year, month, 0).getDate();
8994
8998
  }
8995
8999
  const getBoundary = (type2, value) => {
8996
- const boundary = type2 === "min" ? minDate : maxDate;
9000
+ const boundary = type2 === "min" ? startDate : endDate;
8997
9001
  const year = boundary.getFullYear();
8998
9002
  let month = 1;
8999
9003
  let date = 1;
@@ -9027,12 +9031,12 @@ const DatePicker = (props) => {
9027
9031
  [`${type2}Seconds`]: seconds
9028
9032
  };
9029
9033
  };
9030
- const ranges = (date) => {
9031
- const curDate = date || currentDate;
9034
+ const ranges = () => {
9035
+ const curDate = currentDate;
9032
9036
  if (!curDate)
9033
9037
  return [];
9034
- const { maxYear, maxDate: maxDate2, maxMonth, maxHour, maxMinute, maxSeconds } = getBoundary("max", curDate);
9035
- const { minYear, minDate: minDate2, minMonth, minHour, minMinute, minSeconds } = getBoundary("min", curDate);
9038
+ const { maxYear, maxDate, maxMonth, maxHour, maxMinute, maxSeconds } = getBoundary("max", curDate);
9039
+ const { minYear, minDate, minMonth, minHour, minMinute, minSeconds } = getBoundary("min", curDate);
9036
9040
  let result = [
9037
9041
  {
9038
9042
  type: "year",
@@ -9044,7 +9048,7 @@ const DatePicker = (props) => {
9044
9048
  },
9045
9049
  {
9046
9050
  type: "day",
9047
- range: [minDate2, maxDate2]
9051
+ range: [minDate, maxDate]
9048
9052
  },
9049
9053
  {
9050
9054
  type: "hour",
@@ -9084,7 +9088,7 @@ const DatePicker = (props) => {
9084
9088
  }
9085
9089
  return result;
9086
9090
  };
9087
- const updateChooseValueCustmer = (cacheValueData, selectedValue, index) => {
9091
+ const updateChooseValueCustmer = (selectedOptions, selectedValue, index) => {
9088
9092
  if (["date", "datetime", "datehour", "month-day", "year-month"].includes(
9089
9093
  type.toLocaleLowerCase()
9090
9094
  )) {
@@ -9094,11 +9098,13 @@ const DatePicker = (props) => {
9094
9098
  });
9095
9099
  if (type.toLocaleLowerCase() === "month-day" && formatDate.length < 3) {
9096
9100
  formatDate.unshift(
9097
- new Date(modelValue || minDate || maxDate).getFullYear()
9101
+ new Date(defaultValue || startDate || endDate).getFullYear()
9098
9102
  );
9099
9103
  }
9100
9104
  if (type.toLocaleLowerCase() === "year-month" && formatDate.length < 3) {
9101
- formatDate.push(new Date(modelValue || minDate || maxDate).getDate());
9105
+ formatDate.push(
9106
+ new Date(defaultValue || startDate || endDate).getDate()
9107
+ );
9102
9108
  }
9103
9109
  const year = Number(formatDate[0]);
9104
9110
  const month = Number(formatDate[1]) - 1;
@@ -9123,7 +9129,7 @@ const DatePicker = (props) => {
9123
9129
  const isEqual = (currentDate == null ? void 0 : currentDate.getTime()) === (date == null ? void 0 : date.getTime());
9124
9130
  date && isDate(date) && !isEqual && setCurrentDate(formatValue(date));
9125
9131
  }
9126
- props.onChange && props.onChange(cacheValueData, selectedValue, index);
9132
+ props.onChange && props.onChange(selectedOptions, selectedValue, index);
9127
9133
  };
9128
9134
  const padZero = (num, targetLength = 2) => {
9129
9135
  let str = `${num}`;
@@ -9141,12 +9147,13 @@ const DatePicker = (props) => {
9141
9147
  });
9142
9148
  } else {
9143
9149
  const padMin = padZero(value, 2);
9144
- const fatter = isShowChinese ? zhCNType[type2] : "";
9150
+ const fatter = showChinese ? zhCNType[type2] : "";
9145
9151
  fOption = { text: padMin + fatter, value: padMin };
9146
9152
  }
9147
9153
  return fOption;
9148
9154
  };
9149
9155
  const generateValue = (min, max, val, type2, columnIndex) => {
9156
+ var _a;
9150
9157
  let cmin = min;
9151
9158
  const arr = [];
9152
9159
  let index = 0;
@@ -9161,8 +9168,8 @@ const DatePicker = (props) => {
9161
9168
  index++;
9162
9169
  }
9163
9170
  }
9164
- defaultValue[columnIndex] = arr[index].value;
9165
- setDefaultValue([...defaultValue]);
9171
+ defaultValueOfPicker[columnIndex] = (_a = arr[index]) == null ? void 0 : _a.value;
9172
+ setDefaultValueOfPicker([...defaultValueOfPicker]);
9166
9173
  if (props.filter && props.filter(type2, arr)) {
9167
9174
  return props.filter(type2, arr);
9168
9175
  }
@@ -9187,8 +9194,8 @@ const DatePicker = (props) => {
9187
9194
  }
9188
9195
  return d;
9189
9196
  };
9190
- const columns = (date) => {
9191
- const val = ranges(date).map((res, columnIndex) => {
9197
+ const columns = () => {
9198
+ const val = ranges().map((res, columnIndex) => {
9192
9199
  return generateValue(
9193
9200
  res.range[0],
9194
9201
  res.range[1],
@@ -9199,40 +9206,30 @@ const DatePicker = (props) => {
9199
9206
  });
9200
9207
  return val || [];
9201
9208
  };
9202
- useEffect(() => {
9203
- setCurrentDate(formatValue(modelValue));
9204
- }, []);
9205
- useEffect(() => {
9206
- setCurrentDate(formatValue(modelValue));
9207
- }, [modelValue]);
9208
- useEffect(() => {
9209
- setShow(visible);
9210
- }, [visible]);
9211
9209
  useEffect(() => {
9212
9210
  if (currentDate) {
9213
- setListData(columns());
9211
+ setOptions(columns());
9214
9212
  }
9215
- }, [currentDate]);
9213
+ }, []);
9216
9214
  return /* @__PURE__ */ React.createElement(
9217
9215
  View,
9218
9216
  {
9219
- className: `nut-datepicker ${className || ""}`,
9217
+ className: `nut-datepicker ${className}`,
9220
9218
  style,
9221
9219
  catchMove: true,
9222
9220
  ...rest
9223
9221
  },
9224
- options.length > 0 && /* @__PURE__ */ React.createElement(
9222
+ options.length && /* @__PURE__ */ React.createElement(
9225
9223
  Picker$1,
9226
9224
  {
9227
9225
  title,
9228
- visible: show,
9226
+ visible,
9229
9227
  options,
9230
- onClose: onCloseDatePicker,
9231
- defaultValue,
9232
- onConfirm: (options2, values) => onConfirmDatePicker && onConfirmDatePicker(options2, values),
9233
- onChange: (list, value, index) => updateChooseValueCustmer(list, value, index),
9234
- threeDimensional,
9235
- ref: pickerRef
9228
+ onClose,
9229
+ defaultValue: defaultValueOfPicker,
9230
+ onConfirm: (options2, value) => onConfirm && onConfirm(options2, value),
9231
+ onChange: (options2, value, index) => updateChooseValueCustmer(options2, value, index),
9232
+ threeDimensional
9236
9233
  }
9237
9234
  )
9238
9235
  );
@@ -10174,103 +10171,115 @@ const MenuItem = forwardRef((props, ref) => {
10174
10171
  return { display: "none" };
10175
10172
  };
10176
10173
  const getPosition = () => {
10177
- return direction === "down" ? { top: `${position.top + position.height}px` } : {
10178
- bottom: `${getSystemInfoSync().windowHeight - position.top}px`,
10179
- top: "auto"
10174
+ return direction === "down" ? { position: "absolute", height: `${window.innerHeight}px` } : {
10175
+ position: "absolute",
10176
+ bottom: "100%",
10177
+ top: "auto",
10178
+ height: `${window.innerHeight}px`
10180
10179
  };
10181
10180
  };
10182
10181
  const placeholderStyle = () => {
10183
10182
  if (direction === "down") {
10184
10183
  return {
10185
10184
  height: `${position.top + position.height}px`,
10186
- top: 0,
10185
+ top: "auto",
10186
+ bottom: "-100%",
10187
10187
  ...isShow()
10188
10188
  };
10189
10189
  }
10190
10190
  return {
10191
10191
  height: `${getSystemInfoSync().windowHeight - position.top}px`,
10192
- bottom: `0px`,
10193
- top: "auto",
10192
+ bottom: `auto`,
10193
+ top: "0",
10194
10194
  ...isShow()
10195
10195
  };
10196
10196
  };
10197
- return /* @__PURE__ */ React.createElement(React.Fragment, null, closeOnClickAway ? /* @__PURE__ */ React.createElement(
10197
+ return /* @__PURE__ */ React.createElement(
10198
10198
  "div",
10199
10199
  {
10200
- className: `placeholder-element ${classNames({
10201
- up: direction === "up"
10202
- })}`,
10203
- style: placeholderStyle(),
10204
- onClick: () => parent.toggleMenuItem(index)
10205
- }
10206
- ) : null, /* @__PURE__ */ React.createElement(
10207
- Overlay$1,
10208
- {
10209
- className: "nut-menu__overlay",
10210
- style: getPosition(),
10211
- lockScroll: parent.lockScroll,
10212
- visible: _showPopup,
10213
- closeOnOverlayClick: parent.closeOnOverlayClick,
10214
- onClick: () => {
10215
- parent.closeOnOverlayClick && parent.toggleMenuItem(index);
10200
+ className: "nut-menu-item-container",
10201
+ style: { position: "absolute", left: 0, right: 0 }
10202
+ },
10203
+ closeOnClickAway ? /* @__PURE__ */ React.createElement(
10204
+ "div",
10205
+ {
10206
+ className: `placeholder-element ${classNames({
10207
+ up: direction === "up"
10208
+ })}`,
10209
+ style: placeholderStyle(),
10210
+ onClick: () => parent.toggleMenuItem(index)
10216
10211
  }
10217
- }
10218
- ), /* @__PURE__ */ React.createElement(
10219
- "div",
10220
- {
10221
- className: classNames(className, {
10222
- "nut-menu-item__wrap": direction === "down",
10223
- "nut-menu-item__wrap-up": direction !== "down"
10224
- }),
10225
- style: {
10226
- ...style,
10227
- ...isShow()
10212
+ ) : null,
10213
+ /* @__PURE__ */ React.createElement(
10214
+ Overlay$1,
10215
+ {
10216
+ className: "nut-menu__overlay",
10217
+ style: getPosition(),
10218
+ lockScroll: parent.lockScroll,
10219
+ visible: _showPopup,
10220
+ closeOnOverlayClick: parent.closeOnOverlayClick,
10221
+ onClick: () => {
10222
+ parent.closeOnOverlayClick && parent.toggleMenuItem(index);
10223
+ }
10228
10224
  }
10229
- },
10225
+ ),
10230
10226
  /* @__PURE__ */ React.createElement(
10231
- CSSTransition$1,
10227
+ "div",
10232
10228
  {
10233
- in: _showPopup,
10234
- timeout: 100,
10235
- classNames: direction === "down" ? "menu-item" : "menu-item-up"
10229
+ className: classNames(className, {
10230
+ "nut-menu-item__wrap": direction === "down",
10231
+ "nut-menu-item__wrap-up": direction !== "down"
10232
+ }),
10233
+ style: {
10234
+ ...style,
10235
+ ...isShow()
10236
+ }
10236
10237
  },
10237
- /* @__PURE__ */ React.createElement("div", { className: "nut-menu-item__content" }, options == null ? void 0 : options.map((item, index2) => {
10238
- return /* @__PURE__ */ React.createElement(
10239
- "div",
10240
- {
10241
- className: `nut-menu-item__option ${classNames({
10242
- active: item.value === _value
10243
- })}`,
10244
- key: item.text,
10245
- style: {
10246
- flexBasis: `${100 / columns}%`
10247
- },
10248
- onClick: () => {
10249
- handleClick(item);
10250
- }
10251
- },
10252
- item.value === _value ? /* @__PURE__ */ React.createElement(React.Fragment, null, icon || /* @__PURE__ */ React.createElement(
10253
- a$t,
10254
- {
10255
- color: activeColor,
10256
- size: 10,
10257
- className: getIconCName(item.value, value)
10258
- }
10259
- )) : null,
10260
- /* @__PURE__ */ React.createElement(
10238
+ /* @__PURE__ */ React.createElement(
10239
+ CSSTransition$1,
10240
+ {
10241
+ in: _showPopup,
10242
+ timeout: 100,
10243
+ classNames: direction === "down" ? "menu-item" : "menu-item-up"
10244
+ },
10245
+ /* @__PURE__ */ React.createElement("div", { className: "nut-menu-item__content" }, options == null ? void 0 : options.map((item, index2) => {
10246
+ return /* @__PURE__ */ React.createElement(
10261
10247
  "div",
10262
10248
  {
10263
- className: getIconCName(item.value, value),
10249
+ className: `nut-menu-item__option ${classNames({
10250
+ active: item.value === _value
10251
+ })}`,
10252
+ key: item.text,
10264
10253
  style: {
10265
- color: `${item.value === _value ? activeColor : ""}`
10254
+ flexBasis: `${100 / columns}%`
10255
+ },
10256
+ onClick: () => {
10257
+ handleClick(item);
10266
10258
  }
10267
10259
  },
10268
- item.text
10269
- )
10270
- );
10271
- }), children)
10260
+ item.value === _value ? /* @__PURE__ */ React.createElement(React.Fragment, null, icon || /* @__PURE__ */ React.createElement(
10261
+ a$t,
10262
+ {
10263
+ color: activeColor,
10264
+ size: 10,
10265
+ className: getIconCName(item.value, value)
10266
+ }
10267
+ )) : null,
10268
+ /* @__PURE__ */ React.createElement(
10269
+ "div",
10270
+ {
10271
+ className: getIconCName(item.value, value),
10272
+ style: {
10273
+ color: `${item.value === _value ? activeColor : ""}`
10274
+ }
10275
+ },
10276
+ item.text
10277
+ )
10278
+ );
10279
+ }), children)
10280
+ )
10272
10281
  )
10273
- ));
10282
+ );
10274
10283
  });
10275
10284
  MenuItem.defaultProps = defaultProps$R;
10276
10285
  MenuItem.displayName = "NutMenuItem";
@@ -13122,7 +13131,7 @@ const NoticeBar = (props) => {
13122
13131
  "nut-noticebar-page": true,
13123
13132
  withicon: closeable,
13124
13133
  close: closeable,
13125
- wrap
13134
+ wrapable: wrap
13126
13135
  });
13127
13136
  useEffect(() => {
13128
13137
  return () => {