@nutui/nutui-react-taro 2.7.1 → 2.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +36 -10
  2. package/dist/esm/Animate/style/style.css +1 -1
  3. package/dist/esm/Elevator.js +1 -1
  4. package/dist/esm/Empty.js +1 -1
  5. package/dist/esm/Form/style/style.css +1 -1
  6. package/dist/esm/Form.js +6 -5
  7. package/dist/esm/FormItem/style/style.css +1 -1
  8. package/dist/esm/FormItem.js +1 -1
  9. package/dist/esm/Popover/style/style.css +1 -1
  10. package/dist/esm/Table/style/style.css +1 -1
  11. package/dist/esm/Tour/style/style.css +1 -1
  12. package/dist/esm/Uploader/style/style.css +1 -1
  13. package/dist/esm/Uploader.js +1 -1
  14. package/dist/esm/{elevator.taro-Bsc8PcT0.js → elevator.taro-C0Gs93x7.js} +5 -3
  15. package/dist/esm/{empty.taro-Dt07kty5.js → empty.taro-DhCHSdca.js} +9 -1
  16. package/dist/esm/{formitem.taro-CEWRz5EJ.js → formitem.taro-CU6rrcJD.js} +105 -47
  17. package/dist/esm/nutui-react.es.js +4 -4
  18. package/dist/esm/{uploader.taro-CceZ5Y4t.js → uploader.taro-C3hV5Aih.js} +3 -1
  19. package/dist/locales/base.js +1 -1
  20. package/dist/locales/en-US.js +1 -1
  21. package/dist/locales/id-ID.js +1 -1
  22. package/dist/locales/tr-TR.js +1 -1
  23. package/dist/locales/zh-CN.js +1 -1
  24. package/dist/locales/zh-TW.js +1 -1
  25. package/dist/locales/zh-UG.js +1 -1
  26. package/dist/nutui.react.es.js +247 -148
  27. package/dist/nutui.react.umd.js +246 -147
  28. package/dist/packages/animate/animate.scss +0 -3
  29. package/dist/packages/form/form.scss +0 -68
  30. package/dist/packages/formitem/formitem.scss +90 -21
  31. package/dist/packages/popover/popover.scss +16 -11
  32. package/dist/packages/table/table.scss +1 -0
  33. package/dist/packages/uploader/uploader.scss +2 -1
  34. package/dist/style.css +1 -1
  35. package/dist/styles/variables.scss +1 -0
  36. package/dist/types/packages/configprovider/types.d.ts +1 -1
  37. package/dist/types/packages/empty/types.d.ts +10 -1
  38. package/dist/types/packages/empty/utils.d.ts +2 -0
  39. package/dist/types/packages/form/form.d.ts +2 -0
  40. package/dist/types/packages/form/form.taro.d.ts +10 -0
  41. package/dist/types/packages/form/types.d.ts +2 -1
  42. package/dist/types/packages/formitem/formitem.d.ts +1 -0
  43. package/dist/types/packages/formitem/formitem.taro.d.ts +1 -0
  44. package/dist/types/packages/video/video.d.ts +6 -2
  45. package/dist/types/utils/merge.d.ts +1 -0
  46. package/dist/types/utils/to-array.d.ts +1 -0
  47. package/package.json +1 -1
@@ -2,7 +2,7 @@
2
2
  typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("@tarojs/taro"), require("@tarojs/components"), require("react-dom")) : typeof define === "function" && define.amd ? define(["exports", "react", "@tarojs/taro", "@tarojs/components", "react-dom"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory((global2.nutui = global2.nutui || {}, global2.nutui.react = {}), global2.React, global2.Taro, global2.components, global2.ReactDOM));
3
3
  })(this, function(exports2, React, Taro, components, ReactDOM) {
4
4
  "use strict";/*!
5
- * @nutui/nutui-react-taro v2.7.1 Fri Nov 22 2024 15:43:06 GMT+0800 (Central Standard Time)
5
+ * @nutui/nutui-react-taro v2.7.3 Fri Dec 13 2024 15:47:49 GMT+0800 (China Standard Time)
6
6
  * (c) 2023 @jdf2e.
7
7
  * Released under the MIT License.
8
8
  */
@@ -4196,6 +4196,21 @@
4196
4196
  return /* @__PURE__ */ React.createElement("div", { className: cls, style: styles, onClick: (e2) => goTop(e2) }, children || /* @__PURE__ */ React.createElement(N, { size: 19, className: "nut-backtop-main" }));
4197
4197
  };
4198
4198
  BackTop.displayName = "NutBackTop";
4199
+ const idCounter = {};
4200
+ function uniqueId(prefix = "$nut$") {
4201
+ if (!idCounter[prefix]) {
4202
+ idCounter[prefix] = 0;
4203
+ }
4204
+ const id = ++idCounter[prefix];
4205
+ if (prefix === "$nut$") {
4206
+ return `${id}`;
4207
+ }
4208
+ return `${prefix}${id}`;
4209
+ }
4210
+ function useUuid() {
4211
+ const idRef = React.useRef(uniqueId());
4212
+ return idRef.current;
4213
+ }
4199
4214
  const elevatorContext = React.createContext({});
4200
4215
  const defaultProps$1i = {
4201
4216
  ...ComponentDefaults,
@@ -4227,6 +4242,7 @@
4227
4242
  ...defaultProps$1i,
4228
4243
  ...props
4229
4244
  };
4245
+ const uuid = useUuid();
4230
4246
  const classPrefix2 = "nut-elevator";
4231
4247
  const listview = React.useRef(null);
4232
4248
  const initData = {
@@ -4263,7 +4279,7 @@
4263
4279
  state.current.listHeight.push(height2);
4264
4280
  for (let i2 = 0; i2 < state.current.listGroup.length; i2++) {
4265
4281
  const query = Taro.createSelectorQuery();
4266
- query.selectAll(`.${className} .nut-elevator-item-${i2}`).boundingClientRect();
4282
+ query.selectAll(`.${classPrefix2}-${uuid} .nut-elevator-item-${i2}`).boundingClientRect();
4267
4283
  query.exec((res) => {
4268
4284
  if (res[0][0]) height2 += res[0][0].height;
4269
4285
  state.current.listHeight.push(height2);
@@ -4322,7 +4338,7 @@
4322
4338
  };
4323
4339
  const setListGroup = () => {
4324
4340
  if (listview.current) {
4325
- Taro.createSelectorQuery().selectAll(`.${className} .nut-elevator-list-item`).node((el) => {
4341
+ Taro.createSelectorQuery().selectAll(`.${classPrefix2}-${uuid} .nut-elevator-list-item`).node((el) => {
4326
4342
  state.current.listGroup = [...Object.keys(el)];
4327
4343
  calculateHeight();
4328
4344
  }).exec();
@@ -4356,86 +4372,96 @@
4356
4372
  });
4357
4373
  }
4358
4374
  }, [listview]);
4359
- return /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2} ${className}`, style, ...rest }, /* @__PURE__ */ React.createElement(
4375
+ return /* @__PURE__ */ React.createElement(
4360
4376
  "div",
4361
4377
  {
4362
- className: `${classPrefix2}-list`,
4363
- style: { height: Number.isNaN(+height) ? height : `${height}px` }
4378
+ className: `${classPrefix2} ${className} ${classPrefix2}-${uuid}`,
4379
+ style,
4380
+ ...rest
4364
4381
  },
4365
4382
  /* @__PURE__ */ React.createElement(
4366
- components.ScrollView,
4383
+ "div",
4367
4384
  {
4368
- scrollTop,
4369
- scrollY: true,
4370
- scrollWithAnimation: true,
4371
- scrollAnchoring: true,
4372
- className: `${classPrefix2}-list-inner`,
4373
- type: "list",
4374
- ref: listview,
4375
- onScroll: listViewScroll,
4376
- onTouchStart: (e2) => {
4377
- scrolling.current = false;
4378
- }
4385
+ className: `${classPrefix2}-list`,
4386
+ style: { height: Number.isNaN(+height) ? height : `${height}px` }
4387
+ },
4388
+ /* @__PURE__ */ React.createElement(
4389
+ components.ScrollView,
4390
+ {
4391
+ scrollTop,
4392
+ scrollY: true,
4393
+ scrollWithAnimation: true,
4394
+ scrollAnchoring: true,
4395
+ className: `${classPrefix2}-list-inner`,
4396
+ type: "list",
4397
+ ref: listview,
4398
+ onScroll: listViewScroll,
4399
+ onTouchStart: (e2) => {
4400
+ scrolling.current = false;
4401
+ }
4402
+ },
4403
+ list.map((item, idx) => {
4404
+ return /* @__PURE__ */ React.createElement(
4405
+ "div",
4406
+ {
4407
+ className: `${classPrefix2}-list-item nut-elevator-item-${idx}`,
4408
+ key: idx
4409
+ },
4410
+ /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-list-item-code` }, item[floorKey]),
4411
+ /* @__PURE__ */ React.createElement(React.Fragment, null, item.list.map((subitem) => {
4412
+ return /* @__PURE__ */ React.createElement(
4413
+ "div",
4414
+ {
4415
+ className: classNames({
4416
+ [`${classPrefix2}-list-item-name`]: true,
4417
+ [`${classPrefix2}-list-item-name-highcolor`]: currentData.id === subitem.id && currentKey === item[floorKey]
4418
+ }),
4419
+ key: subitem.id,
4420
+ onClick: () => handleClickItem(item[floorKey], subitem)
4421
+ },
4422
+ children ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(elevatorContext.Provider, { value: subitem }, children)) : subitem.name
4423
+ );
4424
+ }))
4425
+ );
4426
+ })
4427
+ )
4428
+ ),
4429
+ showKeys ? /* @__PURE__ */ React.createElement(React.Fragment, null, list.length && scrollStart ? /* @__PURE__ */ React.createElement(
4430
+ "div",
4431
+ {
4432
+ className: classNames({
4433
+ [`${classPrefix2}-code-current`]: true,
4434
+ [`${classPrefix2}-code-current-current`]: true
4435
+ })
4379
4436
  },
4380
- list.map((item, idx) => {
4437
+ list[codeIndex][floorKey]
4438
+ ) : null, /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-bars` }, /* @__PURE__ */ React.createElement(
4439
+ "div",
4440
+ {
4441
+ className: `${classPrefix2}-bars-inner`,
4442
+ onTouchStart: (event) => touchStart(event),
4443
+ onTouchMove: (event) => touchMove(event),
4444
+ onTouchEnd: touchEnd,
4445
+ style: { touchAction: "pan-y" }
4446
+ },
4447
+ list.map((item, index) => {
4381
4448
  return /* @__PURE__ */ React.createElement(
4382
4449
  "div",
4383
4450
  {
4384
- className: `${classPrefix2}-list-item nut-elevator-item-${idx}`,
4385
- key: idx
4451
+ className: classNames({
4452
+ [`${classPrefix2}-bars-inner-item`]: true,
4453
+ [`${classPrefix2}-bars-inner-item-active`]: item[floorKey] === list[codeIndex][floorKey]
4454
+ }),
4455
+ "data-index": index,
4456
+ key: index,
4457
+ onClick: () => handleClickIndex(item[floorKey])
4386
4458
  },
4387
- /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-list-item-code` }, item[floorKey]),
4388
- /* @__PURE__ */ React.createElement(React.Fragment, null, item.list.map((subitem) => {
4389
- return /* @__PURE__ */ React.createElement(
4390
- "div",
4391
- {
4392
- className: classNames({
4393
- [`${classPrefix2}-list-item-name`]: true,
4394
- [`${classPrefix2}-list-item-name-highcolor`]: currentData.id === subitem.id && currentKey === item[floorKey]
4395
- }),
4396
- key: subitem.id,
4397
- onClick: () => handleClickItem(item[floorKey], subitem)
4398
- },
4399
- children ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(elevatorContext.Provider, { value: subitem }, children)) : subitem.name
4400
- );
4401
- }))
4459
+ item[floorKey]
4402
4460
  );
4403
4461
  })
4404
- )
4405
- ), showKeys ? /* @__PURE__ */ React.createElement(React.Fragment, null, list.length && scrollStart ? /* @__PURE__ */ React.createElement(
4406
- "div",
4407
- {
4408
- className: classNames({
4409
- [`${classPrefix2}-code-current`]: true,
4410
- [`${classPrefix2}-code-current-current`]: true
4411
- })
4412
- },
4413
- list[codeIndex][floorKey]
4414
- ) : null, /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-bars` }, /* @__PURE__ */ React.createElement(
4415
- "div",
4416
- {
4417
- className: `${classPrefix2}-bars-inner`,
4418
- onTouchStart: (event) => touchStart(event),
4419
- onTouchMove: (event) => touchMove(event),
4420
- onTouchEnd: touchEnd,
4421
- style: { touchAction: "pan-y" }
4422
- },
4423
- list.map((item, index) => {
4424
- return /* @__PURE__ */ React.createElement(
4425
- "div",
4426
- {
4427
- className: classNames({
4428
- [`${classPrefix2}-bars-inner-item`]: true,
4429
- [`${classPrefix2}-bars-inner-item-active`]: item[floorKey] === list[codeIndex][floorKey]
4430
- }),
4431
- "data-index": index,
4432
- key: index,
4433
- onClick: () => handleClickIndex(item[floorKey])
4434
- },
4435
- item[floorKey]
4436
- );
4437
- })
4438
- ))) : null, sticky && scrollY > 0 ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-list-fixed` }, /* @__PURE__ */ React.createElement("span", { className: `${classPrefix2}-list-fixed-title` }, list[codeIndex][floorKey])) : null);
4462
+ ))) : null,
4463
+ sticky && scrollY > 0 ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-list-fixed` }, /* @__PURE__ */ React.createElement("span", { className: `${classPrefix2}-list-fixed-title` }, list[codeIndex][floorKey])) : null
4464
+ );
4439
4465
  };
4440
4466
  Elevator.displayName = "NutElevator";
4441
4467
  Elevator.Context = elevatorContext;
@@ -5221,21 +5247,6 @@
5221
5247
  };
5222
5248
  }
5223
5249
  const requestAniFrame$1 = requestAniFrame();
5224
- const idCounter = {};
5225
- function uniqueId(prefix = "$nut$") {
5226
- if (!idCounter[prefix]) {
5227
- idCounter[prefix] = 0;
5228
- }
5229
- const id = ++idCounter[prefix];
5230
- if (prefix === "$nut$") {
5231
- return `${id}`;
5232
- }
5233
- return `${prefix}${id}`;
5234
- }
5235
- function useUuid() {
5236
- const idRef = React.useRef(uniqueId());
5237
- return idRef.current;
5238
- }
5239
5250
  const defaultProps$18 = {
5240
5251
  ...ComponentDefaults,
5241
5252
  tabStyle: {},
@@ -9845,6 +9856,25 @@
9845
9856
  Schema.warning = warning;
9846
9857
  Schema.messages = messages;
9847
9858
  Schema.validators = validators;
9859
+ function merge(...objects) {
9860
+ const result = Array.isArray(objects[0]) ? [] : {};
9861
+ function mergeHelper(obj, path = []) {
9862
+ for (const [key, value] of Object.entries(obj)) {
9863
+ const newPath = [...path, key];
9864
+ if (Array.isArray(value)) {
9865
+ result[key] = [...value];
9866
+ } else if (typeof value === "object" && value !== null) {
9867
+ if (path.some((p) => p === value)) continue;
9868
+ if (!result[key]) result[key] = {};
9869
+ mergeHelper(value, newPath);
9870
+ } else {
9871
+ result[key] = value;
9872
+ }
9873
+ }
9874
+ }
9875
+ objects.filter((obj) => !!obj).forEach((obj) => mergeHelper(obj));
9876
+ return result;
9877
+ }
9848
9878
  const SECRET = "NUT_FORM_INTERNAL";
9849
9879
  class FormStore {
9850
9880
  constructor() {
@@ -9877,17 +9907,16 @@
9877
9907
  });
9878
9908
  return fieldsValue;
9879
9909
  };
9880
- this.setInitialValues = (values, init) => {
9910
+ this.setInitialValues = (initialValues, init) => {
9911
+ this.initialValues = initialValues || {};
9881
9912
  if (init) {
9882
- this.initialValues = values;
9883
- this.store = values;
9913
+ const nextStore = merge(initialValues, this.store);
9914
+ this.updateStore(nextStore);
9884
9915
  }
9885
9916
  };
9886
- this.setFieldsValue = (newStore, needValidate = true) => {
9887
- this.store = {
9888
- ...this.store,
9889
- ...newStore
9890
- };
9917
+ this.setFieldsValue = (newStore) => {
9918
+ const nextStore = merge(this.store, newStore);
9919
+ this.updateStore(nextStore);
9891
9920
  this.fieldEntities.forEach((entity) => {
9892
9921
  const { name } = entity.props;
9893
9922
  Object.keys(newStore).forEach((key) => {
@@ -9905,7 +9934,12 @@
9905
9934
  item.entity.onStoreChange("update");
9906
9935
  }
9907
9936
  });
9908
- needValidate && this.validateFields();
9937
+ };
9938
+ this.setFieldValue = (name, value) => {
9939
+ const store = {
9940
+ [name]: value
9941
+ };
9942
+ this.setFieldsValue(store);
9909
9943
  };
9910
9944
  this.setCallback = (callback) => {
9911
9945
  this.callbacks = {
@@ -9916,6 +9950,10 @@
9916
9950
  this.validateEntities = async (entity, errs) => {
9917
9951
  var _a;
9918
9952
  const { name, rules: rules2 = [] } = entity.props;
9953
+ if (!name) {
9954
+ console.warn("Form field missing name property");
9955
+ return;
9956
+ }
9919
9957
  const descriptor = {};
9920
9958
  if (rules2.length) {
9921
9959
  if (rules2.length > 1) {
@@ -9971,7 +10009,8 @@
9971
10009
  };
9972
10010
  this.resetFields = () => {
9973
10011
  this.errors.length = 0;
9974
- this.store = this.initialValues;
10012
+ const nextStore = merge({}, this.initialValues);
10013
+ this.updateStore(nextStore);
9975
10014
  this.fieldEntities.forEach((entity) => {
9976
10015
  entity.onStoreChange("reset");
9977
10016
  });
@@ -10006,6 +10045,7 @@
10006
10045
  getFieldValue: this.getFieldValue,
10007
10046
  getFieldsValue: this.getFieldsValue,
10008
10047
  setFieldsValue: this.setFieldsValue,
10048
+ setFieldValue: this.setFieldValue,
10009
10049
  resetFields: this.resetFields,
10010
10050
  validateFields: this.validateFields,
10011
10051
  submit: this.submit,
@@ -10020,6 +10060,9 @@
10020
10060
  }
10021
10061
  };
10022
10062
  }
10063
+ updateStore(nextStore) {
10064
+ this.store = nextStore;
10065
+ }
10023
10066
  }
10024
10067
  const useForm = (form) => {
10025
10068
  const formRef = React.useRef();
@@ -10037,7 +10080,9 @@
10037
10080
  ...ComponentDefaults,
10038
10081
  labelPosition: "right",
10039
10082
  starPosition: "left",
10083
+ disabled: false,
10040
10084
  divider: false,
10085
+ validateTrigger: "onChange",
10041
10086
  onFinish: (values) => {
10042
10087
  },
10043
10088
  onFinishFailed: (values, errorFields) => {
@@ -10058,8 +10103,10 @@
10058
10103
  children,
10059
10104
  initialValues,
10060
10105
  divider,
10106
+ disabled,
10061
10107
  onFinish,
10062
10108
  onFinishFailed,
10109
+ validateTrigger,
10063
10110
  labelPosition,
10064
10111
  starPosition,
10065
10112
  form
@@ -10087,7 +10134,7 @@
10087
10134
  mountRef.current = true;
10088
10135
  }
10089
10136
  return /* @__PURE__ */ React.createElement(
10090
- "form",
10137
+ components.Form,
10091
10138
  {
10092
10139
  className: classNames(
10093
10140
  classPrefix2,
@@ -10106,7 +10153,13 @@
10106
10153
  resetFields();
10107
10154
  }
10108
10155
  },
10109
- /* @__PURE__ */ React.createElement(Cell.Group, { divider }, /* @__PURE__ */ React.createElement(Context.Provider, { value: formInstance }, children), footer ? /* @__PURE__ */ React.createElement(Cell, { className: `${classPrefix2}-footer` }, footer) : null)
10156
+ /* @__PURE__ */ React.createElement(Cell.Group, { divider }, /* @__PURE__ */ React.createElement(
10157
+ Context.Provider,
10158
+ {
10159
+ value: { formInstance, labelPosition, disabled, validateTrigger }
10160
+ },
10161
+ children
10162
+ ), footer ? /* @__PURE__ */ React.createElement(Cell, { className: `${classPrefix2}-footer` }, footer) : null)
10110
10163
  );
10111
10164
  }
10112
10165
  );
@@ -10120,6 +10173,12 @@
10120
10173
  }
10121
10174
  ).$$typeof === component.type.$$typeof;
10122
10175
  }
10176
+ function toArray(value) {
10177
+ if (value === void 0 || value === null) {
10178
+ return [];
10179
+ }
10180
+ return Array.isArray(value) ? value : [value];
10181
+ }
10123
10182
  const defaultProps$X = {
10124
10183
  ...ComponentDefaults,
10125
10184
  required: false,
@@ -10127,7 +10186,6 @@
10127
10186
  label: "",
10128
10187
  rules: [{ required: false, message: "" }],
10129
10188
  errorMessageAlign: "left",
10130
- validateTrigger: "onChange",
10131
10189
  shouldUpdate: false,
10132
10190
  noStyle: false
10133
10191
  };
@@ -10136,15 +10194,21 @@
10136
10194
  super(props);
10137
10195
  this.getControlled = (children) => {
10138
10196
  var _a;
10139
- const { setFieldsValue, getFieldValue } = this.context;
10140
- const { dispatch } = this.context.getInternal(SECRET);
10197
+ const { setFieldsValue, getFieldValue } = this.context.formInstance;
10198
+ const { dispatch } = this.context.formInstance.getInternal(SECRET);
10141
10199
  const { name = "" } = this.props;
10142
10200
  if ((_a = children == null ? void 0 : children.props) == null ? void 0 : _a.defaultValue) {
10143
- console.warn("通过 initialValue 设置初始值");
10201
+ if (process.env.NODE_ENV !== "production") {
10202
+ console.warn(
10203
+ "[NutUI] FormItem:",
10204
+ "请通过 initialValue 设置初始值,而不是 defaultValue"
10205
+ );
10206
+ }
10144
10207
  }
10145
10208
  const fieldValue = getFieldValue(name);
10146
10209
  const controlled = {
10147
10210
  ...children.props,
10211
+ className: children.props.className,
10148
10212
  [this.props.valuePropName || "value"]: fieldValue !== void 0 ? fieldValue : this.props.initialValue,
10149
10213
  [this.props.trigger || "onChange"]: (...args) => {
10150
10214
  const originOnChange = children.props[this.props.trigger || "onChange"];
@@ -10155,27 +10219,25 @@
10155
10219
  if (this.props.getValueFromEvent) {
10156
10220
  next = this.props.getValueFromEvent(...args);
10157
10221
  }
10158
- setFieldsValue({ [name]: next }, false);
10222
+ setFieldsValue({ [name]: next });
10159
10223
  }
10160
10224
  };
10161
10225
  const { validateTrigger } = this.props;
10162
- let validateTriggers = [this.props.trigger || "onChange"];
10163
- if (validateTrigger) {
10164
- validateTriggers = typeof validateTrigger === "string" ? [validateTrigger] : [...validateTrigger];
10165
- validateTriggers.forEach((trigger) => {
10166
- const originTrigger = controlled[trigger];
10167
- controlled[trigger] = (...args) => {
10168
- if (originTrigger) {
10169
- originTrigger(...args);
10170
- }
10171
- if (this.props.rules && this.props.rules.length) {
10172
- dispatch({
10173
- name: this.props.name
10174
- });
10175
- }
10176
- };
10177
- });
10178
- }
10226
+ const mergedValidateTrigger = validateTrigger || this.context.validateTrigger;
10227
+ const validateTriggers = toArray(mergedValidateTrigger);
10228
+ validateTriggers.forEach((trigger) => {
10229
+ const originTrigger = controlled[trigger];
10230
+ controlled[trigger] = (...args) => {
10231
+ if (originTrigger) {
10232
+ originTrigger(...args);
10233
+ }
10234
+ if (this.props.rules && this.props.rules.length) {
10235
+ dispatch({
10236
+ name: this.props.name
10237
+ });
10238
+ }
10239
+ };
10240
+ });
10179
10241
  if (isForwardRefComponent(children)) {
10180
10242
  controlled.ref = (componentInstance) => {
10181
10243
  const originRef = children.ref;
@@ -10199,7 +10261,7 @@
10199
10261
  };
10200
10262
  this.onStoreChange = (type2) => {
10201
10263
  if (type2 === "reset") {
10202
- this.context.errors[this.props.name] = [];
10264
+ this.context.formInstance.errors[this.props.name] = [];
10203
10265
  this.refresh();
10204
10266
  } else {
10205
10267
  this.forceUpdate();
@@ -10214,37 +10276,50 @@
10214
10276
  rules: rules2,
10215
10277
  className,
10216
10278
  style,
10217
- align,
10218
- errorMessageAlign
10279
+ errorMessageAlign,
10280
+ align
10219
10281
  } = {
10220
10282
  ...defaultProps$X,
10221
10283
  ...this.props
10222
10284
  };
10223
10285
  const requiredInRules = rules2 == null ? void 0 : rules2.some((rule) => rule.required);
10224
- const item = name ? this.context.errors[name] : [];
10225
- const { starPosition } = this.context;
10226
- const renderStar = (required2 || requiredInRules) && /* @__PURE__ */ React.createElement("i", { className: "required" });
10227
- const renderLabel = /* @__PURE__ */ React.createElement(React.Fragment, null, starPosition === "left" ? renderStar : null, label, starPosition === "right" ? renderStar : null);
10286
+ const item = name ? this.context.formInstance.errors[name] : [];
10287
+ const { starPosition } = this.context.formInstance;
10288
+ const renderStar = (required2 || requiredInRules) && /* @__PURE__ */ React.createElement(components.Text, { className: "nut-form-item-label-required required" }, "*");
10289
+ const renderLabel = /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(components.Text, { className: "nut-form-item-labeltxt" }, starPosition === "left" ? renderStar : null, label), starPosition === "right" ? renderStar : null);
10228
10290
  return /* @__PURE__ */ React.createElement(
10229
10291
  Cell,
10230
10292
  {
10231
- className: `nut-form-item ${className}`,
10293
+ className: `${this.getClassNameWithDirection("nut-form-item")} ${className}`,
10232
10294
  style,
10233
10295
  align,
10234
10296
  onClick: (e2) => this.props.onClick && this.props.onClick(e2, this.componentRef)
10235
10297
  },
10236
- label ? /* @__PURE__ */ React.createElement("div", { className: "nut-cell-title nut-form-item-label" }, renderLabel) : null,
10237
- /* @__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(
10238
- "div",
10298
+ label ? /* @__PURE__ */ React.createElement(
10299
+ components.View,
10239
10300
  {
10240
- className: "nut-form-item-body-tips",
10241
- style: {
10242
- textAlign: errorMessageAlign,
10243
- display: (item == null ? void 0 : item.length) ? "initial" : "none"
10244
- }
10301
+ className: `nut-cell-title ${this.getClassNameWithDirection("nut-form-item-label")}`
10245
10302
  },
10246
- (_a = item == null ? void 0 : item[0]) == null ? void 0 : _a.message
10247
- ))
10303
+ renderLabel
10304
+ ) : null,
10305
+ /* @__PURE__ */ React.createElement(
10306
+ components.View,
10307
+ {
10308
+ className: `nut-cell-value ${this.getClassNameWithDirection("nut-form-item-body")}`
10309
+ },
10310
+ /* @__PURE__ */ React.createElement(components.View, { className: "nut-form-item-body-slots" }, childNode),
10311
+ /* @__PURE__ */ React.createElement(
10312
+ components.View,
10313
+ {
10314
+ className: "nut-form-item-body-tips",
10315
+ style: {
10316
+ textAlign: errorMessageAlign,
10317
+ display: (item == null ? void 0 : item.length) ? "initial" : "none"
10318
+ }
10319
+ },
10320
+ (_a = item == null ? void 0 : item[0]) == null ? void 0 : _a.message
10321
+ )
10322
+ )
10248
10323
  );
10249
10324
  };
10250
10325
  this.componentRef = React.createRef();
@@ -10253,14 +10328,14 @@
10253
10328
  };
10254
10329
  }
10255
10330
  componentDidMount() {
10256
- const { store = {}, setInitialValues } = this.context.getInternal(SECRET);
10331
+ const { store = {}, setInitialValues } = this.context.formInstance.getInternal(SECRET);
10257
10332
  if (this.props.initialValue && this.props.name && !Object.keys(store).includes(this.props.name)) {
10258
10333
  setInitialValues(
10259
10334
  { ...store, [this.props.name]: this.props.initialValue },
10260
10335
  true
10261
10336
  );
10262
10337
  }
10263
- const { registerField, registerUpdate } = this.context.getInternal(SECRET);
10338
+ const { registerField, registerUpdate } = this.context.formInstance.getInternal(SECRET);
10264
10339
  this.cancelRegister = registerField(this);
10265
10340
  this.eventOff = registerUpdate(this, this.props.shouldUpdate);
10266
10341
  }
@@ -10272,6 +10347,12 @@
10272
10347
  this.eventOff();
10273
10348
  }
10274
10349
  }
10350
+ getClassNameWithDirection(className) {
10351
+ if (className && this.context.labelPosition) {
10352
+ return `${className} ${className}-${this.context.labelPosition}`;
10353
+ }
10354
+ return className;
10355
+ }
10275
10356
  render() {
10276
10357
  const { children } = this.props;
10277
10358
  const child = Array.isArray(children) ? children[0] : children;
@@ -10282,9 +10363,16 @@
10282
10363
  this.getControlled(child)
10283
10364
  );
10284
10365
  } else {
10285
- returnChildNode = child(this.context);
10366
+ returnChildNode = child(this.context.formInstance);
10286
10367
  }
10287
- return /* @__PURE__ */ React.createElement(React.Fragment, { key: this.state.resetCount }, this.props.noStyle ? returnChildNode : this.renderLayout(returnChildNode));
10368
+ return /* @__PURE__ */ React.createElement(React.Fragment, { key: this.state.resetCount }, /* @__PURE__ */ React.createElement(
10369
+ components.View,
10370
+ {
10371
+ className: this.context.disabled ? "nut-form-item-disabled" : "",
10372
+ catchMove: this.context.disabled
10373
+ },
10374
+ this.props.noStyle ? returnChildNode : this.renderLayout(returnChildNode)
10375
+ ));
10288
10376
  }
10289
10377
  };
10290
10378
  _FormItem.defaultProps = defaultProps$X;
@@ -13166,6 +13254,7 @@
13166
13254
  }
13167
13255
  };
13168
13256
  const readFile = (files) => {
13257
+ const results = [];
13169
13258
  files.forEach((file, index) => {
13170
13259
  var _a, _b;
13171
13260
  let fileType = file.type;
@@ -13201,8 +13290,9 @@
13201
13290
  fileItem.url = fileType === "video" ? file.thumbTempFilePath : filepath;
13202
13291
  }
13203
13292
  executeUpload(fileItem, index);
13204
- setFileList([...fileList, fileItem]);
13293
+ results.push(fileItem);
13205
13294
  });
13295
+ setFileList([...fileList, ...results]);
13206
13296
  };
13207
13297
  const filterFiles = (files) => {
13208
13298
  const maximum = maxCount * 1;
@@ -13798,6 +13888,12 @@
13798
13888
  );
13799
13889
  };
13800
13890
  Drag.displayName = "NutDrag";
13891
+ const getButtonType = (actions, index) => {
13892
+ if (!actions || actions.length === 0) return "default";
13893
+ const action = actions[index];
13894
+ if (action.type) return action.type;
13895
+ return actions.length > 1 && index === 0 ? "default" : "primary";
13896
+ };
13801
13897
  const defaultStatus = {
13802
13898
  empty: "https://storage.360buyimg.com/imgtools/30186cfda0-0d3eee40-c0ac-11ee-9382-9125782aa3b8.png",
13803
13899
  error: "https://storage.360buyimg.com/imgtools/f3278d0ebb-0ce360c0-c0ac-11ee-8375-193101bb1a46.png",
@@ -13861,10 +13957,13 @@
13861
13957
  [`${classPrefix$f}-actions-right`]: actions.length === 1,
13862
13958
  [`${classPrefix$f}-actions-left`]: actions.length > 1 && index === 0
13863
13959
  }),
13864
- type: `${actions.length > 1 && index === 0 ? "default" : "primary"}`,
13865
- size: "small",
13866
- fill: "outline",
13867
- key: `action-${index}`
13960
+ style: item.style,
13961
+ type: getButtonType(actions, index),
13962
+ size: item.size || "small",
13963
+ fill: item.fill || "outline",
13964
+ disabled: item.disabled || false,
13965
+ key: `action-${index}`,
13966
+ onClick: item.onClick || (() => void 0)
13868
13967
  },
13869
13968
  item == null ? void 0 : item.text
13870
13969
  );
@@ -1,7 +1,4 @@
1
1
  .nut-animate {
2
- .nut-ani-container {
3
- display: inline-block;
4
- }
5
2
  /* Animation css */
6
3
  [class*='nut-animate-'] {
7
4
  animation-duration: 0.5s;