@nutui/nutui-react-taro 2.3.9 → 2.3.10

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 (59) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/esm/ActionSheet/style/style.css +1 -1
  3. package/dist/esm/Address/style/style.css +1 -1
  4. package/dist/esm/Address.js +3 -3
  5. package/dist/esm/Barrage/style/style.css +1 -1
  6. package/dist/esm/Barrage.js +4 -2
  7. package/dist/esm/Calendar/style/style.css +1 -1
  8. package/dist/esm/Cascader/style/style.css +1 -1
  9. package/dist/esm/Cascader.js +2 -2
  10. package/dist/esm/DatePicker/style/style.css +1 -1
  11. package/dist/esm/Form.js +1 -1
  12. package/dist/esm/FormItem.js +1 -1
  13. package/dist/esm/ImagePreview/style/style.css +1 -1
  14. package/dist/esm/NumberKeyboard/style/style.css +1 -1
  15. package/dist/esm/Picker/style/style.css +1 -1
  16. package/dist/esm/Popover/style/style.css +1 -1
  17. package/dist/esm/Popup/style/style.css +1 -1
  18. package/dist/esm/ShortPassword/style/style.css +1 -1
  19. package/dist/esm/ShortPassword.js +1 -1
  20. package/dist/esm/SideNavBar/style/style.css +1 -1
  21. package/dist/esm/Sticky.js +1 -1
  22. package/dist/esm/Tabs/style/style.css +1 -1
  23. package/dist/esm/Tabs.js +1 -1
  24. package/dist/esm/TimeSelect/style/style.css +1 -1
  25. package/dist/esm/Tour/style/style.css +1 -1
  26. package/dist/esm/{address.taro-B54ZOtmo.js → address.taro-zQuxQEce.js} +1 -1
  27. package/dist/esm/barrage.taro-6nbq7wtt.js +118 -0
  28. package/dist/esm/{cascader.taro-BxyK5ybo.js → cascader.taro-M2nZWxiB.js} +1 -1
  29. package/dist/esm/{formitem.taro-atY4A0pS.js → formitem.taro-PPkTQGfW.js} +39 -10
  30. package/dist/esm/nutui-react.es.js +7 -7
  31. package/dist/esm/{shortpassword.taro-bZCwIpEn.js → shortpassword.taro-ECs_E1Xn.js} +18 -5
  32. package/dist/esm/{sticky.taro-MmKUU2Wv.js → sticky.taro-p-evMNR-.js} +1 -1
  33. package/dist/esm/{tabs.taro-w8ra49Qb.js → tabs.taro-Yj7vgtSg.js} +1 -1
  34. package/dist/esm/types/src/packages/formitem/formitem.d.ts +6 -2
  35. package/dist/esm/types/src/packages/formitem/formitem.taro.d.ts +6 -2
  36. package/dist/esm/types/src/packages/shortpassword/shortpassword.d.ts +3 -2
  37. package/dist/esm/types/src/packages/shortpassword/shortpassword.taro.d.ts +3 -2
  38. package/dist/esm/types/src/packages/shortpassword/types.d.ts +4 -0
  39. package/dist/locales/base.js +1 -1
  40. package/dist/locales/en-US.js +1 -1
  41. package/dist/locales/id-ID.js +1 -1
  42. package/dist/locales/tr-TR.js +1 -1
  43. package/dist/locales/zh-CN.js +1 -1
  44. package/dist/locales/zh-TW.js +1 -1
  45. package/dist/locales/zh-UG.js +1 -1
  46. package/dist/nutui.react.es.js +141 -80
  47. package/dist/nutui.react.umd.js +141 -80
  48. package/dist/packages/barrage/barrage.scss +1 -1
  49. package/dist/packages/popup/popup.scss +1 -0
  50. package/dist/packages/tabs/tabs.scss +14 -14
  51. package/dist/style.css +1 -1
  52. package/dist/style.mjs +1 -1
  53. package/dist/types/packages/formitem/formitem.d.ts +6 -2
  54. package/dist/types/packages/formitem/formitem.taro.d.ts +14 -2
  55. package/dist/types/packages/shortpassword/shortpassword.d.ts +3 -2
  56. package/dist/types/packages/shortpassword/shortpassword.taro.d.ts +3 -2
  57. package/dist/types/packages/shortpassword/types.d.ts +4 -0
  58. package/package.json +1 -1
  59. package/dist/esm/barrage.taro-HsivAhbE.js +0 -91
@@ -5,7 +5,7 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  /*!
8
- * @nutui/nutui-react-taro v2.3.9 Fri Feb 02 2024 16:15:32 GMT+0800 (China Standard Time)
8
+ * @nutui/nutui-react-taro v2.3.10 Tue Feb 06 2024 16:10:56 GMT+0800 (China Standard Time)
9
9
  * (c) 2023 @jdf2e.
10
10
  * Released under the MIT License.
11
11
  */
@@ -4034,7 +4034,7 @@ const Sticky = (props) => {
4034
4034
  }
4035
4035
  }, []);
4036
4036
  usePageScroll((res) => {
4037
- if (getEnv() === "WEAPP") {
4037
+ if (getEnv() !== "WEB") {
4038
4038
  handleScroll(res.scrollTop);
4039
4039
  }
4040
4040
  });
@@ -5342,7 +5342,7 @@ const Tabs = (props) => {
5342
5342
  onClick: (e2) => {
5343
5343
  tabChange(item);
5344
5344
  },
5345
- className: classNames(`${classPrefix$k}-titles-item taro`, {
5345
+ className: classNames(`${classPrefix$k}-titles-item`, {
5346
5346
  [`nut-tabs-titles-item-active`]: !item.disabled && String(item.value) === String(value),
5347
5347
  [`nut-tabs-titles-item-disabled`]: item.disabled,
5348
5348
  [`nut-tabs-titles-item-${align}`]: align
@@ -9752,6 +9752,7 @@ class FormStore {
9752
9752
  constructor() {
9753
9753
  // 初始化数据
9754
9754
  __publicField(this, "initialValues", {});
9755
+ __publicField(this, "updateList", []);
9755
9756
  // 存放表单中所有的数据 eg. {password: "ddd",username: "123"}
9756
9757
  __publicField(this, "store", {});
9757
9758
  // 所有的组件实例
@@ -9821,6 +9822,15 @@ class FormStore {
9821
9822
  }
9822
9823
  });
9823
9824
  });
9825
+ this.updateList.forEach((item) => {
9826
+ let shouldUpdate = item.condition;
9827
+ if (typeof item.condition === "function") {
9828
+ shouldUpdate = item.condition();
9829
+ }
9830
+ if (shouldUpdate) {
9831
+ item.entity.onStoreChange("update");
9832
+ }
9833
+ });
9824
9834
  });
9825
9835
  __publicField(this, "setCallback", (callback) => {
9826
9836
  this.callbacks = {
@@ -9889,6 +9899,16 @@ class FormStore {
9889
9899
  entity.onStoreChange("reset");
9890
9900
  });
9891
9901
  });
9902
+ // 监听事件
9903
+ __publicField(this, "registerUpdate", (field, shouldUpdate) => {
9904
+ this.updateList.push({
9905
+ entity: field,
9906
+ condition: shouldUpdate
9907
+ });
9908
+ return () => {
9909
+ this.updateList = this.updateList.filter((i2) => i2.entity !== field);
9910
+ };
9911
+ });
9892
9912
  __publicField(this, "dispatch", ({ name }) => {
9893
9913
  this.validateFields([name]);
9894
9914
  });
@@ -9900,7 +9920,8 @@ class FormStore {
9900
9920
  setInitialValues: this.setInitialValues,
9901
9921
  dispatch: this.dispatch,
9902
9922
  store: this.store,
9903
- fieldEntities: this.fieldEntities
9923
+ fieldEntities: this.fieldEntities,
9924
+ registerUpdate: this.registerUpdate
9904
9925
  };
9905
9926
  }
9906
9927
  });
@@ -10031,13 +10052,16 @@ const defaultProps$Y = {
10031
10052
  label: "",
10032
10053
  rules: [{ required: false, message: "" }],
10033
10054
  errorMessageAlign: "left",
10034
- validateTrigger: "onChange"
10055
+ validateTrigger: "onChange",
10056
+ shouldUpdate: false,
10057
+ noStyle: false
10035
10058
  };
10036
10059
  class FormItem extends React__default.Component {
10037
10060
  constructor(props) {
10038
10061
  super(props);
10039
10062
  __publicField(this, "cancelRegister");
10040
10063
  __publicField(this, "componentRef");
10064
+ __publicField(this, "eventOff");
10041
10065
  // children添加value属性和onChange事件
10042
10066
  __publicField(this, "getControlled", (children) => {
10043
10067
  var _a;
@@ -10111,7 +10135,6 @@ class FormItem extends React__default.Component {
10111
10135
  }
10112
10136
  });
10113
10137
  __publicField(this, "renderLayout", (childNode) => {
10114
- var _a;
10115
10138
  const {
10116
10139
  label,
10117
10140
  name,
@@ -10137,16 +10160,13 @@ class FormItem extends React__default.Component {
10137
10160
  onClick: (e2) => this.props.onClick && this.props.onClick(e2, this.componentRef)
10138
10161
  },
10139
10162
  label ? /* @__PURE__ */ React__default.createElement("div", { className: "nut-cell-title nut-form-item-label" }, renderLabel) : null,
10140
- /* @__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), /* @__PURE__ */ React__default.createElement(
10163
+ /* @__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(
10141
10164
  "div",
10142
10165
  {
10143
10166
  className: "nut-form-item-body-tips",
10144
- style: {
10145
- textAlign: errorMessageAlign,
10146
- display: (item == null ? void 0 : item.length) ? "initial" : "none"
10147
- }
10167
+ style: { textAlign: errorMessageAlign }
10148
10168
  },
10149
- (_a = item == null ? void 0 : item[0]) == null ? void 0 : _a.message
10169
+ item[0].message
10150
10170
  ))
10151
10171
  );
10152
10172
  });
@@ -10156,22 +10176,31 @@ class FormItem extends React__default.Component {
10156
10176
  };
10157
10177
  }
10158
10178
  componentDidMount() {
10159
- const { registerField } = this.context.getInternal(SECRET);
10179
+ const { registerField, registerUpdate } = this.context.getInternal(SECRET);
10160
10180
  this.cancelRegister = registerField(this);
10181
+ this.eventOff = registerUpdate(this, this.props.shouldUpdate);
10161
10182
  }
10162
10183
  componentWillUnmount() {
10163
10184
  if (this.cancelRegister) {
10164
10185
  this.cancelRegister();
10165
10186
  }
10187
+ if (this.eventOff) {
10188
+ this.eventOff();
10189
+ }
10166
10190
  }
10167
10191
  render() {
10168
10192
  const { children } = this.props;
10169
10193
  const child = Array.isArray(children) ? children[0] : children;
10170
- const returnChildNode = React__default.cloneElement(
10171
- child,
10172
- this.getControlled(child)
10173
- );
10174
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, { key: this.state.resetCount }, this.renderLayout(returnChildNode));
10194
+ let returnChildNode;
10195
+ if (!this.props.shouldUpdate) {
10196
+ returnChildNode = React__default.cloneElement(
10197
+ child,
10198
+ this.getControlled(child)
10199
+ );
10200
+ } else {
10201
+ returnChildNode = child(this.context);
10202
+ }
10203
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, { key: this.state.resetCount }, this.props.noStyle ? returnChildNode : this.renderLayout(returnChildNode));
10175
10204
  }
10176
10205
  }
10177
10206
  __publicField(FormItem, "defaultProps", defaultProps$Y);
@@ -12023,13 +12052,13 @@ const defaultProps$N = {
12023
12052
  // 1~6
12024
12053
  autoFocus: false
12025
12054
  };
12026
- const ShortPassword = (props) => {
12055
+ const InternalShortPassword = (props, ref) => {
12027
12056
  const { locale } = useConfig$1();
12028
12057
  const {
12029
12058
  title,
12030
12059
  description,
12031
12060
  tips,
12032
- visible,
12061
+ visible: deleteVisible,
12033
12062
  value,
12034
12063
  error,
12035
12064
  hideFooter,
@@ -12060,6 +12089,20 @@ const ShortPassword = (props) => {
12060
12089
  const format2 = (val) => {
12061
12090
  return val.slice(0, comLen);
12062
12091
  };
12092
+ const [visible, setVisible] = usePropsValue({
12093
+ value: props.visible,
12094
+ defaultValue: false,
12095
+ finalValue: false
12096
+ });
12097
+ const actions = {
12098
+ open: () => {
12099
+ setVisible(true);
12100
+ },
12101
+ close: () => {
12102
+ setVisible(false);
12103
+ }
12104
+ };
12105
+ useImperativeHandle(ref, () => actions);
12063
12106
  const [inputValue, setInputValue] = usePropsValue({ value, onChange });
12064
12107
  useEffect(() => {
12065
12108
  if (visible && autoFocus) {
@@ -12095,8 +12138,7 @@ const ShortPassword = (props) => {
12095
12138
  }))), /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-message` }, /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-message-error` }, error), /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-message-forget`, onClick: onTips }, tips || /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(z, { size: 11, style: { marginRight: "3px" } }), locale.shortpassword.tips))), !hideFooter && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-footer` }, /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-footer-cancel`, onClick: onCancel }, locale.cancel), /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-footer-sure`, onClick: sure }, locale.confirm)))
12096
12139
  );
12097
12140
  };
12098
- ShortPassword.defaultProps = defaultProps$N;
12099
- ShortPassword.displayName = "NutShortPassword";
12141
+ const ShortPassword = React__default.forwardRef(InternalShortPassword);
12100
12142
  const defaultProps$M = {
12101
12143
  ...ComponentDefaults,
12102
12144
  canvasId: "spcanvas",
@@ -18080,79 +18122,98 @@ const InternalBarrage = (props, ref) => {
18080
18122
  ...defaultProps$6,
18081
18123
  ...props
18082
18124
  };
18083
- const [styleList, setStyleList] = useState([]);
18084
- const [baItemList, setBaItemList] = useState(list);
18085
- const barrageListSet = useRef(list);
18086
18125
  const barrageBody = useRef(null);
18087
18126
  const barrageContainer = useRef(null);
18088
- const timeId = useRef((/* @__PURE__ */ new Date()).getTime());
18127
+ const barrageCWidth = useRef(0);
18089
18128
  const timer = useRef(0);
18090
- const classes = classNames(
18091
- classPrefix$1,
18092
- {
18093
- [`${classPrefix$1}-body${timeId.current}`]: true
18094
- },
18095
- className
18096
- );
18129
+ const index = useRef(0);
18130
+ const times = useRef([]);
18131
+ const historyIndex = useRef(-1);
18132
+ const classes = classNames(classPrefix$1, className);
18097
18133
  useImperativeHandle(ref, () => ({
18098
18134
  add: (word) => {
18099
- barrageListSet.current = [...barrageListSet.current, word];
18100
- run();
18135
+ const _index = index.current % list.length;
18136
+ if (!loop && index.current === list.length) {
18137
+ list.splice(list.length, 0, word);
18138
+ } else {
18139
+ list.splice(_index, 0, word);
18140
+ }
18101
18141
  }
18102
18142
  }));
18143
+ const getNodeWidth = async (node, type4 = "width") => {
18144
+ if (node) {
18145
+ const refe = await getRectByTaro(node);
18146
+ return Math.ceil(type4 === "height" ? refe.height : refe.width);
18147
+ }
18148
+ return 0;
18149
+ };
18103
18150
  useEffect(() => {
18104
- barrageListSet.current = [...list];
18105
- run();
18151
+ const init = async () => {
18152
+ if (barrageBody.current) {
18153
+ barrageCWidth.current = await getNodeWidth(barrageBody.current);
18154
+ }
18155
+ };
18156
+ init();
18157
+ setTimeout(() => {
18158
+ var _a;
18159
+ (_a = barrageBody.current) == null ? void 0 : _a.style.setProperty(
18160
+ "--move-distance",
18161
+ `-${barrageCWidth.current}px`
18162
+ );
18163
+ index.current = 0;
18164
+ run();
18165
+ }, 300);
18106
18166
  return () => {
18107
18167
  clearInterval(timer.current);
18108
18168
  };
18109
18169
  }, [list]);
18110
18170
  const run = () => {
18111
- setBaItemList(barrageListSet.current);
18112
- barrageListSet.current.forEach((item, index) => {
18113
- getNode(index);
18114
- });
18115
- };
18116
- const getNode = (index) => {
18117
- const query = createSelectorQuery();
18118
- setTimeout(() => {
18119
- let width = 100;
18120
- query.select(`.${classPrefix$1}-body${timeId.current}`).boundingClientRect((rec) => {
18121
- width = rec.width || 300;
18122
- });
18123
- query.select(`.${classPrefix$1}-item${index}`).boundingClientRect((recs) => {
18124
- const height = recs.height;
18125
- const nodeTop = `${index % rows * (height + gapY) + 20}px`;
18126
- styleInfo(index, nodeTop, width);
18127
- }).exec();
18128
- }, 500);
18171
+ clearInterval(timer.current);
18172
+ let intervalCache = interval;
18173
+ const _index = (loop ? index.current % list.length : index.current) % rows;
18174
+ const result = times.current[_index] - rows * interval;
18175
+ if (result > 0) {
18176
+ intervalCache += result;
18177
+ }
18178
+ timer.current = window.setTimeout(() => {
18179
+ play();
18180
+ }, intervalCache);
18129
18181
  };
18130
- const styleInfo = (index, nodeTop, width) => {
18131
- const timeIndex = index - rows > 0 ? index - rows : 0;
18132
- const list2 = styleList;
18133
- const time = list2[timeIndex] ? Number(list2[timeIndex]["--time"]) : 0;
18134
- const obj = {
18135
- top: nodeTop,
18136
- "--time": `${interval * index + time}`,
18137
- animationDuration: `${duration}ms`,
18138
- animationIterationCount: `${loop ? "infinite" : 1}`,
18139
- animationDelay: `${interval * index + time}ms`,
18140
- "--move-distance": `-${width}px`
18141
- };
18142
- list2.push(obj);
18143
- setStyleList([...list2]);
18182
+ const play = async () => {
18183
+ if (!loop && index.current >= list.length) {
18184
+ return;
18185
+ }
18186
+ const _index = loop ? index.current % list.length : index.current;
18187
+ const el = document.createElement(`View`);
18188
+ let currentIndex = _index % rows;
18189
+ if (currentIndex <= historyIndex.current || historyIndex.current === 3 && currentIndex !== 0 || Math.abs(currentIndex - historyIndex.current) !== 1) {
18190
+ currentIndex = historyIndex.current + 1 >= rows ? 0 : historyIndex.current + 1;
18191
+ }
18192
+ historyIndex.current = currentIndex;
18193
+ el.innerHTML = list[_index];
18194
+ el.classList.add("barrage-item");
18195
+ barrageContainer.current.appendChild(el);
18196
+ try {
18197
+ const width = await getNodeWidth(el);
18198
+ const height = await getNodeWidth(el, "height");
18199
+ el.classList.add("move");
18200
+ const elScrollDuration = width / barrageCWidth.current * duration;
18201
+ times.current[currentIndex] = Math.ceil(elScrollDuration);
18202
+ el.style.animationDuration = `${(duration + elScrollDuration).toFixed(
18203
+ 2
18204
+ )}ms`;
18205
+ el.style.top = `${currentIndex * (height + gapY) + 20}px`;
18206
+ el.style.width = `${width}px`;
18207
+ } catch (error) {
18208
+ console.log("异常自动流转到下一个");
18209
+ }
18210
+ el.addEventListener("animationend", () => {
18211
+ barrageContainer.current.removeChild(el);
18212
+ });
18213
+ index.current++;
18214
+ run();
18144
18215
  };
18145
- return /* @__PURE__ */ React__default.createElement("div", { className: classes, ref: barrageBody, ...restProps }, /* @__PURE__ */ React__default.createElement("div", { ref: barrageContainer, className: "bContainer" }, baItemList.map((item, index) => {
18146
- return /* @__PURE__ */ React__default.createElement(
18147
- "div",
18148
- {
18149
- className: `barrage-item ${classPrefix$1}-item${index} move`,
18150
- style: styleList[index],
18151
- key: index
18152
- },
18153
- item.length > 8 ? `${item.substr(0, 8)}...` : item
18154
- );
18155
- })));
18216
+ return /* @__PURE__ */ React__default.createElement(View, { className: classes, ref: barrageBody, ...restProps }, /* @__PURE__ */ React__default.createElement(View, { ref: barrageContainer, className: "bContainer" }));
18156
18217
  };
18157
18218
  const Barrage = React__default.forwardRef(
18158
18219
  InternalBarrage