@nutui/nutui-react-taro 2.7.0 → 2.7.2
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.
- package/CHANGELOG.md +39 -10
- package/dist/esm/ActionSheet.js +1 -1
- package/dist/esm/Address.js +1 -1
- package/dist/esm/Calendar.js +1 -1
- package/dist/esm/Cascader.js +1 -1
- package/dist/esm/DatePicker.js +1 -1
- package/dist/esm/Elevator.js +1 -1
- package/dist/esm/Form/style/style.css +1 -1
- package/dist/esm/Form.js +6 -5
- package/dist/esm/FormItem/style/style.css +1 -1
- package/dist/esm/FormItem.js +1 -1
- package/dist/esm/ImagePreview.js +1 -1
- package/dist/esm/NumberKeyboard.js +1 -1
- package/dist/esm/Picker.js +1 -1
- package/dist/esm/Popover.js +1 -1
- package/dist/esm/Popup.js +1 -1
- package/dist/esm/ShortPassword.js +1 -1
- package/dist/esm/SideNavBar.js +1 -1
- package/dist/esm/Table/style/style.css +1 -1
- package/dist/esm/TextArea.js +1 -1
- package/dist/esm/TimeSelect.js +1 -1
- package/dist/esm/Toast/style/index.js +1 -1
- package/dist/esm/Toast/style/style.css +1 -1
- package/dist/esm/Tour.js +1 -1
- package/dist/esm/Uploader/style/style.css +1 -1
- package/dist/esm/Uploader.js +1 -1
- package/dist/esm/{actionsheet.taro-CgfXnK1M.js → actionsheet.taro-kMhbV73n.js} +1 -1
- package/dist/esm/{address.taro-CAikNvuu.js → address.taro-C8CsajMW.js} +2 -2
- package/dist/esm/{calendar.taro-MkErd99P.js → calendar.taro-CM4yWFlF.js} +1 -1
- package/dist/esm/{cascader.taro-DEApf0aF.js → cascader.taro-DRE3asjI.js} +1 -1
- package/dist/esm/{datepicker.taro-DibmSueg.js → datepicker.taro-DU4OSraL.js} +1 -1
- package/dist/esm/{elevator.taro-Bsc8PcT0.js → elevator.taro-C0Gs93x7.js} +5 -3
- package/dist/esm/{formitem.taro-CEWRz5EJ.js → formitem.taro-CU6rrcJD.js} +105 -47
- package/dist/esm/{imagepreview.taro-C0yMREHT.js → imagepreview.taro-BE4mZT-S.js} +1 -1
- package/dist/esm/{numberkeyboard.taro-CIlStObb.js → numberkeyboard.taro-BvVO_MyJ.js} +1 -1
- package/dist/esm/nutui-react.es.js +18 -18
- package/dist/esm/{picker.taro-mCnxpFCY.js → picker.taro-CYNZBTE4.js} +1 -1
- package/dist/esm/{popover.taro-BHcidbZG.js → popover.taro-o5vHvHsm.js} +1 -1
- package/dist/esm/{popup.taro-DV32k5dP.js → popup.taro-JynjcLCn.js} +3 -3
- package/dist/esm/{shortpassword.taro-ByEtEDDl.js → shortpassword.taro-CUnXqjab.js} +1 -1
- package/dist/esm/{sidenavbar.taro-DNwoQw9u.js → sidenavbar.taro-C-AoUXLA.js} +1 -1
- package/dist/esm/{textarea.taro-EJQxRHZR.js → textarea.taro-PsaohYay.js} +2 -2
- package/dist/esm/{timeselect.taro-DE_a87DT.js → timeselect.taro-FIl91wiO.js} +1 -1
- package/dist/esm/{tour.taro-BvBZa8nq.js → tour.taro-DfOfyyte.js} +1 -1
- package/dist/esm/{uploader.taro-CceZ5Y4t.js → uploader.taro-C3hV5Aih.js} +3 -1
- package/dist/locales/base.js +1 -1
- package/dist/locales/en-US.js +1 -1
- package/dist/locales/id-ID.js +1 -1
- package/dist/locales/tr-TR.js +1 -1
- package/dist/locales/zh-CN.js +1 -1
- package/dist/locales/zh-TW.js +1 -1
- package/dist/locales/zh-UG.js +1 -1
- package/dist/nutui.react.es.js +237 -148
- package/dist/nutui.react.umd.js +236 -147
- package/dist/packages/form/form.scss +0 -68
- package/dist/packages/formitem/formitem.scss +90 -21
- package/dist/packages/table/table.scss +1 -0
- package/dist/packages/toast/toast.scss +1 -0
- package/dist/packages/uploader/uploader.scss +2 -1
- package/dist/style.css +1 -1
- package/dist/types/packages/form/form.d.ts +2 -0
- package/dist/types/packages/form/form.taro.d.ts +10 -0
- package/dist/types/packages/form/types.d.ts +2 -1
- package/dist/types/packages/formitem/formitem.d.ts +1 -0
- package/dist/types/packages/formitem/formitem.taro.d.ts +1 -0
- package/dist/types/packages/infiniteloading/infiniteloading.taro.d.ts +1 -1
- package/dist/types/utils/merge.d.ts +1 -0
- package/dist/types/utils/to-array.d.ts +1 -0
- package/package.json +1 -1
package/dist/nutui.react.umd.js
CHANGED
|
@@ -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.
|
|
5
|
+
* @nutui/nutui-react-taro v2.7.2 Fri Dec 06 2024 16:21:35 GMT+0800 (中国标准时间)
|
|
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(`.${
|
|
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(`.${
|
|
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(
|
|
4375
|
+
return /* @__PURE__ */ React.createElement(
|
|
4360
4376
|
"div",
|
|
4361
4377
|
{
|
|
4362
|
-
className: `${classPrefix2}
|
|
4363
|
-
style
|
|
4378
|
+
className: `${classPrefix2} ${className} ${classPrefix2}-${uuid}`,
|
|
4379
|
+
style,
|
|
4380
|
+
...rest
|
|
4364
4381
|
},
|
|
4365
4382
|
/* @__PURE__ */ React.createElement(
|
|
4366
|
-
|
|
4383
|
+
"div",
|
|
4367
4384
|
{
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
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
|
|
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:
|
|
4385
|
-
|
|
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
|
-
|
|
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
|
-
|
|
4406
|
-
|
|
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;
|
|
@@ -4795,7 +4821,7 @@
|
|
|
4795
4821
|
);
|
|
4796
4822
|
};
|
|
4797
4823
|
const renderNode = () => {
|
|
4798
|
-
return /* @__PURE__ */ React.createElement(
|
|
4824
|
+
return /* @__PURE__ */ React.createElement(components.View, { catchMove: true }, overlay ? /* @__PURE__ */ React.createElement(
|
|
4799
4825
|
Overlay,
|
|
4800
4826
|
{
|
|
4801
4827
|
style: overlayStyles,
|
|
@@ -4806,7 +4832,7 @@
|
|
|
4806
4832
|
duration,
|
|
4807
4833
|
onClick: onHandleClickOverlay
|
|
4808
4834
|
}
|
|
4809
|
-
) : null,
|
|
4835
|
+
) : null, renderPop());
|
|
4810
4836
|
};
|
|
4811
4837
|
React.useEffect(() => {
|
|
4812
4838
|
visible && open2();
|
|
@@ -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 = (
|
|
9910
|
+
this.setInitialValues = (initialValues, init) => {
|
|
9911
|
+
this.initialValues = initialValues || {};
|
|
9881
9912
|
if (init) {
|
|
9882
|
-
|
|
9883
|
-
this.
|
|
9913
|
+
const nextStore = merge(initialValues, this.store);
|
|
9914
|
+
this.updateStore(nextStore);
|
|
9884
9915
|
}
|
|
9885
9916
|
};
|
|
9886
|
-
this.setFieldsValue = (newStore
|
|
9887
|
-
this.store
|
|
9888
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
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 }
|
|
10222
|
+
setFieldsValue({ [name]: next });
|
|
10159
10223
|
}
|
|
10160
10224
|
};
|
|
10161
10225
|
const { validateTrigger } = this.props;
|
|
10162
|
-
|
|
10163
|
-
|
|
10164
|
-
|
|
10165
|
-
|
|
10166
|
-
|
|
10167
|
-
|
|
10168
|
-
|
|
10169
|
-
|
|
10170
|
-
|
|
10171
|
-
|
|
10172
|
-
|
|
10173
|
-
|
|
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
|
-
|
|
10218
|
-
|
|
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(
|
|
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:
|
|
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(
|
|
10237
|
-
|
|
10238
|
-
"div",
|
|
10298
|
+
label ? /* @__PURE__ */ React.createElement(
|
|
10299
|
+
components.View,
|
|
10239
10300
|
{
|
|
10240
|
-
className: "nut-form-item-
|
|
10241
|
-
|
|
10242
|
-
|
|
10243
|
-
|
|
10244
|
-
|
|
10301
|
+
className: `nut-cell-title ${this.getClassNameWithDirection("nut-form-item-label")}`
|
|
10302
|
+
},
|
|
10303
|
+
renderLabel
|
|
10304
|
+
) : null,
|
|
10305
|
+
/* @__PURE__ */ React.createElement(
|
|
10306
|
+
components.View,
|
|
10307
|
+
{
|
|
10308
|
+
className: `nut-cell-value ${this.getClassNameWithDirection("nut-form-item-body")}`
|
|
10245
10309
|
},
|
|
10246
|
-
|
|
10247
|
-
|
|
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 },
|
|
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;
|
|
@@ -12432,7 +12520,6 @@
|
|
|
12432
12520
|
defaultValue: "",
|
|
12433
12521
|
showCount: false,
|
|
12434
12522
|
maxLength: 140,
|
|
12435
|
-
placeholder: "",
|
|
12436
12523
|
readOnly: false,
|
|
12437
12524
|
disabled: false,
|
|
12438
12525
|
autoSize: false
|
|
@@ -12524,7 +12611,7 @@
|
|
|
12524
12611
|
onFocus: (e2) => handleFocus(e2),
|
|
12525
12612
|
autoHeight: autoSize,
|
|
12526
12613
|
maxlength: maxLength,
|
|
12527
|
-
placeholder: placeholder
|
|
12614
|
+
placeholder: placeholder === void 0 ? locale.placeholder : placeholder,
|
|
12528
12615
|
...rest
|
|
12529
12616
|
}
|
|
12530
12617
|
),
|
|
@@ -13167,6 +13254,7 @@
|
|
|
13167
13254
|
}
|
|
13168
13255
|
};
|
|
13169
13256
|
const readFile = (files) => {
|
|
13257
|
+
const results = [];
|
|
13170
13258
|
files.forEach((file, index) => {
|
|
13171
13259
|
var _a, _b;
|
|
13172
13260
|
let fileType = file.type;
|
|
@@ -13202,8 +13290,9 @@
|
|
|
13202
13290
|
fileItem.url = fileType === "video" ? file.thumbTempFilePath : filepath;
|
|
13203
13291
|
}
|
|
13204
13292
|
executeUpload(fileItem, index);
|
|
13205
|
-
|
|
13293
|
+
results.push(fileItem);
|
|
13206
13294
|
});
|
|
13295
|
+
setFileList([...fileList, ...results]);
|
|
13207
13296
|
};
|
|
13208
13297
|
const filterFiles = (files) => {
|
|
13209
13298
|
const maximum = maxCount * 1;
|