@nutui/nutui-react-taro 2.0.16 → 2.0.17

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 (85) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/esm/Address.js +2 -2
  3. package/dist/esm/Audio.js +3 -3
  4. package/dist/esm/Avatar.js +1 -1
  5. package/dist/esm/Cascader.js +1 -1
  6. package/dist/esm/DatePicker.js +3 -3
  7. package/dist/esm/Ellipsis.js +2 -2
  8. package/dist/esm/Form/style/style.css +1 -1
  9. package/dist/esm/Form.js +53 -3
  10. package/dist/esm/FormItem/style/style.css +1 -1
  11. package/dist/esm/FormItem.js +1 -1
  12. package/dist/esm/InputNumber.js +1 -1
  13. package/dist/esm/Menu.js +3 -3
  14. package/dist/esm/MenuItem.js +2 -2
  15. package/dist/esm/NoticeBar.js +3 -2
  16. package/dist/esm/Picker.js +2 -2
  17. package/dist/esm/Popover.js +2 -2
  18. package/dist/esm/PullToRefresh.js +1 -1
  19. package/dist/esm/Range.js +3 -2
  20. package/dist/esm/Skeleton.js +2 -2
  21. package/dist/esm/Sticky.js +2 -2
  22. package/dist/esm/Swipe.js +2 -2
  23. package/dist/esm/Table.js +1 -1
  24. package/dist/esm/Toast.js +2 -1
  25. package/dist/esm/Tour.js +3 -3
  26. package/dist/esm/TrendArrow.js +1 -1
  27. package/dist/esm/VirtualList.js +1 -1
  28. package/dist/esm/{address.taro-6d420871.js → address.taro-319deb0d.js} +1 -1
  29. package/dist/esm/{audio.taro-ef39c1d9.js → audio.taro-f0ec6410.js} +2 -3
  30. package/dist/esm/{avatar.taro-47abbb9f.js → avatar.taro-0e574535.js} +1 -1
  31. package/dist/esm/{cascader.taro-01ffbfb1.js → cascader.taro-8d41895a.js} +2 -1
  32. package/dist/esm/{datepicker.taro-288d64bb.js → datepicker.taro-4da6a538.js} +1 -1
  33. package/dist/esm/{ellipsis.taro-21b13b31.js → ellipsis.taro-cd36ab2d.js} +4 -4
  34. package/dist/esm/{formitem.taro-bb63ac0a.js → formitem.taro-d69dce1e.js} +28 -10
  35. package/dist/esm/{use-client-rect-2bb6c562.js → get-rect-by-taro-fe02fe2b.js} +21 -3
  36. package/dist/esm/{inputnumber.taro-2f6f30d7.js → inputnumber.taro-d2fc26bd.js} +2 -2
  37. package/dist/esm/{menu.taro-4cde3e7f.js → menu.taro-0727ce5f.js} +1 -1
  38. package/dist/esm/{menuitem.taro-8a60a655.js → menuitem.taro-a4d83b53.js} +1 -1
  39. package/dist/esm/{noticebar.taro-d95c13b6.js → noticebar.taro-4e1d882b.js} +2 -2
  40. package/dist/esm/nutui-react.es.js +24 -24
  41. package/dist/esm/{picker.taro-0770a67f.js → picker.taro-47d1c716.js} +4 -4
  42. package/dist/esm/{popover.taro-7a482b85.js → popover.taro-43e96169.js} +1 -1
  43. package/dist/esm/{pulltorefresh.taro-d35571e8.js → pulltorefresh.taro-f3ab76c2.js} +4 -6
  44. package/dist/esm/{range.taro-fbbf5522.js → range.taro-4028c748.js} +1 -1
  45. package/dist/esm/{skeleton.taro-1896ff37.js → skeleton.taro-1f829d87.js} +1 -1
  46. package/dist/esm/{sticky.taro-2d78a04e.js → sticky.taro-dbacaf76.js} +1 -1
  47. package/dist/esm/{swipe.taro-2fa2479c.js → swipe.taro-385eece1.js} +1 -1
  48. package/dist/esm/{table.taro-072907bf.js → table.taro-a7dcb564.js} +5 -5
  49. package/dist/esm/{toast.taro-44ebc833.js → toast.taro-50ee73e6.js} +30 -19
  50. package/dist/esm/{tour.taro-3299d7a2.js → tour.taro-5185292f.js} +1 -1
  51. package/dist/esm/{trendarrow.taro-53d6e250.js → trendarrow.taro-e6b635ae.js} +1 -1
  52. package/dist/esm/types/src/packages/cascader/cascader.d.ts +2 -1
  53. package/dist/esm/types/src/packages/cascader/cascader.taro.d.ts +2 -1
  54. package/dist/esm/types/src/packages/form/types.d.ts +1 -0
  55. package/dist/esm/types/src/packages/formitem/formitem.d.ts +1 -0
  56. package/dist/esm/types/src/packages/formitem/formitem.taro.d.ts +1 -0
  57. package/dist/esm/types/src/packages/table/types.d.ts +1 -1
  58. package/dist/esm/types/src/packages/toast/toast.taro.d.ts +3 -6
  59. package/dist/esm/types/src/packages/virtuallist/utils.d.ts +1 -1
  60. package/dist/esm/types/src/utils/get-rect-by-taro.d.ts +12 -0
  61. package/dist/esm/types/src/utils/use-client-rect.d.ts +3 -9
  62. package/dist/esm/types/src/utils/use-uuid.d.ts +1 -0
  63. package/dist/esm/{virtuallist.taro-e552d954.js → virtuallist.taro-c75a4e71.js} +2 -2
  64. package/dist/locales/base.js +1 -1
  65. package/dist/locales/en-US.js +1 -1
  66. package/dist/locales/id-ID.js +1 -1
  67. package/dist/locales/tr-TR.js +1 -1
  68. package/dist/locales/zh-CN.js +1 -1
  69. package/dist/locales/zh-TW.js +1 -1
  70. package/dist/locales/zh-UG.js +1 -1
  71. package/dist/nutui.react.es.js +187 -78
  72. package/dist/nutui.react.umd.js +186 -77
  73. package/dist/packages/form/form.scss +9 -1
  74. package/dist/packages/formitem/formitem.scss +0 -11
  75. package/dist/style.css +1 -1
  76. package/dist/style.mjs +1 -1
  77. package/dist/types/packages/cascader/cascader.taro.d.ts +2 -1
  78. package/dist/types/packages/form/types.d.ts +1 -0
  79. package/dist/types/packages/formitem/formitem.taro.d.ts +5 -0
  80. package/dist/types/packages/table/types.d.ts +1 -1
  81. package/dist/types/packages/toast/toast.taro.d.ts +3 -6
  82. package/dist/types/packages/virtuallist/utils.d.ts +1 -1
  83. package/dist/types/utils/get-rect-by-taro.d.ts +12 -0
  84. package/dist/types/utils/use-client-rect.d.ts +3 -9
  85. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react-taro v2.0.16 Wed Sep 06 2023 15:52:38 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react-taro v2.0.17 Wed Sep 13 2023 17:18:36 GMT+0800 (中国标准时间)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react-taro v2.0.16 Wed Sep 06 2023 15:52:38 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react-taro v2.0.17 Wed Sep 13 2023 17:18:36 GMT+0800 (中国标准时间)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react-taro v2.0.16 Wed Sep 06 2023 15:52:38 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react-taro v2.0.17 Wed Sep 13 2023 17:18:36 GMT+0800 (中国标准时间)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -5,13 +5,13 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  /*!
8
- * @nutui/nutui-react-taro v2.0.16 Wed Sep 06 2023 15:51:52 GMT+0800 (China Standard Time)
8
+ * @nutui/nutui-react-taro v2.0.17 Wed Sep 13 2023 17:17:51 GMT+0800 (中国标准时间)
9
9
  * (c) 2023 @jdf2e.
10
10
  * Released under the MIT License.
11
11
  */
12
12
  import * as React from "react";
13
13
  import React__default, { useCallback, createContext, useContext, useState, useEffect, useRef, useMemo as useMemo$1, isValidElement, forwardRef, useImperativeHandle, Component, Children } from "react";
14
- import Taro, { getEnv, usePageScroll, getSystemInfoSync, pageScrollTo, nextTick, createSelectorQuery, ENV_TYPE, canvasToTempFilePath, uploadFile, chooseMedia, chooseImage, Events, getCurrentInstance, useReady, createInnerAudioContext, getSystemInfo, createOffscreenCanvas } from "@tarojs/taro";
14
+ import Taro, { getEnv, createSelectorQuery, usePageScroll, getSystemInfoSync, pageScrollTo, nextTick, ENV_TYPE, canvasToTempFilePath, uploadFile, chooseMedia, chooseImage, Events, getCurrentInstance, useReady, createInnerAudioContext, getSystemInfo, createOffscreenCanvas } from "@tarojs/taro";
15
15
  import { Image as Image$2, View, ScrollView, PickerView, PickerViewColumn, Input as Input$1, Textarea, Swiper as Swiper$1, SwiperItem as SwiperItem$1, Video as Video$1 } from "@tarojs/components";
16
16
  import ReactDOM, { createPortal } from "react-dom";
17
17
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
@@ -5459,6 +5459,7 @@ function useWatch(dep, callback, config2 = { immediate: false }) {
5459
5459
  stop.current = true;
5460
5460
  };
5461
5461
  }
5462
+ const inBrowser = typeof document !== "undefined" && !!document.scripts;
5462
5463
  function isWindow(val) {
5463
5464
  return val === window;
5464
5465
  }
@@ -5488,12 +5489,28 @@ const getRect = (elementRef) => {
5488
5489
  height: 0
5489
5490
  };
5490
5491
  };
5492
+ function makeRect(width, height) {
5493
+ return {
5494
+ top: 0,
5495
+ left: 0,
5496
+ right: width,
5497
+ bottom: height,
5498
+ width,
5499
+ height
5500
+ };
5501
+ }
5491
5502
  const getRectByTaro = async (element) => {
5492
5503
  if (element) {
5493
- const res = await element.getBoundingClientRect();
5494
- return res;
5504
+ if (inBrowser) {
5505
+ return Promise.resolve(getRect(element));
5506
+ }
5507
+ return new Promise((resolve, reject) => {
5508
+ createSelectorQuery().select(`#${element.uid}`).boundingClientRect().exec(([rects]) => {
5509
+ resolve(rects);
5510
+ });
5511
+ });
5495
5512
  }
5496
- return Promise.resolve({});
5513
+ return Promise.resolve(makeRect(0, 0));
5497
5514
  };
5498
5515
  const canUseDom = !!(typeof window !== "undefined" && typeof document !== "undefined" && window.document && window.document.createElement);
5499
5516
  const defaultRoot = canUseDom ? window : void 0;
@@ -7109,6 +7126,7 @@ const InternalCascader = (props, ref) => {
7109
7126
  activeColor,
7110
7127
  activeIcon,
7111
7128
  popup,
7129
+ popupProps = {},
7112
7130
  visible,
7113
7131
  options,
7114
7132
  value,
@@ -7404,6 +7422,7 @@ const InternalCascader = (props, ref) => {
7404
7422
  return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, popup ? /* @__PURE__ */ React__default.createElement(
7405
7423
  Popup,
7406
7424
  {
7425
+ ...popupProps,
7407
7426
  visible,
7408
7427
  position: "bottom",
7409
7428
  round: true,
@@ -8937,7 +8956,7 @@ const InternalPickerPanel = (props, ref) => {
8937
8956
  }
8938
8957
  return false;
8939
8958
  };
8940
- const setTransform = (translateY = 0, type4, time = DEFAULT_DURATION, deg) => {
8959
+ const setTransform = (type4, deg, time = DEFAULT_DURATION, translateY = 0) => {
8941
8960
  let nTime = time;
8942
8961
  if (type4 !== "end") {
8943
8962
  nTime = 0;
@@ -8957,7 +8976,7 @@ const InternalPickerPanel = (props, ref) => {
8957
8976
  }
8958
8977
  const endMove = Math.round(updateMove / lineSpacing.current) * lineSpacing.current;
8959
8978
  const deg = `${(Math.abs(Math.round(endMove / lineSpacing.current)) + 1) * rotation}deg`;
8960
- setTransform(endMove, type4, time, deg);
8979
+ setTransform(type4, deg, time, endMove);
8961
8980
  setCurrIndex(Math.abs(Math.round(endMove / lineSpacing.current)) + 1);
8962
8981
  } else {
8963
8982
  let deg = 0;
@@ -8966,7 +8985,7 @@ const InternalPickerPanel = (props, ref) => {
8966
8985
  const minDeg = 0;
8967
8986
  deg = Math.min(Math.max(currentDeg, minDeg), maxDeg);
8968
8987
  if (minDeg < deg && deg < maxDeg) {
8969
- setTransform(updateMove, "", void 0, `${deg}deg`);
8988
+ setTransform("", `${deg}deg`, void 0, updateMove);
8970
8989
  setCurrIndex(Math.abs(Math.round(updateMove / lineSpacing.current)) + 1);
8971
8990
  }
8972
8991
  }
@@ -9220,9 +9239,7 @@ const InternalPicker = (props, ref) => {
9220
9239
  while (columnOptions && columnOptions.children) {
9221
9240
  const options2 = columnOptions.children;
9222
9241
  const value = values[columnIndex2];
9223
- let index = options2.findIndex(
9224
- (columnItem) => columnItem.value === value
9225
- );
9242
+ let index = options2.findIndex((columnItem) => columnItem.value === value);
9226
9243
  if (index === -1)
9227
9244
  index = 0;
9228
9245
  columnOptions = columnOptions.children[index];
@@ -10853,7 +10870,7 @@ class FormStore {
10853
10870
  __publicField(this, "fieldEntities", []);
10854
10871
  // 校验成功或失败的回调,onFinish、onFinishFailed
10855
10872
  __publicField(this, "callbacks", {});
10856
- __publicField(this, "errors", []);
10873
+ __publicField(this, "errors", {});
10857
10874
  /**
10858
10875
  * 注册组件实例
10859
10876
  * @param field
@@ -10875,6 +10892,19 @@ class FormStore {
10875
10892
  var _a;
10876
10893
  return (_a = this.store) == null ? void 0 : _a[name];
10877
10894
  });
10895
+ /**
10896
+ * 获取全部字段
10897
+ */
10898
+ __publicField(this, "getFieldsValue", (name) => {
10899
+ if (typeof name === "boolean") {
10900
+ return JSON.parse(JSON.stringify(this.store));
10901
+ }
10902
+ const fieldsValue = {};
10903
+ name.forEach((field) => {
10904
+ fieldsValue[field] = this.getFieldValue(field);
10905
+ });
10906
+ return fieldsValue;
10907
+ });
10878
10908
  /**
10879
10909
  * 设置 form 的初始值,之后在 reset 的时候使用
10880
10910
  * @param values
@@ -10932,13 +10962,45 @@ class FormStore {
10932
10962
  validator.validate({ [name]: (_a = this.store) == null ? void 0 : _a[name] }, (errors) => {
10933
10963
  if (errors) {
10934
10964
  err.push(...errors);
10935
- this.errors.push(...errors);
10965
+ this.errors[name] = errors;
10936
10966
  }
10937
10967
  entity.onStoreChange("validate");
10938
10968
  });
10939
10969
  });
10940
10970
  return err;
10941
10971
  });
10972
+ __publicField(this, "validateFields", (nameList) => {
10973
+ if (!nameList || nameList.length === 0) {
10974
+ this.validate();
10975
+ return;
10976
+ }
10977
+ this.fieldEntities.filter(({ props: { name } }) => {
10978
+ return nameList.includes(name);
10979
+ }).forEach((entity) => {
10980
+ var _a;
10981
+ const { name, rules: rules2 = [] } = entity.props;
10982
+ const descriptor = {};
10983
+ if (rules2.length) {
10984
+ if (rules2.length > 1) {
10985
+ descriptor[name] = [];
10986
+ rules2.forEach((v) => {
10987
+ descriptor[name].push(v);
10988
+ });
10989
+ } else {
10990
+ descriptor[name] = rules2[0];
10991
+ }
10992
+ }
10993
+ const validator = new Schema(descriptor);
10994
+ validator.messages();
10995
+ validator.validate({ [name]: (_a = this.store) == null ? void 0 : _a[name] }, (errors) => {
10996
+ this.errors[name] = [];
10997
+ if (errors) {
10998
+ this.errors[name] = errors;
10999
+ }
11000
+ entity.onStoreChange("validate");
11001
+ });
11002
+ });
11003
+ });
10942
11004
  __publicField(this, "submit", () => {
10943
11005
  var _a, _b, _c, _d;
10944
11006
  const errors = this.validate();
@@ -10955,12 +11017,17 @@ class FormStore {
10955
11017
  entity.onStoreChange("reset");
10956
11018
  });
10957
11019
  });
11020
+ __publicField(this, "dispatch", ({ name }) => {
11021
+ this.validateFields([name]);
11022
+ });
10958
11023
  __publicField(this, "getForm", () => {
10959
11024
  return {
11025
+ dispatch: this.dispatch,
10960
11026
  setInitialValues: this.setInitialValues,
10961
11027
  setCallback: this.setCallback,
10962
11028
  registerField: this.registerField,
10963
11029
  getFieldValue: this.getFieldValue,
11030
+ getFieldsValue: this.getFieldsValue,
10964
11031
  setFieldsValue: this.setFieldsValue,
10965
11032
  resetFields: this.resetFields,
10966
11033
  submit: this.submit,
@@ -11081,7 +11148,8 @@ const defaultProps$X = {
11081
11148
  name: "",
11082
11149
  label: "",
11083
11150
  rules: [{ required: false, message: "" }],
11084
- errorMessageAlign: "left"
11151
+ errorMessageAlign: "left",
11152
+ validateTrigger: "onChange"
11085
11153
  };
11086
11154
  class FormItem extends React__default.Component {
11087
11155
  constructor(props) {
@@ -11091,14 +11159,15 @@ class FormItem extends React__default.Component {
11091
11159
  // children添加value属性和onChange事件
11092
11160
  __publicField(this, "getControlled", (children) => {
11093
11161
  var _a;
11094
- const { setFieldsValue, getFieldValue } = this.context;
11162
+ const { setFieldsValue, getFieldValue, dispatch } = this.context;
11095
11163
  const { name = "" } = this.props;
11096
11164
  if ((_a = children == null ? void 0 : children.props) == null ? void 0 : _a.defaultValue) {
11097
11165
  console.warn("通过 initialValue 设置初始值");
11098
11166
  }
11167
+ const fieldValue = getFieldValue(name);
11099
11168
  const controlled = {
11100
11169
  ...children.props,
11101
- [this.props.valuePropName || "value"]: getFieldValue(name) === void 0 ? this.props.initialValue : getFieldValue(name),
11170
+ [this.props.valuePropName || "value"]: fieldValue !== void 0 ? fieldValue : this.props.initialValue,
11102
11171
  [this.props.trigger || "onChange"]: (...args) => {
11103
11172
  const originOnChange = children.props[this.props.trigger || "onChange"];
11104
11173
  if (originOnChange) {
@@ -11111,6 +11180,24 @@ class FormItem extends React__default.Component {
11111
11180
  setFieldsValue({ [name]: next });
11112
11181
  }
11113
11182
  };
11183
+ const { validateTrigger } = this.props;
11184
+ let validateTriggers = [this.props.trigger || "onChange"];
11185
+ if (validateTrigger) {
11186
+ validateTriggers = typeof validateTrigger === "string" ? [...validateTriggers, validateTrigger] : [...validateTriggers, ...validateTrigger];
11187
+ validateTriggers.forEach((trigger) => {
11188
+ const originTrigger = controlled[trigger];
11189
+ controlled[trigger] = (...args) => {
11190
+ if (originTrigger) {
11191
+ originTrigger(...args);
11192
+ }
11193
+ if (this.props.rules && this.props.rules.length) {
11194
+ dispatch({
11195
+ name: this.props.name
11196
+ });
11197
+ }
11198
+ };
11199
+ });
11200
+ }
11114
11201
  if (isForwardRefComponent(children)) {
11115
11202
  controlled.ref = (componentInstance) => {
11116
11203
  const originRef = children.ref;
@@ -11140,16 +11227,22 @@ class FormItem extends React__default.Component {
11140
11227
  }
11141
11228
  });
11142
11229
  __publicField(this, "renderLayout", (childNode) => {
11143
- var _a, _b;
11144
- const { label, name, required: required4, className, style, errorMessageAlign } = {
11230
+ const {
11231
+ label,
11232
+ name,
11233
+ required: required4,
11234
+ rules: rules2,
11235
+ className,
11236
+ style,
11237
+ errorMessageAlign
11238
+ } = {
11145
11239
  ...defaultProps$X,
11146
11240
  ...this.props
11147
11241
  };
11148
- const item = ((_a = this.context.errors) == null ? void 0 : _a.length) > 0 && ((_b = this.context.errors) == null ? void 0 : _b.filter((item2) => {
11149
- return item2.field === name;
11150
- }));
11242
+ const requiredInRules = rules2 == null ? void 0 : rules2.some((rule) => rule.required);
11243
+ const item = name ? this.context.errors[name] : [];
11151
11244
  const { starPosition } = this.context;
11152
- const renderStar = required4 && /* @__PURE__ */ React__default.createElement("i", { className: "required" });
11245
+ const renderStar = (required4 || requiredInRules) && /* @__PURE__ */ React__default.createElement("i", { className: "required" });
11153
11246
  const renderLabel = /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, starPosition === "left" ? renderStar : null, label, starPosition === "right" ? renderStar : null);
11154
11247
  return /* @__PURE__ */ React__default.createElement(
11155
11248
  Cell,
@@ -11159,7 +11252,7 @@ class FormItem extends React__default.Component {
11159
11252
  onClick: (e) => this.props.onClick && this.props.onClick(e, this.componentRef)
11160
11253
  },
11161
11254
  label ? /* @__PURE__ */ React__default.createElement("div", { className: "nut-cell__title nut-form-item__label" }, renderLabel) : null,
11162
- /* @__PURE__ */ React__default.createElement("div", { className: "nut-cell__value nut-form-item__body" }, /* @__PURE__ */ React__default.createElement("div", { className: "nut-form-item__body__slots" }, childNode), item.length > 0 && /* @__PURE__ */ React__default.createElement(
11255
+ /* @__PURE__ */ React__default.createElement("div", { className: "nut-cell__value nut-form-item__body" }, /* @__PURE__ */ React__default.createElement("div", { className: "nut-form-item__body__slots" }, childNode), item && item.length > 0 && /* @__PURE__ */ React__default.createElement(
11163
11256
  "div",
11164
11257
  {
11165
11258
  className: "nut-form-item__body__tips",
@@ -11548,7 +11641,7 @@ const InputNumber = (props) => {
11548
11641
  };
11549
11642
  const changeFormatValue = (e) => {
11550
11643
  const input = e.target.value;
11551
- const numReg = new RegExp("^[0-9]*$");
11644
+ const numReg = /^[0-9]*$/;
11552
11645
  const numValue = input.replace(/[^0-9|.]/gi, "");
11553
11646
  if (formatter) {
11554
11647
  if (!numReg.test(input[0]) && numValue) {
@@ -11567,7 +11660,7 @@ const InputNumber = (props) => {
11567
11660
  };
11568
11661
  const burFormatValue = (e) => {
11569
11662
  const input = e.target.value;
11570
- const numReg = new RegExp("^[0-9]*$");
11663
+ const numReg = /^[0-9]*$/;
11571
11664
  const numValue = input.replace(/[^0-9|.]/gi, "");
11572
11665
  if (formatter) {
11573
11666
  if (formatter(numValue) === input) {
@@ -13160,7 +13253,9 @@ const InternalSignature = (props, ref) => {
13160
13253
  }
13161
13254
  )));
13162
13255
  };
13163
- const Signature = React__default.forwardRef(InternalSignature);
13256
+ const Signature = React__default.forwardRef(
13257
+ InternalSignature
13258
+ );
13164
13259
  Signature.defaultProps = defaultProps$L;
13165
13260
  Signature.displayName = "NutSignature";
13166
13261
  const defaultProps$K = {
@@ -14843,10 +14938,13 @@ const NoticeBar = (props) => {
14843
14938
  if (childCount <= 1)
14844
14939
  return;
14845
14940
  stopAutoPlay();
14846
- swiperRef.current.autoplayTimer = setTimeout(() => {
14847
- next();
14848
- autoplay();
14849
- }, Number(duration) + 100 * speed);
14941
+ swiperRef.current.autoplayTimer = setTimeout(
14942
+ () => {
14943
+ next();
14944
+ autoplay();
14945
+ },
14946
+ Number(duration) + 100 * speed
14947
+ );
14850
14948
  };
14851
14949
  const move = ({ pace = 0, offset: offset2 = 0 }) => {
14852
14950
  if (childCount <= 1)
@@ -14883,7 +14981,7 @@ const NoticeBar = (props) => {
14883
14981
  const getStyle = (moveOffset = offset) => {
14884
14982
  const target = innerRef.current;
14885
14983
  let _offset = 0;
14886
- const val = (rect == null ? void 0 : rect.height) - height;
14984
+ const val = ((rect == null ? void 0 : rect.height) || 0) - height;
14887
14985
  _offset = moveOffset + Number(active === childCount - 1 && val / 2);
14888
14986
  target.style.transitionDuration = `${swiperRef.current.moving ? 0 : duration}ms`;
14889
14987
  target.style.height = `${Number(height) * childCount}px`;
@@ -15438,7 +15536,6 @@ const PullToRefresh = (p) => {
15438
15536
  };
15439
15537
  const handleTouchStart = (e) => {
15440
15538
  touch.start(e);
15441
- pullingRef.current = true;
15442
15539
  };
15443
15540
  const handleTouchMove = (e) => {
15444
15541
  if (props.scrollTop > 0) {
@@ -15447,17 +15544,16 @@ const PullToRefresh = (p) => {
15447
15544
  if (status === "refreshing" || status === "complete")
15448
15545
  return;
15449
15546
  touch.move(e);
15450
- if (e.cancelable) {
15451
- e.preventDefault();
15547
+ if (touch.isVertical()) {
15548
+ pullingRef.current = true;
15549
+ setHeight(
15550
+ Math.max(
15551
+ rubberbandIfOutOfBounds(touch.deltaY, 0, 0, headHeight * 5, 0.5),
15552
+ 0
15553
+ )
15554
+ );
15555
+ setStatus(height > threshold ? "canRelease" : "pulling");
15452
15556
  }
15453
- e.stopPropagation();
15454
- setHeight(
15455
- Math.max(
15456
- rubberbandIfOutOfBounds(touch.deltaY, 0, 0, headHeight * 5, 0.5),
15457
- 0
15458
- )
15459
- );
15460
- setStatus(height > threshold ? "canRelease" : "pulling");
15461
15557
  };
15462
15558
  async function doRefresh() {
15463
15559
  setHeight(headHeight);
@@ -15650,7 +15746,7 @@ const Avatar = (props) => {
15650
15746
  ...icon.props,
15651
15747
  className: `${icon.props.className || ""} icon`
15652
15748
  }) : null, children && /* @__PURE__ */ React__default.createElement("span", { className: "text" }, children), !src && !icon && !children && /* @__PURE__ */ React__default.createElement(a$c, { className: "icon" })),
15653
- showMax && /* @__PURE__ */ React__default.createElement("div", { className: "text" }, ((_l = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _l.maxContent) ? (_m = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _m.maxContent : `+ ${avatarIndex - ((_n = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _n.max)}`)
15749
+ showMax && /* @__PURE__ */ React__default.createElement("div", { className: "text" }, ((_l = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _l.maxContent) ? (_m = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _m.maxContent : `+ ${avatarIndex - Number(((_n = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _n.max) || 0)}`)
15654
15750
  ));
15655
15751
  };
15656
15752
  Avatar.defaultProps = defaultProps$v;
@@ -15942,49 +16038,59 @@ const Toast = (props) => {
15942
16038
  closeOnOverlayClick,
15943
16039
  lockScroll,
15944
16040
  contentClassName,
15945
- size,
15946
16041
  visible,
16042
+ size,
15947
16043
  className,
15948
16044
  style,
15949
16045
  onClose
15950
16046
  },
15951
16047
  setParams
15952
16048
  } = useParams({ ...defaultProps$s, ...props });
15953
- let timer;
15954
- const [openState, SetOpenState] = useState(false);
16049
+ const timer = useRef(-1);
16050
+ const [innerVisible, setInnerVisible] = usePropsValue({
16051
+ value: visible,
16052
+ defaultValue: void 0,
16053
+ finalValue: false,
16054
+ onChange: (v) => {
16055
+ !v && (onClose == null ? void 0 : onClose());
16056
+ }
16057
+ });
15955
16058
  useEffect(() => {
15956
- if (visible) {
15957
- show2();
15958
- } else {
15959
- hide2();
16059
+ if (innerVisible) {
16060
+ autoClose();
15960
16061
  }
15961
- }, [visible]);
16062
+ }, [innerVisible, duration]);
15962
16063
  useCustomEvent(
15963
16064
  id,
15964
16065
  ({ status, options }) => {
15965
16066
  if (status) {
16067
+ options.visible = true;
15966
16068
  setParams(options);
15967
16069
  show2();
15968
16070
  } else {
16071
+ setParams({ visible: false });
15969
16072
  hide2();
15970
16073
  }
15971
16074
  }
15972
16075
  );
15973
16076
  const clearTimer = () => {
15974
- if (timer) {
15975
- clearTimeout(timer);
15976
- timer = null;
16077
+ if (timer.current) {
16078
+ clearTimeout(timer.current);
16079
+ timer.current = -1;
15977
16080
  }
15978
16081
  };
16082
+ const show2 = () => {
16083
+ setInnerVisible(true);
16084
+ };
15979
16085
  const hide2 = () => {
15980
- SetOpenState(false);
15981
- onClose == null ? void 0 : onClose();
16086
+ clearTimer();
16087
+ setInnerVisible(false);
15982
16088
  };
15983
- const show2 = () => {
16089
+ const autoClose = () => {
15984
16090
  clearTimer();
15985
- SetOpenState(true);
15986
16091
  if (duration) {
15987
- timer = window.setTimeout(() => {
16092
+ timer.current = window.setTimeout(() => {
16093
+ setParams({ visible: false });
15988
16094
  hide2();
15989
16095
  }, duration * 1e3);
15990
16096
  }
@@ -16015,10 +16121,10 @@ const Toast = (props) => {
16015
16121
  "nut-toast-has-icon": icon,
16016
16122
  [`nut-toast-${size}`]: true
16017
16123
  });
16018
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, openState ? /* @__PURE__ */ React__default.createElement(
16124
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, innerVisible ? /* @__PURE__ */ React__default.createElement(
16019
16125
  Overlay,
16020
16126
  {
16021
- visible: openState,
16127
+ visible: innerVisible,
16022
16128
  style,
16023
16129
  className: `${classPrefix$8}__overlay-default ${className}`,
16024
16130
  closeOnOverlayClick,
@@ -16194,7 +16300,6 @@ __publicField(AnimatingNumbers, "defaultProps", defaultProps$p);
16194
16300
  __publicField(AnimatingNumbers, "displayName", "NutAnimatingNumbers");
16195
16301
  __publicField(AnimatingNumbers, "CountUp", CountUp);
16196
16302
  AnimatingNumbers.CountUp = CountUp;
16197
- const warn = console.warn;
16198
16303
  const defaultProps$o = {
16199
16304
  ...ComponentDefaults,
16200
16305
  className: "",
@@ -16262,7 +16367,7 @@ const Audio = (props) => {
16262
16367
  });
16263
16368
  audioCtx.onEnded(() => {
16264
16369
  if (props.loop) {
16265
- warn(locale.audio.tips || "onPlayEnd事件在loop=false时才会触发");
16370
+ console.warn(locale.audio.tips || "onPlayEnd事件在loop=false时才会触发");
16266
16371
  } else {
16267
16372
  props.onPlayEnd && props.onPlayEnd(audioCtx);
16268
16373
  }
@@ -16983,7 +17088,9 @@ const InternalCountDown = (props, ref) => {
16983
17088
  )
16984
17089
  );
16985
17090
  };
16986
- const CountDown = React__default.forwardRef(InternalCountDown);
17091
+ const CountDown = React__default.forwardRef(
17092
+ InternalCountDown
17093
+ );
16987
17094
  CountDown.defaultProps = defaultProps$k;
16988
17095
  CountDown.displayName = "NutCountDown";
16989
17096
  const defaultProps$j = {
@@ -17136,18 +17243,18 @@ const Ellipsis = (props) => {
17136
17243
  }
17137
17244
  };
17138
17245
  const verifyEllipsis = async () => {
17139
- var _a2, _b2, _c2, _d2, _e, _f;
17246
+ var _a2, _b2, _c2, _d2, _e, _f, _g;
17140
17247
  const refe = await getRectByTaro(rootContain.current);
17141
17248
  if (refe && refe.height && refe.height > maxHeight.current) {
17142
17249
  if (direction === "end") {
17143
- ellipsis.current.leading = (_c2 = (_a2 = ellipsis.current) == null ? void 0 : _a2.leading) == null ? void 0 : _c2.slice(
17250
+ ellipsis.current.leading = (_d2 = (_a2 = ellipsis.current) == null ? void 0 : _a2.leading) == null ? void 0 : _d2.slice(
17144
17251
  0,
17145
- ((_b2 = ellipsis.current) == null ? void 0 : _b2.leading.length) - 1
17252
+ (((_c2 = (_b2 = ellipsis.current) == null ? void 0 : _b2.leading) == null ? void 0 : _c2.length) || 0) - 1
17146
17253
  );
17147
17254
  } else {
17148
- ellipsis.current.tailing = (_f = (_d2 = ellipsis.current) == null ? void 0 : _d2.tailing) == null ? void 0 : _f.slice(
17255
+ ellipsis.current.tailing = (_g = (_e = ellipsis.current) == null ? void 0 : _e.tailing) == null ? void 0 : _g.slice(
17149
17256
  1,
17150
- (_e = ellipsis.current) == null ? void 0 : _e.tailing.length
17257
+ (_f = ellipsis.current) == null ? void 0 : _f.tailing.length
17151
17258
  );
17152
17259
  }
17153
17260
  assignContent();
@@ -18079,8 +18186,8 @@ const Table = (props) => {
18079
18186
  return [columns2.key, columns2.render];
18080
18187
  });
18081
18188
  };
18082
- const renderBodyTds = (item) => {
18083
- return sortDataItem().map(([value, render], index) => {
18189
+ const renderBodyTds = (item, rowIndex) => {
18190
+ return sortDataItem().map(([value, render]) => {
18084
18191
  return /* @__PURE__ */ React__default.createElement(
18085
18192
  "span",
18086
18193
  {
@@ -18090,13 +18197,13 @@ const Table = (props) => {
18090
18197
  ),
18091
18198
  key: value
18092
18199
  },
18093
- typeof item[value] === "function" || typeof render === "function" ? /* @__PURE__ */ React__default.createElement("div", null, render ? render(item) : item[value](item)) : item[value]
18200
+ typeof item[value] === "function" || typeof render === "function" ? /* @__PURE__ */ React__default.createElement("div", null, render ? render(item, rowIndex) : item[value](item)) : item[value]
18094
18201
  );
18095
18202
  });
18096
18203
  };
18097
18204
  const renderBoyTrs = () => {
18098
- return curData.map((item, index) => {
18099
- return /* @__PURE__ */ React__default.createElement("div", { className: bodyClassPrefix, key: index }, renderBodyTds(item));
18205
+ return curData.map((item, rowIndex) => {
18206
+ return /* @__PURE__ */ React__default.createElement("div", { className: bodyClassPrefix, key: rowIndex }, renderBodyTds(item, rowIndex));
18100
18207
  });
18101
18208
  };
18102
18209
  return /* @__PURE__ */ React__default.createElement("div", { className: cls, style, ...rest }, /* @__PURE__ */ React__default.createElement(
@@ -18485,7 +18592,7 @@ const initPositinoCache = (reaItemSize, length = 0) => {
18485
18592
  }
18486
18593
  return positions;
18487
18594
  };
18488
- const binarySearch = (positionsList, value = 0, horizontal) => {
18595
+ const binarySearch = (positionsList, horizontal, value = 0) => {
18489
18596
  let start = 0;
18490
18597
  let end = positionsList.length - 1;
18491
18598
  let tempIndex = null;
@@ -18628,7 +18735,7 @@ const VirtualList = (props) => {
18628
18735
  const listScroll = (e) => {
18629
18736
  const scrollTop = e.detail ? e.detail.scrollTop : e.target.scrollTop;
18630
18737
  const scrollSize = Math.floor(scrollTop);
18631
- const startIndex = binarySearch(positions, scrollSize, false);
18738
+ const startIndex = binarySearch(positions, false, scrollSize);
18632
18739
  const overStart = startIndex - overscan > -1 ? startIndex - overscan : 0;
18633
18740
  const endIndex = end();
18634
18741
  if (!itemEqual) {
@@ -18793,7 +18900,9 @@ const InternalBarrage = (props, ref) => {
18793
18900
  );
18794
18901
  })));
18795
18902
  };
18796
- const Barrage = React__default.forwardRef(InternalBarrage);
18903
+ const Barrage = React__default.forwardRef(
18904
+ InternalBarrage
18905
+ );
18797
18906
  Barrage.defaultProps = defaultProps$5;
18798
18907
  Barrage.displayName = "NutBarrage";
18799
18908
  const defaultProps$4 = {
@@ -19073,7 +19182,7 @@ const TrendArrow = (props) => {
19073
19182
  return console.warn(`传入的值:${num}不是一个数字`);
19074
19183
  }
19075
19184
  num = parseFloat(num);
19076
- const numPow = Math.pow(10, digit);
19185
+ const numPow = 10 ** digit;
19077
19186
  return (Math.round((num + Number.EPSILON) * numPow) / numPow).toFixed(digit);
19078
19187
  };
19079
19188
  const calcStyle = (() => {