@nutui/nutui-react-taro 2.7.6 → 2.7.7
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 +20 -7
- package/dist/esm/Address/style/style.css +1 -1
- package/dist/esm/Address.js +1 -1
- package/dist/esm/Cascader/style/style.css +1 -1
- package/dist/esm/Cascader.js +1 -1
- package/dist/esm/DatePicker.js +1 -1
- package/dist/esm/Empty.js +1 -1
- package/dist/esm/Form.js +2 -1
- package/dist/esm/FormItem.js +1 -1
- package/dist/esm/TabPane.js +1 -1
- package/dist/esm/Tabs/style/style.css +1 -1
- package/dist/esm/Tabs.js +1 -1
- package/dist/esm/{address.taro-BCoDZM6h.js → address.taro-Ck0ZmxRg.js} +1 -1
- package/dist/esm/{cascader.taro-BwRnRQXE.js → cascader.taro-DUJvcGw0.js} +1 -1
- package/dist/esm/{datepicker.taro-DicskhhH.js → datepicker.taro-Dwh8sKhJ.js} +8 -0
- package/dist/esm/{empty.taro-DhCHSdca.js → empty.taro-ChtnK90s.js} +1 -1
- package/dist/esm/{formitem.taro-CU6rrcJD.js → formitem.taro-Bee3MWwq.js} +121 -31
- package/dist/esm/nutui-react.es.js +7 -7
- package/dist/esm/{tabpane.taro-BAe86j3t.js → tabpane.taro-BAihO3w8.js} +2 -1
- package/dist/esm/{tabs.taro-CnXiMR_B.js → tabs.taro-sp_DNWis.js} +26 -44
- 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 +161 -100
- package/dist/nutui.react.umd.js +161 -100
- package/dist/packages/tabs/tabs.scss +72 -115
- package/dist/style.css +1 -1
- package/dist/types/packages/form/__tests__/merge.spec.d.ts +1 -0
- package/dist/types/packages/form/index.d.ts +2 -1
- package/dist/types/packages/form/index.taro.d.ts +2 -1
- package/dist/types/packages/form/useform.d.ts +2 -1
- package/dist/types/packages/form/useform.taro.d.ts +2 -1
- package/dist/types/utils/merge.d.ts +14 -1
- package/package.json +1 -1
package/dist/nutui.react.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui-react
|
|
2
|
+
* @nutui/nutui-react v2.7.7 Fri Jan 24 2025 13:57:13 GMT+0800 (China Standard Time)
|
|
3
3
|
* (c) 2023 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -3922,7 +3922,7 @@ const Space = (props) => {
|
|
|
3922
3922
|
}));
|
|
3923
3923
|
};
|
|
3924
3924
|
Space.displayName = "NutSpace";
|
|
3925
|
-
function useWatch(dep, callback, config2 = { immediate: false }) {
|
|
3925
|
+
function useWatch$1(dep, callback, config2 = { immediate: false }) {
|
|
3926
3926
|
const { immediate } = config2;
|
|
3927
3927
|
const prev = useRef();
|
|
3928
3928
|
const inited = useRef(false);
|
|
@@ -4058,7 +4058,7 @@ const Sticky = (props) => {
|
|
|
4058
4058
|
const [rootRect, setRootRect] = useState({});
|
|
4059
4059
|
const [fixed, setFixed] = useState(false);
|
|
4060
4060
|
const [transform, setTransform] = useState(0);
|
|
4061
|
-
useWatch(fixed, () => {
|
|
4061
|
+
useWatch$1(fixed, () => {
|
|
4062
4062
|
onChange && onChange(fixed);
|
|
4063
4063
|
});
|
|
4064
4064
|
const rootStyle = useMemo$1(() => {
|
|
@@ -5253,7 +5253,7 @@ const TabPane = (props) => {
|
|
|
5253
5253
|
autoHeightClassName,
|
|
5254
5254
|
className
|
|
5255
5255
|
);
|
|
5256
|
-
return children
|
|
5256
|
+
return children && /* @__PURE__ */ React__default.createElement(View, { className: classes }, !disabled && children);
|
|
5257
5257
|
};
|
|
5258
5258
|
const inBrowser = typeof window !== "undefined";
|
|
5259
5259
|
function requestAniFrame() {
|
|
@@ -5297,24 +5297,19 @@ const Tabs = (props) => {
|
|
|
5297
5297
|
value: outerValue,
|
|
5298
5298
|
defaultValue: outerDefaultValue,
|
|
5299
5299
|
...rest
|
|
5300
|
-
} = {
|
|
5301
|
-
...defaultProps$18,
|
|
5302
|
-
...props
|
|
5303
|
-
};
|
|
5300
|
+
} = { ...defaultProps$18, ...props };
|
|
5304
5301
|
const uuid = useUuid();
|
|
5305
5302
|
const [value, setValue] = usePropsValue({
|
|
5306
5303
|
value: outerValue,
|
|
5307
5304
|
defaultValue: outerDefaultValue,
|
|
5308
|
-
finalValue: 0,
|
|
5309
5305
|
onChange
|
|
5310
5306
|
});
|
|
5311
5307
|
const titleItemsRef = useRef([]);
|
|
5312
|
-
const navRef = useRef(null);
|
|
5313
5308
|
const getTitles = () => {
|
|
5314
5309
|
const titles2 = [];
|
|
5315
5310
|
React__default.Children.forEach(children, (child, idx) => {
|
|
5316
5311
|
if (React__default.isValidElement(child)) {
|
|
5317
|
-
const
|
|
5312
|
+
const { props: props2 } = child;
|
|
5318
5313
|
if ((props2 == null ? void 0 : props2.title) || (props2 == null ? void 0 : props2.value)) {
|
|
5319
5314
|
titles2.push({
|
|
5320
5315
|
title: props2.title,
|
|
@@ -5349,13 +5344,8 @@ const Tabs = (props) => {
|
|
|
5349
5344
|
);
|
|
5350
5345
|
const classesTitle = classNames(`${classPrefix$k}-titles`, {
|
|
5351
5346
|
[`${classPrefix$k}-titles-${activeType}`]: activeType,
|
|
5352
|
-
[`${classPrefix$k}-titles-scrollable`]: true,
|
|
5353
5347
|
[`${classPrefix$k}-titles-${align}`]: align
|
|
5354
5348
|
});
|
|
5355
|
-
const tabsActiveStyle = {
|
|
5356
|
-
color: activeType === "smile" ? activeColor : "",
|
|
5357
|
-
background: activeType === "line" ? activeColor : ""
|
|
5358
|
-
};
|
|
5359
5349
|
const getRect2 = (selector) => {
|
|
5360
5350
|
return new Promise((resolve) => {
|
|
5361
5351
|
createSelectorQuery().select(selector).boundingClientRect().exec((rect = []) => {
|
|
@@ -5371,22 +5361,15 @@ const Tabs = (props) => {
|
|
|
5371
5361
|
});
|
|
5372
5362
|
};
|
|
5373
5363
|
const scrollWithAnimation = useRef(false);
|
|
5374
|
-
const navRectRef = useRef();
|
|
5375
|
-
const titleRectRef = useRef([]);
|
|
5376
5364
|
const [scrollLeft, setScrollLeft] = useState(0);
|
|
5377
5365
|
const [scrollTop, setScrollTop] = useState(0);
|
|
5378
5366
|
const scrollDirection = (to, direction2) => {
|
|
5379
5367
|
let count = 0;
|
|
5380
5368
|
const frames = 1;
|
|
5381
5369
|
function animate() {
|
|
5382
|
-
if (direction2 === "horizontal")
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
setScrollTop(to);
|
|
5386
|
-
}
|
|
5387
|
-
if (++count < frames) {
|
|
5388
|
-
requestAniFrame$1(animate);
|
|
5389
|
-
}
|
|
5370
|
+
if (direction2 === "horizontal") setScrollLeft(to);
|
|
5371
|
+
else setScrollTop(to);
|
|
5372
|
+
if (++count < frames) requestAniFrame$1(animate);
|
|
5390
5373
|
}
|
|
5391
5374
|
animate();
|
|
5392
5375
|
};
|
|
@@ -5396,17 +5379,17 @@ const Tabs = (props) => {
|
|
|
5396
5379
|
getRect2(`#nut-tabs-titles-${name || uuid} .nut-tabs-list`),
|
|
5397
5380
|
getAllRect(`#nut-tabs-titles-${name || uuid} .nut-tabs-titles-item`)
|
|
5398
5381
|
]).then(([navRect, titleRects]) => {
|
|
5399
|
-
|
|
5400
|
-
titleRectRef.current = titleRects;
|
|
5401
|
-
const titleRect = titleRectRef.current[index];
|
|
5382
|
+
const titleRect = titleRects[index];
|
|
5402
5383
|
if (!titleRect) return;
|
|
5403
5384
|
let to = 0;
|
|
5404
5385
|
if (direction === "vertical") {
|
|
5405
5386
|
const top = titleRects.slice(0, index).reduce((prev, curr) => prev + curr.height, 0);
|
|
5406
|
-
to = top - (
|
|
5387
|
+
to = top - (navRect.height - titleRect.height) / 2;
|
|
5407
5388
|
} else {
|
|
5408
5389
|
const left2 = titleRects.slice(0, index).reduce((prev, curr) => prev + curr.width, 0);
|
|
5409
|
-
to =
|
|
5390
|
+
to = left2 - (navRect.width - titleRect.width) / 2;
|
|
5391
|
+
if (to < 0) return;
|
|
5392
|
+
to = rtl ? -to : to;
|
|
5410
5393
|
}
|
|
5411
5394
|
nextTick(() => {
|
|
5412
5395
|
scrollWithAnimation.current = true;
|
|
@@ -5421,7 +5404,7 @@ const Tabs = (props) => {
|
|
|
5421
5404
|
);
|
|
5422
5405
|
index = index < 0 ? 0 : index;
|
|
5423
5406
|
return {
|
|
5424
|
-
transform: direction === "horizontal" ? `translate3d(${rtl ? "" : "-"}${index * 100}%, 0, 0)` : `translate3d( 0
|
|
5407
|
+
transform: direction === "horizontal" ? `translate3d(${rtl ? "" : "-"}${index * 100}%, 0, 0)` : `translate3d( 0, -${index * 100}%, 0)`,
|
|
5425
5408
|
transitionDuration: `${duration}ms`
|
|
5426
5409
|
};
|
|
5427
5410
|
};
|
|
@@ -5432,12 +5415,11 @@ const Tabs = (props) => {
|
|
|
5432
5415
|
index = index < 0 ? 0 : index;
|
|
5433
5416
|
scrollIntoView(index);
|
|
5434
5417
|
}, [value]);
|
|
5435
|
-
const tabChange = (item
|
|
5418
|
+
const tabChange = (item) => {
|
|
5436
5419
|
onClick && onClick(item.value);
|
|
5437
|
-
if (item.disabled) {
|
|
5438
|
-
|
|
5420
|
+
if (!item.disabled) {
|
|
5421
|
+
setValue(item.value);
|
|
5439
5422
|
}
|
|
5440
|
-
setValue(item.value);
|
|
5441
5423
|
};
|
|
5442
5424
|
return /* @__PURE__ */ React__default.createElement(View, { className: classes, ...rest }, /* @__PURE__ */ React__default.createElement(
|
|
5443
5425
|
ScrollView,
|
|
@@ -5452,71 +5434,55 @@ const Tabs = (props) => {
|
|
|
5452
5434
|
scrollWithAnimation: rtl && Taro.getEnv() !== "WEB" ? false : scrollWithAnimation.current,
|
|
5453
5435
|
id: `nut-tabs-titles-${name || uuid}`,
|
|
5454
5436
|
className: classesTitle,
|
|
5455
|
-
style:
|
|
5437
|
+
style: tabStyle
|
|
5456
5438
|
},
|
|
5457
|
-
/* @__PURE__ */ React__default.createElement(View, { className: "nut-tabs-list"
|
|
5439
|
+
/* @__PURE__ */ React__default.createElement(View, { className: "nut-tabs-list" }, !!title && typeof title === "function" ? title() : titles.current.map((item, index) => {
|
|
5458
5440
|
return /* @__PURE__ */ React__default.createElement(
|
|
5459
5441
|
View,
|
|
5460
5442
|
{
|
|
5443
|
+
key: item.value,
|
|
5461
5444
|
ref: (ref) => titleItemsRef.current.push(ref),
|
|
5462
5445
|
id: `scrollIntoView${index}`,
|
|
5463
|
-
onClick: (
|
|
5464
|
-
tabChange(item);
|
|
5465
|
-
},
|
|
5446
|
+
onClick: () => tabChange(item),
|
|
5466
5447
|
className: classNames(`${classPrefix$k}-titles-item`, {
|
|
5467
5448
|
[`nut-tabs-titles-item-active`]: !item.disabled && String(item.value) === String(value),
|
|
5468
5449
|
[`nut-tabs-titles-item-disabled`]: item.disabled,
|
|
5469
5450
|
[`nut-tabs-titles-item-${align}`]: align
|
|
5470
|
-
})
|
|
5471
|
-
key: item.value
|
|
5451
|
+
})
|
|
5472
5452
|
},
|
|
5473
5453
|
activeType === "line" && /* @__PURE__ */ React__default.createElement(
|
|
5474
5454
|
View,
|
|
5475
5455
|
{
|
|
5476
5456
|
className: classNames(
|
|
5477
5457
|
`${classPrefix$k}-titles-item-line`,
|
|
5478
|
-
{
|
|
5479
|
-
[`${classPrefix$k}-titles-item-line-${direction}`]: true
|
|
5480
|
-
}
|
|
5458
|
+
`${classPrefix$k}-titles-item-line-${direction}`
|
|
5481
5459
|
),
|
|
5482
|
-
style:
|
|
5460
|
+
style: { background: activeColor }
|
|
5483
5461
|
}
|
|
5484
5462
|
),
|
|
5485
|
-
activeType === "smile" && /* @__PURE__ */ React__default.createElement(
|
|
5486
|
-
View,
|
|
5487
|
-
{
|
|
5488
|
-
className: `${classPrefix$k}-titles-item-smile`,
|
|
5489
|
-
style: tabsActiveStyle
|
|
5490
|
-
},
|
|
5491
|
-
/* @__PURE__ */ React__default.createElement(L$1, { color: activeColor })
|
|
5492
|
-
),
|
|
5463
|
+
activeType === "smile" && /* @__PURE__ */ React__default.createElement(View, { className: `${classPrefix$k}-titles-item-smile` }, /* @__PURE__ */ React__default.createElement(L$1, { color: activeColor })),
|
|
5493
5464
|
/* @__PURE__ */ React__default.createElement(
|
|
5494
5465
|
View,
|
|
5495
5466
|
{
|
|
5496
5467
|
className: classNames(
|
|
5497
|
-
|
|
5468
|
+
{
|
|
5469
|
+
[`${classPrefix$k}-ellipsis`]: direction === "vertical"
|
|
5470
|
+
},
|
|
5498
5471
|
`${classPrefix$k}-titles-item-text`
|
|
5499
|
-
)
|
|
5472
|
+
),
|
|
5473
|
+
style: { color: activeColor }
|
|
5500
5474
|
},
|
|
5501
5475
|
item.title
|
|
5502
5476
|
)
|
|
5503
5477
|
);
|
|
5504
5478
|
}))
|
|
5505
5479
|
), /* @__PURE__ */ React__default.createElement(View, { className: `${classPrefix$k}-content-wrap` }, /* @__PURE__ */ React__default.createElement(View, { className: `${classPrefix$k}-content`, style: getContentStyle() }, React__default.Children.map(children, (child, idx) => {
|
|
5506
|
-
if (!React__default.isValidElement(child))
|
|
5507
|
-
|
|
5508
|
-
}
|
|
5509
|
-
let childProps = {
|
|
5480
|
+
if (!React__default.isValidElement(child)) return null;
|
|
5481
|
+
return React__default.cloneElement(child, {
|
|
5510
5482
|
...child.props,
|
|
5511
|
-
active: value === child.props.value
|
|
5512
|
-
|
|
5513
|
-
|
|
5514
|
-
childProps = {
|
|
5515
|
-
...childProps,
|
|
5516
|
-
autoHeightClassName: "inactive"
|
|
5517
|
-
};
|
|
5518
|
-
}
|
|
5519
|
-
return React__default.cloneElement(child, childProps);
|
|
5483
|
+
active: value === child.props.value,
|
|
5484
|
+
autoHeightClassName: autoHeight && String(value) !== String(child.props.value || idx) ? "inactive" : void 0
|
|
5485
|
+
});
|
|
5520
5486
|
}))));
|
|
5521
5487
|
};
|
|
5522
5488
|
Tabs.displayName = "NutTabs";
|
|
@@ -8701,6 +8667,14 @@ const DatePicker = (props) => {
|
|
|
8701
8667
|
Number(formatDate[2]),
|
|
8702
8668
|
getMonthEndDay(Number(formatDate[0]), Number(formatDate[1]))
|
|
8703
8669
|
);
|
|
8670
|
+
if (selectedOptions.length >= 2 && ["date", "datehour", "datetime", "month-day"].includes(rangeType)) {
|
|
8671
|
+
const dayOption = formatOption("day", day);
|
|
8672
|
+
if (rangeType === "month-day") {
|
|
8673
|
+
selectedOptions[1] = dayOption;
|
|
8674
|
+
} else {
|
|
8675
|
+
selectedOptions[2] = dayOption;
|
|
8676
|
+
}
|
|
8677
|
+
}
|
|
8704
8678
|
let date4 = null;
|
|
8705
8679
|
if (rangeType === "date" || rangeType === "month-day" || rangeType === "year-month") {
|
|
8706
8680
|
date4 = new Date(year, month, day);
|
|
@@ -9614,7 +9588,7 @@ function newMessages() {
|
|
|
9614
9588
|
pattern: {
|
|
9615
9589
|
mismatch: "%s value %s does not match pattern %s"
|
|
9616
9590
|
},
|
|
9617
|
-
clone: function
|
|
9591
|
+
clone: function clone2() {
|
|
9618
9592
|
var cloned = JSON.parse(JSON.stringify(this));
|
|
9619
9593
|
cloned.clone = this.clone;
|
|
9620
9594
|
return cloned;
|
|
@@ -9878,23 +9852,55 @@ Schema.register = function register(type4, validator) {
|
|
|
9878
9852
|
Schema.warning = warning;
|
|
9879
9853
|
Schema.messages = messages;
|
|
9880
9854
|
Schema.validators = validators;
|
|
9881
|
-
function merge(...
|
|
9882
|
-
|
|
9883
|
-
|
|
9884
|
-
|
|
9885
|
-
|
|
9886
|
-
|
|
9887
|
-
|
|
9888
|
-
|
|
9889
|
-
|
|
9890
|
-
|
|
9891
|
-
|
|
9892
|
-
|
|
9893
|
-
|
|
9894
|
-
|
|
9855
|
+
function merge(...items) {
|
|
9856
|
+
return _merge(items[0] === true, false, items);
|
|
9857
|
+
}
|
|
9858
|
+
function recursive(...items) {
|
|
9859
|
+
return _merge(items[0] === true, true, items);
|
|
9860
|
+
}
|
|
9861
|
+
function clone(input) {
|
|
9862
|
+
if (Array.isArray(input)) {
|
|
9863
|
+
const output = [];
|
|
9864
|
+
for (let index = 0; index < input.length; ++index)
|
|
9865
|
+
output.push(clone(input[index]));
|
|
9866
|
+
return output;
|
|
9867
|
+
}
|
|
9868
|
+
if (isPlainObject(input)) {
|
|
9869
|
+
const output = {};
|
|
9870
|
+
for (const index in input) output[index] = clone(input[index]);
|
|
9871
|
+
return output;
|
|
9872
|
+
}
|
|
9873
|
+
return input;
|
|
9874
|
+
}
|
|
9875
|
+
function isPlainObject(input) {
|
|
9876
|
+
if (input === null || typeof input !== "object") return false;
|
|
9877
|
+
if (Object.getPrototypeOf(input) === null) return true;
|
|
9878
|
+
let ref = input;
|
|
9879
|
+
while (Object.getPrototypeOf(ref) !== null) ref = Object.getPrototypeOf(ref);
|
|
9880
|
+
return Object.getPrototypeOf(input) === ref;
|
|
9881
|
+
}
|
|
9882
|
+
function _recursiveMerge(base, extend) {
|
|
9883
|
+
if (!isPlainObject(base) || !isPlainObject(extend)) return extend;
|
|
9884
|
+
for (const key in extend) {
|
|
9885
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype")
|
|
9886
|
+
continue;
|
|
9887
|
+
base[key] = isPlainObject(base[key]) && isPlainObject(extend[key]) ? _recursiveMerge(base[key], extend[key]) : extend[key];
|
|
9888
|
+
}
|
|
9889
|
+
return base;
|
|
9890
|
+
}
|
|
9891
|
+
function _merge(isClone, isRecursive, items) {
|
|
9892
|
+
let result;
|
|
9893
|
+
if (isClone || !isPlainObject(result = items.shift())) result = {};
|
|
9894
|
+
for (let index = 0; index < items.length; ++index) {
|
|
9895
|
+
const item = items[index];
|
|
9896
|
+
if (!isPlainObject(item)) continue;
|
|
9897
|
+
for (const key in item) {
|
|
9898
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype")
|
|
9899
|
+
continue;
|
|
9900
|
+
const value = isClone ? clone(item[key]) : item[key];
|
|
9901
|
+
result[key] = isRecursive ? _recursiveMerge(result[key], value) : value;
|
|
9895
9902
|
}
|
|
9896
9903
|
}
|
|
9897
|
-
objects.filter((obj) => !!obj).forEach((obj) => mergeHelper(obj));
|
|
9898
9904
|
return result;
|
|
9899
9905
|
}
|
|
9900
9906
|
const SECRET = "NUT_FORM_INTERNAL";
|
|
@@ -9910,9 +9916,6 @@ class FormStore {
|
|
|
9910
9916
|
this.fieldEntities.push(field);
|
|
9911
9917
|
return () => {
|
|
9912
9918
|
this.fieldEntities = this.fieldEntities.filter((item) => item !== field);
|
|
9913
|
-
if (this.store) {
|
|
9914
|
-
delete this.store[field.props.name];
|
|
9915
|
-
}
|
|
9916
9919
|
};
|
|
9917
9920
|
};
|
|
9918
9921
|
this.getFieldValue = (name) => {
|
|
@@ -9934,10 +9937,11 @@ class FormStore {
|
|
|
9934
9937
|
if (init) {
|
|
9935
9938
|
const nextStore = merge(initialValues, this.store);
|
|
9936
9939
|
this.updateStore(nextStore);
|
|
9940
|
+
this.notifyWatch();
|
|
9937
9941
|
}
|
|
9938
9942
|
};
|
|
9939
9943
|
this.setFieldsValue = (newStore) => {
|
|
9940
|
-
const nextStore =
|
|
9944
|
+
const nextStore = recursive(true, this.store, newStore);
|
|
9941
9945
|
this.updateStore(nextStore);
|
|
9942
9946
|
this.fieldEntities.forEach((entity) => {
|
|
9943
9947
|
const { name } = entity.props;
|
|
@@ -9956,12 +9960,14 @@ class FormStore {
|
|
|
9956
9960
|
item.entity.onStoreChange("update");
|
|
9957
9961
|
}
|
|
9958
9962
|
});
|
|
9963
|
+
this.notifyWatch();
|
|
9959
9964
|
};
|
|
9960
9965
|
this.setFieldValue = (name, value) => {
|
|
9961
9966
|
const store = {
|
|
9962
9967
|
[name]: value
|
|
9963
9968
|
};
|
|
9964
9969
|
this.setFieldsValue(store);
|
|
9970
|
+
this.notifyWatch([name]);
|
|
9965
9971
|
};
|
|
9966
9972
|
this.setCallback = (callback) => {
|
|
9967
9973
|
this.callbacks = {
|
|
@@ -10004,7 +10010,6 @@ class FormStore {
|
|
|
10004
10010
|
};
|
|
10005
10011
|
this.validateFields = async (nameList) => {
|
|
10006
10012
|
let filterEntities = [];
|
|
10007
|
-
this.errors.length = 0;
|
|
10008
10013
|
if (!nameList || nameList.length === 0) {
|
|
10009
10014
|
filterEntities = this.fieldEntities;
|
|
10010
10015
|
} else {
|
|
@@ -10029,13 +10034,29 @@ class FormStore {
|
|
|
10029
10034
|
(_d = (_c = this.callbacks).onFinishFailed) == null ? void 0 : _d.call(_c, this.store, errors);
|
|
10030
10035
|
}
|
|
10031
10036
|
};
|
|
10032
|
-
this.resetFields = () => {
|
|
10033
|
-
|
|
10034
|
-
|
|
10035
|
-
|
|
10036
|
-
|
|
10037
|
-
|
|
10038
|
-
|
|
10037
|
+
this.resetFields = (namePaths) => {
|
|
10038
|
+
if (namePaths && namePaths.length) {
|
|
10039
|
+
namePaths.forEach((path) => {
|
|
10040
|
+
this.errors[path] = null;
|
|
10041
|
+
this.fieldEntities.forEach((entity) => {
|
|
10042
|
+
const name = entity.props.name;
|
|
10043
|
+
if (name === path) {
|
|
10044
|
+
if (path in this.initialValues) {
|
|
10045
|
+
this.updateStore({ [path]: this.initialValues[path] });
|
|
10046
|
+
} else {
|
|
10047
|
+
delete this.store[path];
|
|
10048
|
+
}
|
|
10049
|
+
entity.onStoreChange("reset");
|
|
10050
|
+
}
|
|
10051
|
+
});
|
|
10052
|
+
});
|
|
10053
|
+
} else {
|
|
10054
|
+
const nextStore = merge({}, this.initialValues);
|
|
10055
|
+
this.updateStore(nextStore);
|
|
10056
|
+
this.fieldEntities.forEach((entity) => {
|
|
10057
|
+
entity.onStoreChange("reset");
|
|
10058
|
+
});
|
|
10059
|
+
}
|
|
10039
10060
|
};
|
|
10040
10061
|
this.registerUpdate = (field, shouldUpdate) => {
|
|
10041
10062
|
this.updateList.push({
|
|
@@ -10058,7 +10079,8 @@ class FormStore {
|
|
|
10058
10079
|
dispatch: this.dispatch,
|
|
10059
10080
|
store: this.store,
|
|
10060
10081
|
fieldEntities: this.fieldEntities,
|
|
10061
|
-
registerUpdate: this.registerUpdate
|
|
10082
|
+
registerUpdate: this.registerUpdate,
|
|
10083
|
+
registerWatch: this.registerWatch
|
|
10062
10084
|
};
|
|
10063
10085
|
}
|
|
10064
10086
|
};
|
|
@@ -10075,6 +10097,26 @@ class FormStore {
|
|
|
10075
10097
|
getInternal: this.getInternal
|
|
10076
10098
|
};
|
|
10077
10099
|
};
|
|
10100
|
+
this.watchList = [];
|
|
10101
|
+
this.registerWatch = (callback) => {
|
|
10102
|
+
this.watchList.push(callback);
|
|
10103
|
+
return () => {
|
|
10104
|
+
this.watchList = this.watchList.filter((fn) => fn !== callback);
|
|
10105
|
+
};
|
|
10106
|
+
};
|
|
10107
|
+
this.notifyWatch = (namePath = []) => {
|
|
10108
|
+
if (this.watchList.length) {
|
|
10109
|
+
let allValues;
|
|
10110
|
+
if (!namePath || namePath.length === 0) {
|
|
10111
|
+
allValues = this.getFieldsValue(true);
|
|
10112
|
+
} else {
|
|
10113
|
+
allValues = this.getFieldsValue(namePath);
|
|
10114
|
+
}
|
|
10115
|
+
this.watchList.forEach((callback) => {
|
|
10116
|
+
callback(allValues, namePath);
|
|
10117
|
+
});
|
|
10118
|
+
}
|
|
10119
|
+
};
|
|
10078
10120
|
this.callbacks = {
|
|
10079
10121
|
onFinish: () => {
|
|
10080
10122
|
},
|
|
@@ -10098,6 +10140,24 @@ const useForm = (form) => {
|
|
|
10098
10140
|
}
|
|
10099
10141
|
return [formRef.current];
|
|
10100
10142
|
};
|
|
10143
|
+
const useWatch = (path, form) => {
|
|
10144
|
+
const formInstance = form.getInternal(SECRET);
|
|
10145
|
+
const [value, setValue] = useState();
|
|
10146
|
+
useEffect(() => {
|
|
10147
|
+
const unsubscribe = formInstance.registerWatch(
|
|
10148
|
+
(data, namePath) => {
|
|
10149
|
+
const value2 = data[path];
|
|
10150
|
+
setValue(value2);
|
|
10151
|
+
}
|
|
10152
|
+
);
|
|
10153
|
+
const initialValue = form.getFieldsValue(true);
|
|
10154
|
+
if (value !== initialValue[path]) {
|
|
10155
|
+
setValue(initialValue[path]);
|
|
10156
|
+
}
|
|
10157
|
+
return () => unsubscribe();
|
|
10158
|
+
}, [form]);
|
|
10159
|
+
return value;
|
|
10160
|
+
};
|
|
10101
10161
|
const defaultProps$Y = {
|
|
10102
10162
|
...ComponentDefaults,
|
|
10103
10163
|
labelPosition: "right",
|
|
@@ -10403,6 +10463,7 @@ let FormItem = _FormItem;
|
|
|
10403
10463
|
const InnerForm = Form;
|
|
10404
10464
|
InnerForm.Item = FormItem;
|
|
10405
10465
|
InnerForm.useForm = useForm;
|
|
10466
|
+
InnerForm.useWatch = useWatch;
|
|
10406
10467
|
function trimExtraChar(value, char, regExp) {
|
|
10407
10468
|
const index = value.indexOf(char);
|
|
10408
10469
|
if (index === -1) {
|
|
@@ -13953,7 +14014,7 @@ const Empty = (props) => {
|
|
|
13953
14014
|
const imageNode = typeof imageUrl === "string" ? /* @__PURE__ */ React__default.createElement("img", { className: "img", src: imageUrl, alt: "empty" }) : imageUrl;
|
|
13954
14015
|
useEffect(() => {
|
|
13955
14016
|
setImgStyle(() => {
|
|
13956
|
-
if (
|
|
14017
|
+
if (typeof imageSize !== "number" && typeof imageSize !== "string") {
|
|
13957
14018
|
return {};
|
|
13958
14019
|
}
|
|
13959
14020
|
if (typeof imageSize === "number") {
|