@nutui/nutui-react-taro 2.3.9 → 2.3.11

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 (161) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/esm/ActionSheet/style/style.css +1 -1
  3. package/dist/esm/ActionSheet.js +1 -1
  4. package/dist/esm/Address/style/style.css +1 -1
  5. package/dist/esm/Address.js +3 -3
  6. package/dist/esm/Animate/style/style.css +1 -1
  7. package/dist/esm/Audio/style/style.css +1 -1
  8. package/dist/esm/BackTop.js +1 -1
  9. package/dist/esm/Badge/style/style.css +1 -1
  10. package/dist/esm/Barrage/style/style.css +1 -1
  11. package/dist/esm/Barrage.js +4 -2
  12. package/dist/esm/Calendar/style/style.css +1 -1
  13. package/dist/esm/Card/style/style.css +1 -1
  14. package/dist/esm/Cascader/style/style.css +1 -1
  15. package/dist/esm/Cascader.js +2 -2
  16. package/dist/esm/Checkbox/style/style.css +1 -1
  17. package/dist/esm/CheckboxGroup/style/style.css +1 -1
  18. package/dist/esm/Col/style/style.css +1 -1
  19. package/dist/esm/Collapse/style/style.css +1 -1
  20. package/dist/esm/CollapseItem/style/style.css +1 -1
  21. package/dist/esm/DatePicker/style/style.css +1 -1
  22. package/dist/esm/Dialog/style/style.css +1 -1
  23. package/dist/esm/Divider/style/style.css +1 -1
  24. package/dist/esm/Form/style/style.css +1 -1
  25. package/dist/esm/Form.js +1 -1
  26. package/dist/esm/FormItem/style/style.css +1 -1
  27. package/dist/esm/FormItem.js +1 -1
  28. package/dist/esm/Grid/style/style.css +1 -1
  29. package/dist/esm/GridItem/style/style.css +1 -1
  30. package/dist/esm/ImagePreview/style/style.css +1 -1
  31. package/dist/esm/Indicator/style/style.css +1 -1
  32. package/dist/esm/Input.js +1 -1
  33. package/dist/esm/InputNumber.js +1 -1
  34. package/dist/esm/Menu/style/style.css +1 -1
  35. package/dist/esm/MenuItem/style/style.css +1 -1
  36. package/dist/esm/NavBar/style/style.css +1 -1
  37. package/dist/esm/NoticeBar/style/style.css +1 -1
  38. package/dist/esm/NumberKeyboard/style/style.css +1 -1
  39. package/dist/esm/Picker/style/style.css +1 -1
  40. package/dist/esm/Popover/style/style.css +1 -1
  41. package/dist/esm/Popup/style/style.css +1 -1
  42. package/dist/esm/Price/style/style.css +1 -1
  43. package/dist/esm/Radio/style/style.css +1 -1
  44. package/dist/esm/RadioGroup/style/style.css +1 -1
  45. package/dist/esm/Range/style/style.css +1 -1
  46. package/dist/esm/SearchBar/style/style.css +1 -1
  47. package/dist/esm/ShortPassword/style/style.css +1 -1
  48. package/dist/esm/ShortPassword.js +1 -1
  49. package/dist/esm/SideNavBar/style/style.css +1 -1
  50. package/dist/esm/Skeleton/style/style.css +1 -1
  51. package/dist/esm/Skeleton.js +1 -1
  52. package/dist/esm/Step/style/style.css +1 -1
  53. package/dist/esm/Steps/style/style.css +1 -1
  54. package/dist/esm/Sticky.js +1 -1
  55. package/dist/esm/Swipe/style/style.css +1 -1
  56. package/dist/esm/Swiper/style/style.css +1 -1
  57. package/dist/esm/Switch/style/style.css +1 -1
  58. package/dist/esm/Tabbar/style/style.css +1 -1
  59. package/dist/esm/TabbarItem/style/style.css +1 -1
  60. package/dist/esm/Table/style/style.css +1 -1
  61. package/dist/esm/Tabs/style/style.css +1 -1
  62. package/dist/esm/Tabs.js +1 -1
  63. package/dist/esm/TextArea/style/style.css +1 -1
  64. package/dist/esm/TimeSelect/style/style.css +1 -1
  65. package/dist/esm/Tour/style/style.css +1 -1
  66. package/dist/esm/VirtualList/style/style.css +1 -1
  67. package/dist/esm/{actionsheet.taro-6NiOrNyd.js → actionsheet.taro-kKhb0Vwt.js} +1 -1
  68. package/dist/esm/{address.taro-B54ZOtmo.js → address.taro-zQuxQEce.js} +1 -1
  69. package/dist/esm/{backtop.taro-Y3vOJiXq.js → backtop.taro-Cfld7ina.js} +1 -1
  70. package/dist/esm/barrage.taro-6nbq7wtt.js +118 -0
  71. package/dist/esm/{cascader.taro-BxyK5ybo.js → cascader.taro-M2nZWxiB.js} +1 -1
  72. package/dist/esm/{formitem.taro-atY4A0pS.js → formitem.taro-viaUkMmm.js} +42 -13
  73. package/dist/esm/{input.taro-YoPsV-op.js → input.taro-xCoGdppk.js} +4 -1
  74. package/dist/esm/inputnumber.taro-WPpS0Xl9.js +169 -0
  75. package/dist/esm/nutui-react.es.js +12 -12
  76. package/dist/esm/{shortpassword.taro-bZCwIpEn.js → shortpassword.taro-JBWXzk6I.js} +19 -6
  77. package/dist/esm/{skeleton.taro-Pg7WtP0e.js → skeleton.taro--AtiA7MK.js} +2 -2
  78. package/dist/esm/{sticky.taro-MmKUU2Wv.js → sticky.taro-p-evMNR-.js} +1 -1
  79. package/dist/esm/{tabs.taro-w8ra49Qb.js → tabs.taro-Yj7vgtSg.js} +1 -1
  80. package/dist/esm/types/src/packages/formitem/formitem.d.ts +6 -2
  81. package/dist/esm/types/src/packages/formitem/formitem.taro.d.ts +6 -2
  82. package/dist/esm/types/src/packages/inputnumber/inputnumber.d.ts +15 -15
  83. package/dist/esm/types/src/packages/inputnumber/inputnumber.taro.d.ts +15 -17
  84. package/dist/esm/types/src/packages/shortpassword/shortpassword.d.ts +3 -2
  85. package/dist/esm/types/src/packages/shortpassword/shortpassword.taro.d.ts +3 -2
  86. package/dist/esm/types/src/packages/shortpassword/types.d.ts +4 -0
  87. package/dist/locales/base.js +1 -1
  88. package/dist/locales/en-US.js +1 -1
  89. package/dist/locales/id-ID.js +1 -1
  90. package/dist/locales/tr-TR.js +1 -1
  91. package/dist/locales/zh-CN.js +1 -1
  92. package/dist/locales/zh-TW.js +1 -1
  93. package/dist/locales/zh-UG.js +1 -1
  94. package/dist/nutui.react.es.js +277 -247
  95. package/dist/nutui.react.umd.js +277 -247
  96. package/dist/packages/animate/animate.scss +0 -27
  97. package/dist/packages/audio/audio.scss +0 -5
  98. package/dist/packages/avatarcropper/avatarcropper.scss +0 -2
  99. package/dist/packages/badge/badge.scss +7 -0
  100. package/dist/packages/barrage/barrage.scss +23 -4
  101. package/dist/packages/button/button.scss +0 -1
  102. package/dist/packages/calendar/calendar.scss +4 -4
  103. package/dist/packages/calendarcard/calendarcard.scss +0 -1
  104. package/dist/packages/cascader/cascader.scss +0 -1
  105. package/dist/packages/checkbox/checkbox.scss +0 -2
  106. package/dist/packages/checkboxgroup/checkboxgroup.scss +1 -3
  107. package/dist/packages/col/col.scss +2 -2
  108. package/dist/packages/collapseitem/collapseitem.scss +2 -3
  109. package/dist/packages/dialog/dialog.scss +4 -0
  110. package/dist/packages/divider/divider.scss +1 -1
  111. package/dist/packages/fixednav/fixednav.scss +0 -2
  112. package/dist/packages/form/form.scss +24 -26
  113. package/dist/packages/formitem/formitem.scss +0 -1
  114. package/dist/packages/grid/grid.scss +1 -1
  115. package/dist/packages/griditem/griditem.scss +28 -26
  116. package/dist/packages/imagepreview/imagepreview.scss +0 -1
  117. package/dist/packages/indicator/indicator.scss +2 -3
  118. package/dist/packages/menu/menu.scss +0 -7
  119. package/dist/packages/menuitem/menuitem.scss +14 -10
  120. package/dist/packages/navbar/navbar.scss +3 -5
  121. package/dist/packages/noticebar/noticebar.scss +20 -0
  122. package/dist/packages/numberkeyboard/numberkeyboard.scss +25 -18
  123. package/dist/packages/pagination/pagination.scss +0 -2
  124. package/dist/packages/picker/picker.scss +9 -0
  125. package/dist/packages/popover/popover.scss +0 -4
  126. package/dist/packages/popup/popup.scss +4 -19
  127. package/dist/packages/price/price.scss +1 -0
  128. package/dist/packages/radio/radio.scss +0 -1
  129. package/dist/packages/radiogroup/radiogroup.scss +10 -1
  130. package/dist/packages/range/range.scss +127 -127
  131. package/dist/packages/rate/rate.scss +0 -1
  132. package/dist/packages/searchbar/searchbar.scss +3 -2
  133. package/dist/packages/shortpassword/shortpassword.scss +4 -0
  134. package/dist/packages/skeleton/skeleton.scss +13 -3
  135. package/dist/packages/space/space.scss +0 -1
  136. package/dist/packages/step/step.scss +21 -25
  137. package/dist/packages/swipe/swipe.scss +0 -15
  138. package/dist/packages/swiper/swiper.scss +0 -1
  139. package/dist/packages/switch/switch.scss +11 -0
  140. package/dist/packages/table/table.scss +4 -5
  141. package/dist/packages/tabs/tabs.scss +16 -18
  142. package/dist/packages/tag/tag.scss +0 -1
  143. package/dist/packages/textarea/textarea.scss +1 -6
  144. package/dist/packages/timeselect/timeselect.scss +1 -6
  145. package/dist/packages/tour/tour.scss +1 -5
  146. package/dist/packages/trendarrow/trendarrow.scss +0 -1
  147. package/dist/packages/uploader/uploader.scss +0 -1
  148. package/dist/packages/virtuallist/virtuallist.scss +12 -12
  149. package/dist/style.css +1 -1
  150. package/dist/style.mjs +1 -1
  151. package/dist/styles/variables.scss +11 -7
  152. package/dist/types/packages/formitem/formitem.d.ts +6 -2
  153. package/dist/types/packages/formitem/formitem.taro.d.ts +14 -2
  154. package/dist/types/packages/inputnumber/inputnumber.d.ts +15 -15
  155. package/dist/types/packages/inputnumber/inputnumber.taro.d.ts +28 -30
  156. package/dist/types/packages/shortpassword/shortpassword.d.ts +3 -2
  157. package/dist/types/packages/shortpassword/shortpassword.taro.d.ts +3 -2
  158. package/dist/types/packages/shortpassword/types.d.ts +4 -0
  159. package/package.json +5 -5
  160. package/dist/esm/barrage.taro-HsivAhbE.js +0 -91
  161. package/dist/esm/inputnumber.taro-7QptygT3.js +0 -197
@@ -8,7 +8,7 @@ var __publicField = (obj, key, value) => {
8
8
  return value;
9
9
  };
10
10
  /*!
11
- * @nutui/nutui-react-taro v2.3.9 Fri Feb 02 2024 16:15:32 GMT+0800 (China Standard Time)
11
+ * @nutui/nutui-react-taro v2.3.11 Fri Feb 23 2024 19:40:58 GMT+0800 (China Standard Time)
12
12
  * (c) 2023 @jdf2e.
13
13
  * Released under the MIT License.
14
14
  */
@@ -4050,7 +4050,7 @@ var __publicField = (obj, key, value) => {
4050
4050
  }
4051
4051
  }, []);
4052
4052
  Taro.usePageScroll((res) => {
4053
- if (Taro.getEnv() === "WEAPP") {
4053
+ if (Taro.getEnv() !== "WEB") {
4054
4054
  handleScroll(res.scrollTop);
4055
4055
  }
4056
4056
  });
@@ -4113,7 +4113,7 @@ var __publicField = (obj, key, value) => {
4113
4113
  duration: duration > 0 ? duration : 0
4114
4114
  });
4115
4115
  };
4116
- const styles = style ? {
4116
+ const styles = Object.keys(style || {}).length !== 0 ? {
4117
4117
  zIndex,
4118
4118
  ...style
4119
4119
  } : {
@@ -5358,7 +5358,7 @@ var __publicField = (obj, key, value) => {
5358
5358
  onClick: (e2) => {
5359
5359
  tabChange(item);
5360
5360
  },
5361
- className: classNames(`${classPrefix$k}-titles-item taro`, {
5361
+ className: classNames(`${classPrefix$k}-titles-item`, {
5362
5362
  [`nut-tabs-titles-item-active`]: !item.disabled && String(item.value) === String(value),
5363
5363
  [`nut-tabs-titles-item-disabled`]: item.disabled,
5364
5364
  [`nut-tabs-titles-item-${align}`]: align
@@ -9768,6 +9768,7 @@ var __publicField = (obj, key, value) => {
9768
9768
  constructor() {
9769
9769
  // 初始化数据
9770
9770
  __publicField(this, "initialValues", {});
9771
+ __publicField(this, "updateList", []);
9771
9772
  // 存放表单中所有的数据 eg. {password: "ddd",username: "123"}
9772
9773
  __publicField(this, "store", {});
9773
9774
  // 所有的组件实例
@@ -9837,6 +9838,15 @@ var __publicField = (obj, key, value) => {
9837
9838
  }
9838
9839
  });
9839
9840
  });
9841
+ this.updateList.forEach((item) => {
9842
+ let shouldUpdate = item.condition;
9843
+ if (typeof item.condition === "function") {
9844
+ shouldUpdate = item.condition();
9845
+ }
9846
+ if (shouldUpdate) {
9847
+ item.entity.onStoreChange("update");
9848
+ }
9849
+ });
9840
9850
  });
9841
9851
  __publicField(this, "setCallback", (callback) => {
9842
9852
  this.callbacks = {
@@ -9884,9 +9894,11 @@ var __publicField = (obj, key, value) => {
9884
9894
  );
9885
9895
  }
9886
9896
  const errs = [];
9887
- filterEntities.forEach((entity) => {
9888
- this.validateEntities(entity, errs);
9889
- });
9897
+ await Promise.all(
9898
+ filterEntities.map(async (entity) => {
9899
+ await this.validateEntities(entity, errs);
9900
+ })
9901
+ );
9890
9902
  return errs;
9891
9903
  });
9892
9904
  __publicField(this, "submit", async () => {
@@ -9905,6 +9917,16 @@ var __publicField = (obj, key, value) => {
9905
9917
  entity.onStoreChange("reset");
9906
9918
  });
9907
9919
  });
9920
+ // 监听事件
9921
+ __publicField(this, "registerUpdate", (field, shouldUpdate) => {
9922
+ this.updateList.push({
9923
+ entity: field,
9924
+ condition: shouldUpdate
9925
+ });
9926
+ return () => {
9927
+ this.updateList = this.updateList.filter((i2) => i2.entity !== field);
9928
+ };
9929
+ });
9908
9930
  __publicField(this, "dispatch", ({ name }) => {
9909
9931
  this.validateFields([name]);
9910
9932
  });
@@ -9916,7 +9938,8 @@ var __publicField = (obj, key, value) => {
9916
9938
  setInitialValues: this.setInitialValues,
9917
9939
  dispatch: this.dispatch,
9918
9940
  store: this.store,
9919
- fieldEntities: this.fieldEntities
9941
+ fieldEntities: this.fieldEntities,
9942
+ registerUpdate: this.registerUpdate
9920
9943
  };
9921
9944
  }
9922
9945
  });
@@ -10047,13 +10070,16 @@ var __publicField = (obj, key, value) => {
10047
10070
  label: "",
10048
10071
  rules: [{ required: false, message: "" }],
10049
10072
  errorMessageAlign: "left",
10050
- validateTrigger: "onChange"
10073
+ validateTrigger: "onChange",
10074
+ shouldUpdate: false,
10075
+ noStyle: false
10051
10076
  };
10052
10077
  class FormItem extends React.Component {
10053
10078
  constructor(props) {
10054
10079
  super(props);
10055
10080
  __publicField(this, "cancelRegister");
10056
10081
  __publicField(this, "componentRef");
10082
+ __publicField(this, "eventOff");
10057
10083
  // children添加value属性和onChange事件
10058
10084
  __publicField(this, "getControlled", (children) => {
10059
10085
  var _a;
@@ -10127,7 +10153,6 @@ var __publicField = (obj, key, value) => {
10127
10153
  }
10128
10154
  });
10129
10155
  __publicField(this, "renderLayout", (childNode) => {
10130
- var _a;
10131
10156
  const {
10132
10157
  label,
10133
10158
  name,
@@ -10153,16 +10178,13 @@ var __publicField = (obj, key, value) => {
10153
10178
  onClick: (e2) => this.props.onClick && this.props.onClick(e2, this.componentRef)
10154
10179
  },
10155
10180
  label ? /* @__PURE__ */ React.createElement("div", { className: "nut-cell-title nut-form-item-label" }, renderLabel) : null,
10156
- /* @__PURE__ */ React.createElement("div", { className: "nut-cell-value nut-form-item-body" }, /* @__PURE__ */ React.createElement("div", { className: "nut-form-item-body-slots" }, childNode), /* @__PURE__ */ React.createElement(
10181
+ /* @__PURE__ */ React.createElement("div", { className: "nut-cell-value nut-form-item-body" }, /* @__PURE__ */ React.createElement("div", { className: "nut-form-item-body-slots" }, childNode), item && item.length > 0 && /* @__PURE__ */ React.createElement(
10157
10182
  "div",
10158
10183
  {
10159
10184
  className: "nut-form-item-body-tips",
10160
- style: {
10161
- textAlign: errorMessageAlign,
10162
- display: (item == null ? void 0 : item.length) ? "initial" : "none"
10163
- }
10185
+ style: { textAlign: errorMessageAlign }
10164
10186
  },
10165
- (_a = item == null ? void 0 : item[0]) == null ? void 0 : _a.message
10187
+ item[0].message
10166
10188
  ))
10167
10189
  );
10168
10190
  });
@@ -10172,22 +10194,31 @@ var __publicField = (obj, key, value) => {
10172
10194
  };
10173
10195
  }
10174
10196
  componentDidMount() {
10175
- const { registerField } = this.context.getInternal(SECRET);
10197
+ const { registerField, registerUpdate } = this.context.getInternal(SECRET);
10176
10198
  this.cancelRegister = registerField(this);
10199
+ this.eventOff = registerUpdate(this, this.props.shouldUpdate);
10177
10200
  }
10178
10201
  componentWillUnmount() {
10179
10202
  if (this.cancelRegister) {
10180
10203
  this.cancelRegister();
10181
10204
  }
10205
+ if (this.eventOff) {
10206
+ this.eventOff();
10207
+ }
10182
10208
  }
10183
10209
  render() {
10184
10210
  const { children } = this.props;
10185
10211
  const child = Array.isArray(children) ? children[0] : children;
10186
- const returnChildNode = React.cloneElement(
10187
- child,
10188
- this.getControlled(child)
10189
- );
10190
- return /* @__PURE__ */ React.createElement(React.Fragment, { key: this.state.resetCount }, this.renderLayout(returnChildNode));
10212
+ let returnChildNode;
10213
+ if (!this.props.shouldUpdate) {
10214
+ returnChildNode = React.cloneElement(
10215
+ child,
10216
+ this.getControlled(child)
10217
+ );
10218
+ } else {
10219
+ returnChildNode = child(this.context);
10220
+ }
10221
+ return /* @__PURE__ */ React.createElement(React.Fragment, { key: this.state.resetCount }, this.props.noStyle ? returnChildNode : this.renderLayout(returnChildNode));
10191
10222
  }
10192
10223
  }
10193
10224
  __publicField(FormItem, "defaultProps", defaultProps$Y);
@@ -10371,7 +10402,10 @@ var __publicField = (obj, key, value) => {
10371
10402
  name,
10372
10403
  className: "nut-input-native",
10373
10404
  ref: inputRef,
10374
- style: { textAlign: align },
10405
+ style: {
10406
+ textAlign: `${// eslint-disable-next-line no-nested-ternary
10407
+ align === "right" ? "end" : align === "left" ? "start" : "center"}`
10408
+ },
10375
10409
  type: inputType(type2),
10376
10410
  password: type2 === "password",
10377
10411
  maxlength: maxLength,
@@ -10412,11 +10446,10 @@ var __publicField = (obj, key, value) => {
10412
10446
  const defaultProps$W = {
10413
10447
  ...ComponentDefaults,
10414
10448
  disabled: false,
10415
- min: 1,
10416
- max: 9999,
10417
10449
  readOnly: false,
10418
10450
  allowEmpty: false,
10419
- defaultValue: 0,
10451
+ min: 1,
10452
+ max: 9999,
10420
10453
  step: 1,
10421
10454
  digits: 0,
10422
10455
  async: false
@@ -10449,197 +10482,161 @@ var __publicField = (obj, key, value) => {
10449
10482
  ...defaultProps$W,
10450
10483
  ...props
10451
10484
  };
10452
- const inputRef = React.useRef("");
10453
- const [_checked, setChecked] = usePropsValue({
10454
- value,
10455
- defaultValue
10485
+ const classes = classNames(classPrefix$h, {
10486
+ [`${classPrefix$h}-disabled`]: disabled
10456
10487
  });
10488
+ const [focused, setFocused] = React.useState(false);
10489
+ const inputRef = React.useRef(null);
10457
10490
  React.useEffect(() => {
10458
- if (formatter) {
10459
- if (_checked || _checked === 0) {
10460
- inputRef.current = formatter(_checked);
10461
- setChecked(formatter(_checked));
10462
- }
10463
- }
10464
- }, []);
10465
- const classes = classNames(
10466
- {
10467
- [`${classPrefix$h}`]: true,
10468
- [`${classPrefix$h}-disabled`]: disabled
10469
- },
10470
- className
10471
- );
10472
- const styles = {
10473
- ...style
10474
- };
10475
- const addAllow = (value2 = _checked) => {
10476
- if (formatter) {
10477
- const numValue = String(value2).replace(/[^0-9|.]/gi, "");
10478
- return Number(numValue) < Number(max) && !disabled;
10491
+ var _a, _b;
10492
+ if (focused) {
10493
+ (_b = (_a = inputRef.current) == null ? void 0 : _a.select) == null ? void 0 : _b.call(_a);
10479
10494
  }
10480
- return Number(value2) < Number(max) && !disabled;
10481
- };
10482
- const reduceAllow = (value2 = _checked) => {
10483
- if (formatter) {
10484
- const numValue = String(value2).replace(/[^0-9|.]/gi, "");
10485
- return Number(numValue) > Number(min) && !disabled;
10495
+ }, [focused]);
10496
+ const [shadowValue, setShadowValue] = usePropsValue({
10497
+ value: typeof value === "string" ? parseFloat(value) : value,
10498
+ defaultValue: typeof defaultValue === "string" ? parseFloat(defaultValue) : defaultValue,
10499
+ onChange: (value2) => {
10486
10500
  }
10487
- return Number(value2) > Number(min) && !disabled;
10488
- };
10489
- const iconMinusClasses = classNames("nut-inputnumber-icon icon-minus", {
10490
- "nut-inputnumber-icon-disabled": !reduceAllow()
10491
- });
10492
- const iconAddClasses = classNames("nut-inputnumber-icon icon-plus", {
10493
- "nut-inputnumber-icon-disabled": !addAllow()
10494
10501
  });
10495
- const fixedDecimalPlaces = (v) => {
10496
- return Number(v).toFixed(Number(digits));
10497
- };
10498
- const emitChange = (value2, e2) => {
10499
- const outputValue = fixedDecimalPlaces(value2);
10500
- onChange && onChange(outputValue, e2);
10501
- if (!async) {
10502
- if (Number(outputValue) < Number(min)) {
10503
- formatter ? setChecked(formatter(Number(min))) : setChecked(Number(min));
10504
- } else if (Number(outputValue) > Number(max)) {
10505
- formatter ? setChecked(formatter(Number(max))) : setChecked(Number(max));
10506
- } else {
10507
- formatter ? setChecked(formatter(outputValue)) : setChecked(outputValue);
10508
- }
10502
+ const bound2 = (value2, min2, max2) => {
10503
+ let res = value2;
10504
+ if (min2 !== void 0) {
10505
+ res = Math.max(Number(min2), res);
10509
10506
  }
10510
- };
10511
- const reduceNumber = (e2) => {
10512
- onMinus && onMinus(e2);
10513
- if (reduceAllow()) {
10514
- if (formatter) {
10515
- const numValue = String(_checked).replace(/[^0-9|.]/gi, "");
10516
- const outputValue = Number(numValue) - Number(step);
10517
- inputRef.current = formatter(outputValue);
10518
- emitChange(outputValue, e2);
10519
- } else {
10520
- const outputValue = Number(_checked) - Number(step);
10521
- emitChange(outputValue, e2);
10522
- }
10523
- } else {
10524
- onOverlimit && onOverlimit(e2);
10507
+ if (max2 !== void 0) {
10508
+ res = Math.min(Number(max2), res);
10525
10509
  }
10510
+ return res;
10526
10511
  };
10527
- const addNumber = (e2) => {
10528
- onPlus && onPlus(e2);
10529
- if (addAllow()) {
10530
- if (formatter) {
10531
- const numValue = String(_checked).replace(/[^0-9|.]/gi, "");
10532
- const outputValue = Number(numValue) + Number(step);
10533
- inputRef.current = formatter(outputValue);
10534
- emitChange(outputValue, e2);
10535
- } else {
10536
- const outputValue = Number(_checked) + Number(step);
10537
- emitChange(outputValue, e2);
10538
- }
10539
- } else {
10540
- onOverlimit && onOverlimit(e2);
10512
+ const format2 = (value2) => {
10513
+ if (value2 === null)
10514
+ return "";
10515
+ if (typeof value2 === "string")
10516
+ value2 = parseFloat(value2);
10517
+ const fixedValue = bound2(value2, Number(min), Number(max));
10518
+ if (formatter) {
10519
+ return formatter(fixedValue);
10541
10520
  }
10542
- };
10543
- const changeValue = (e2) => {
10544
- const input = e2.target;
10545
- onChange && onChange(input.value, e2);
10546
- if (!async) {
10547
- setChecked(input.value);
10521
+ if (digits) {
10522
+ return fixedValue.toFixed(digits).toString();
10548
10523
  }
10524
+ return fixedValue.toString();
10549
10525
  };
10550
- const changeFormatValue = (e2) => {
10551
- const input = e2.target.value;
10552
- const numReg = /^[0-9]*$/;
10553
- const numValue = input.replace(/[^0-9|.]/gi, "");
10554
- if (formatter) {
10555
- if (!numReg.test(input[0]) && numValue) {
10556
- setChecked(formatter(numValue));
10557
- } else if (!numReg.test(input[0]) && !numValue) {
10558
- setChecked(input);
10559
- } else if (numReg.test(input[0])) {
10560
- if (formatter(numValue) === inputRef.current) {
10561
- setChecked(numValue);
10562
- } else {
10563
- setChecked(formatter(numValue));
10564
- inputRef.current = formatter(numValue);
10565
- }
10566
- }
10526
+ const [inputValue, setInputValue] = React.useState(format2(shadowValue));
10527
+ React.useEffect(() => {
10528
+ if (!focused && !async) {
10529
+ setShadowValue(bound2(Number(shadowValue), Number(min), Number(max)));
10530
+ setInputValue(format2(shadowValue));
10567
10531
  }
10568
- };
10569
- const burFormatValue = (e2) => {
10570
- const input = e2.target.value;
10571
- const numReg = /^[0-9]*$/;
10572
- const numValue = input.replace(/[^0-9|.]/gi, "");
10573
- if (formatter) {
10574
- if (formatter(numValue) === input) {
10575
- emitChange(numValue, e2);
10576
- return;
10577
- }
10578
- if (!numReg.test(input) || !input) {
10579
- setChecked(formatter(""));
10532
+ }, [focused, shadowValue]);
10533
+ React.useEffect(() => {
10534
+ if (async) {
10535
+ setShadowValue(bound2(Number(value), Number(min), Number(max)));
10536
+ setInputValue(format2(value));
10537
+ }
10538
+ }, [value]);
10539
+ const calcNextValue = (current, step2, symbol) => {
10540
+ const dig = digits + 1;
10541
+ return (parseFloat(current || "0") * dig + parseFloat(step2) * dig * symbol) / dig;
10542
+ };
10543
+ const update = (negative, e2) => {
10544
+ if (step !== void 0) {
10545
+ const shouldOverBoundary = calcNextValue(
10546
+ shadowValue,
10547
+ step,
10548
+ negative ? -1 : 1
10549
+ );
10550
+ const nextValue = bound2(shouldOverBoundary, Number(min), Number(max));
10551
+ setShadowValue(nextValue);
10552
+ if (negative ? shouldOverBoundary < min : shouldOverBoundary > max) {
10553
+ onOverlimit == null ? void 0 : onOverlimit(e2);
10554
+ } else {
10555
+ onChange == null ? void 0 : onChange(nextValue, e2);
10580
10556
  }
10581
10557
  }
10582
10558
  };
10583
- const focusValue = (e2) => {
10559
+ const handleReduce = (e2) => {
10584
10560
  if (disabled)
10585
10561
  return;
10586
- if (readOnly)
10587
- return;
10588
- onFocus && onFocus(e2);
10562
+ onMinus == null ? void 0 : onMinus(e2);
10563
+ update(true, e2);
10589
10564
  };
10590
- const burValue = (e2) => {
10565
+ const handlePlus = (e2) => {
10591
10566
  if (disabled)
10592
10567
  return;
10593
- if (readOnly)
10594
- return;
10595
- const input = e2.target;
10596
- let value2 = +input.value;
10597
- if (value2 === 0 && !allowEmpty) {
10598
- value2 = Number(defaultValue);
10568
+ onPlus == null ? void 0 : onPlus(e2);
10569
+ update(false, e2);
10570
+ };
10571
+ const parseValue = (text) => {
10572
+ if (text === "")
10573
+ return null;
10574
+ if (text === "-")
10575
+ return null;
10576
+ return text;
10577
+ };
10578
+ const handleInputChange = (e2) => {
10579
+ setInputValue(e2.target.value);
10580
+ const valueStr = parseValue(e2.target.value);
10581
+ if (valueStr === null) {
10582
+ if (allowEmpty) {
10583
+ setShadowValue(null);
10584
+ } else {
10585
+ setShadowValue(defaultValue);
10586
+ }
10587
+ } else {
10588
+ setShadowValue(valueStr);
10599
10589
  }
10600
- if (value2 < Number(min)) {
10601
- value2 = Number(min);
10602
- } else if (value2 > Number(max)) {
10603
- value2 = Number(max);
10590
+ if (!async) {
10591
+ onChange == null ? void 0 : onChange(parseFloat(valueStr || "0").toFixed(digits), e2);
10604
10592
  }
10605
- emitChange(value2, e2);
10593
+ };
10594
+ const handleFocus = (e2) => {
10595
+ setFocused(true);
10596
+ setInputValue(
10597
+ shadowValue !== void 0 && shadowValue !== null ? bound2(Number(shadowValue), Number(min), Number(max)).toString() : ""
10598
+ );
10599
+ onFocus && onFocus(e2);
10600
+ };
10601
+ const handleBlur = (e2) => {
10602
+ setFocused(false);
10606
10603
  onBlur && onBlur(e2);
10604
+ if (async) {
10605
+ const valueStr = parseValue(e2.target.value);
10606
+ onChange == null ? void 0 : onChange(parseFloat(valueStr || "0").toFixed(digits), e2);
10607
+ }
10607
10608
  };
10608
- return /* @__PURE__ */ React.createElement("div", { className: classes, style: styles, ...restProps }, /* @__PURE__ */ React.createElement("div", { className: "nut-input-minus" }, /* @__PURE__ */ React.createElement(
10609
+ return /* @__PURE__ */ React.createElement("div", { className: classes, style, ...restProps }, /* @__PURE__ */ React.createElement("div", { className: "nut-input-minus" }, /* @__PURE__ */ React.createElement(
10609
10610
  t,
10610
10611
  {
10611
- className: iconMinusClasses,
10612
- onClick: (e2) => reduceNumber(e2)
10612
+ className: classNames("nut-inputnumber-icon icon-minus", {
10613
+ [`${classPrefix$h}-icon-disabled`]: shadowValue === min || disabled
10614
+ }),
10615
+ onClick: handleReduce
10613
10616
  }
10614
- )), /* @__PURE__ */ React.createElement(React.Fragment, null, formatter ? /* @__PURE__ */ React.createElement(
10617
+ )), /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
10615
10618
  "input",
10616
10619
  {
10617
10620
  className: "nut-number-input",
10618
- type: "text",
10619
- min,
10620
- max,
10621
+ type: "digit",
10622
+ ref: inputRef,
10623
+ inputMode: "decimal",
10621
10624
  disabled,
10622
10625
  readOnly,
10623
- value: _checked,
10624
- onInput: changeFormatValue,
10625
- onBlur: burFormatValue,
10626
- onFocus: focusValue
10626
+ value: inputValue,
10627
+ onInput: handleInputChange,
10628
+ onBlur: handleBlur,
10629
+ onFocus: handleFocus
10627
10630
  }
10628
- ) : /* @__PURE__ */ React.createElement(
10629
- "input",
10631
+ )), /* @__PURE__ */ React.createElement("div", { className: "nut-input-add" }, /* @__PURE__ */ React.createElement(
10632
+ i,
10630
10633
  {
10631
- className: "nut-number-input",
10632
- type: "digit",
10633
- min,
10634
- max,
10635
- disabled,
10636
- readOnly,
10637
- value: _checked,
10638
- onInput: changeValue,
10639
- onBlur: burValue,
10640
- onFocus: focusValue
10634
+ className: classNames("nut-inputnumber-icon icon-plus", {
10635
+ [`${classPrefix$h}-icon-disabled`]: shadowValue === max || disabled
10636
+ }),
10637
+ onClick: handlePlus
10641
10638
  }
10642
- )), /* @__PURE__ */ React.createElement("div", { className: "nut-input-add" }, /* @__PURE__ */ React.createElement(i, { className: iconAddClasses, onClick: (e2) => addNumber(e2) })));
10639
+ )));
10643
10640
  };
10644
10641
  InputNumber.defaultProps = defaultProps$W;
10645
10642
  InputNumber.displayName = "NutInputNumber";
@@ -12039,13 +12036,13 @@ var __publicField = (obj, key, value) => {
12039
12036
  // 1~6
12040
12037
  autoFocus: false
12041
12038
  };
12042
- const ShortPassword = (props) => {
12039
+ const InternalShortPassword = (props, ref) => {
12043
12040
  const { locale } = useConfig$1();
12044
12041
  const {
12045
12042
  title,
12046
12043
  description,
12047
12044
  tips,
12048
- visible,
12045
+ visible: deleteVisible,
12049
12046
  value,
12050
12047
  error,
12051
12048
  hideFooter,
@@ -12076,6 +12073,20 @@ var __publicField = (obj, key, value) => {
12076
12073
  const format2 = (val) => {
12077
12074
  return val.slice(0, comLen);
12078
12075
  };
12076
+ const [visible, setVisible] = usePropsValue({
12077
+ value: props.visible,
12078
+ defaultValue: false,
12079
+ finalValue: false
12080
+ });
12081
+ const actions = {
12082
+ open: () => {
12083
+ setVisible(true);
12084
+ },
12085
+ close: () => {
12086
+ setVisible(false);
12087
+ }
12088
+ };
12089
+ React.useImperativeHandle(ref, () => actions);
12079
12090
  const [inputValue, setInputValue] = usePropsValue({ value, onChange });
12080
12091
  React.useEffect(() => {
12081
12092
  if (visible && autoFocus) {
@@ -12108,11 +12119,10 @@ var __publicField = (obj, key, value) => {
12108
12119
  },
12109
12120
  /* @__PURE__ */ React.createElement("div", { className: classNames(classPrefix2, className), style }, /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-title` }, title || locale.shortpassword.title), /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-description` }, description || locale.shortpassword.description), /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-input`, onClick: onFocus }, /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-input-site` }), /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-input-fake` }, [...new Array(comLen).keys()].map((item, index) => {
12110
12121
  return /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-input-fake-li`, key: index }, inputValue.length > index && /* @__PURE__ */ React.createElement(React.Fragment, null, plain ? inputValue[index] : /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-input-fake-li-icon` })));
12111
- }))), /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-message` }, /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-message-error` }, error), /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-message-forget`, onClick: onTips }, tips || /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(z, { size: 11, style: { marginRight: "3px" } }), locale.shortpassword.tips))), !hideFooter && /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-footer` }, /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-footer-cancel`, onClick: onCancel }, locale.cancel), /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-footer-sure`, onClick: sure }, locale.confirm)))
12122
+ }))), /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-message` }, /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-message-error` }, error), /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-message-forget`, onClick: onTips }, tips || /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(z, { size: 11 }), locale.shortpassword.tips))), !hideFooter && /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-footer` }, /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-footer-cancel`, onClick: onCancel }, locale.cancel), /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-footer-sure`, onClick: sure }, locale.confirm)))
12112
12123
  );
12113
12124
  };
12114
- ShortPassword.defaultProps = defaultProps$N;
12115
- ShortPassword.displayName = "NutShortPassword";
12125
+ const ShortPassword = React.forwardRef(InternalShortPassword);
12116
12126
  const defaultProps$M = {
12117
12127
  ...ComponentDefaults,
12118
12128
  canvasId: "spcanvas",
@@ -13160,6 +13170,7 @@ var __publicField = (obj, key, value) => {
13160
13170
  return /* @__PURE__ */ React.createElement(
13161
13171
  Popup,
13162
13172
  {
13173
+ ...rest,
13163
13174
  round: true,
13164
13175
  visible,
13165
13176
  position: "bottom",
@@ -14938,7 +14949,7 @@ var __publicField = (obj, key, value) => {
14938
14949
  const classPrefix2 = "nut-skeleton";
14939
14950
  const classes = classNames(classPrefix2, className);
14940
14951
  const avatarClass = classNames({
14941
- avatar: true,
14952
+ [`nut-avatar`]: true,
14942
14953
  [`avatar-${avatarShape}`]: avatarShape
14943
14954
  });
14944
14955
  const repeatLines = (num) => {
@@ -14956,7 +14967,7 @@ var __publicField = (obj, key, value) => {
14956
14967
  height: "50px"
14957
14968
  };
14958
14969
  };
14959
- return /* @__PURE__ */ React.createElement(React.Fragment, null, visible ? /* @__PURE__ */ React.createElement("div", null, children) : /* @__PURE__ */ React.createElement("div", { className: classes, ...rest }, animated && /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-animation` }), /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-content` }, avatar && /* @__PURE__ */ React.createElement(
14970
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, visible ? /* @__PURE__ */ React.createElement(React.Fragment, null, children) : /* @__PURE__ */ React.createElement("div", { className: classes, ...rest }, animated && /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-animation` }), /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-content` }, avatar && /* @__PURE__ */ React.createElement(
14960
14971
  Avatar,
14961
14972
  {
14962
14973
  className: avatarClass,
@@ -18096,79 +18107,98 @@ var __publicField = (obj, key, value) => {
18096
18107
  ...defaultProps$6,
18097
18108
  ...props
18098
18109
  };
18099
- const [styleList, setStyleList] = React.useState([]);
18100
- const [baItemList, setBaItemList] = React.useState(list);
18101
- const barrageListSet = React.useRef(list);
18102
18110
  const barrageBody = React.useRef(null);
18103
18111
  const barrageContainer = React.useRef(null);
18104
- const timeId = React.useRef((/* @__PURE__ */ new Date()).getTime());
18112
+ const barrageCWidth = React.useRef(0);
18105
18113
  const timer = React.useRef(0);
18106
- const classes = classNames(
18107
- classPrefix$1,
18108
- {
18109
- [`${classPrefix$1}-body${timeId.current}`]: true
18110
- },
18111
- className
18112
- );
18114
+ const index = React.useRef(0);
18115
+ const times = React.useRef([]);
18116
+ const historyIndex = React.useRef(-1);
18117
+ const classes = classNames(classPrefix$1, className);
18113
18118
  React.useImperativeHandle(ref, () => ({
18114
18119
  add: (word) => {
18115
- barrageListSet.current = [...barrageListSet.current, word];
18116
- run();
18120
+ const _index = index.current % list.length;
18121
+ if (!loop && index.current === list.length) {
18122
+ list.splice(list.length, 0, word);
18123
+ } else {
18124
+ list.splice(_index, 0, word);
18125
+ }
18117
18126
  }
18118
18127
  }));
18128
+ const getNodeWidth = async (node, type2 = "width") => {
18129
+ if (node) {
18130
+ const refe = await getRectByTaro(node);
18131
+ return Math.ceil(type2 === "height" ? refe.height : refe.width);
18132
+ }
18133
+ return 0;
18134
+ };
18119
18135
  React.useEffect(() => {
18120
- barrageListSet.current = [...list];
18121
- run();
18136
+ const init = async () => {
18137
+ if (barrageBody.current) {
18138
+ barrageCWidth.current = await getNodeWidth(barrageBody.current);
18139
+ }
18140
+ };
18141
+ init();
18142
+ setTimeout(() => {
18143
+ var _a;
18144
+ (_a = barrageBody.current) == null ? void 0 : _a.style.setProperty(
18145
+ "--move-distance",
18146
+ `-${barrageCWidth.current}px`
18147
+ );
18148
+ index.current = 0;
18149
+ run();
18150
+ }, 300);
18122
18151
  return () => {
18123
18152
  clearInterval(timer.current);
18124
18153
  };
18125
18154
  }, [list]);
18126
18155
  const run = () => {
18127
- setBaItemList(barrageListSet.current);
18128
- barrageListSet.current.forEach((item, index) => {
18129
- getNode(index);
18130
- });
18131
- };
18132
- const getNode = (index) => {
18133
- const query = Taro.createSelectorQuery();
18134
- setTimeout(() => {
18135
- let width = 100;
18136
- query.select(`.${classPrefix$1}-body${timeId.current}`).boundingClientRect((rec) => {
18137
- width = rec.width || 300;
18138
- });
18139
- query.select(`.${classPrefix$1}-item${index}`).boundingClientRect((recs) => {
18140
- const height = recs.height;
18141
- const nodeTop = `${index % rows * (height + gapY) + 20}px`;
18142
- styleInfo(index, nodeTop, width);
18143
- }).exec();
18144
- }, 500);
18156
+ clearInterval(timer.current);
18157
+ let intervalCache = interval;
18158
+ const _index = (loop ? index.current % list.length : index.current) % rows;
18159
+ const result = times.current[_index] - rows * interval;
18160
+ if (result > 0) {
18161
+ intervalCache += result;
18162
+ }
18163
+ timer.current = window.setTimeout(() => {
18164
+ play();
18165
+ }, intervalCache);
18145
18166
  };
18146
- const styleInfo = (index, nodeTop, width) => {
18147
- const timeIndex = index - rows > 0 ? index - rows : 0;
18148
- const list2 = styleList;
18149
- const time = list2[timeIndex] ? Number(list2[timeIndex]["--time"]) : 0;
18150
- const obj = {
18151
- top: nodeTop,
18152
- "--time": `${interval * index + time}`,
18153
- animationDuration: `${duration}ms`,
18154
- animationIterationCount: `${loop ? "infinite" : 1}`,
18155
- animationDelay: `${interval * index + time}ms`,
18156
- "--move-distance": `-${width}px`
18157
- };
18158
- list2.push(obj);
18159
- setStyleList([...list2]);
18167
+ const play = async () => {
18168
+ if (!loop && index.current >= list.length) {
18169
+ return;
18170
+ }
18171
+ const _index = loop ? index.current % list.length : index.current;
18172
+ const el = document.createElement(`View`);
18173
+ let currentIndex = _index % rows;
18174
+ if (currentIndex <= historyIndex.current || historyIndex.current === 3 && currentIndex !== 0 || Math.abs(currentIndex - historyIndex.current) !== 1) {
18175
+ currentIndex = historyIndex.current + 1 >= rows ? 0 : historyIndex.current + 1;
18176
+ }
18177
+ historyIndex.current = currentIndex;
18178
+ el.innerHTML = list[_index];
18179
+ el.classList.add("barrage-item");
18180
+ barrageContainer.current.appendChild(el);
18181
+ try {
18182
+ const width = await getNodeWidth(el);
18183
+ const height = await getNodeWidth(el, "height");
18184
+ el.classList.add("move");
18185
+ const elScrollDuration = width / barrageCWidth.current * duration;
18186
+ times.current[currentIndex] = Math.ceil(elScrollDuration);
18187
+ el.style.animationDuration = `${(duration + elScrollDuration).toFixed(
18188
+ 2
18189
+ )}ms`;
18190
+ el.style.top = `${currentIndex * (height + gapY) + 20}px`;
18191
+ el.style.width = `${width}px`;
18192
+ } catch (error) {
18193
+ console.log("异常自动流转到下一个");
18194
+ }
18195
+ el.addEventListener("animationend", () => {
18196
+ barrageContainer.current.removeChild(el);
18197
+ });
18198
+ index.current++;
18199
+ run();
18160
18200
  };
18161
- return /* @__PURE__ */ React.createElement("div", { className: classes, ref: barrageBody, ...restProps }, /* @__PURE__ */ React.createElement("div", { ref: barrageContainer, className: "bContainer" }, baItemList.map((item, index) => {
18162
- return /* @__PURE__ */ React.createElement(
18163
- "div",
18164
- {
18165
- className: `barrage-item ${classPrefix$1}-item${index} move`,
18166
- style: styleList[index],
18167
- key: index
18168
- },
18169
- item.length > 8 ? `${item.substr(0, 8)}...` : item
18170
- );
18171
- })));
18201
+ return /* @__PURE__ */ React.createElement(components.View, { className: classes, ref: barrageBody, ...restProps }, /* @__PURE__ */ React.createElement(components.View, { ref: barrageContainer, className: "bContainer" }));
18172
18202
  };
18173
18203
  const Barrage = React.forwardRef(
18174
18204
  InternalBarrage