@nutui/nutui-react-taro 2.7.5 → 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 +32 -9
- 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/Cell/style/style.css +1 -1
- package/dist/esm/CellGroup/style/style.css +1 -1
- package/dist/esm/DatePicker.js +1 -1
- package/dist/esm/Empty.js +1 -1
- package/dist/esm/Form/style/style.css +1 -1
- package/dist/esm/Form.js +2 -1
- package/dist/esm/FormItem/style/style.css +1 -1
- package/dist/esm/FormItem.js +1 -1
- package/dist/esm/Swiper.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-C8CsajMW.js → address.taro-Ck0ZmxRg.js} +1 -1
- package/dist/esm/{cascader.taro-DRE3asjI.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-CY1VxgF-.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 +162 -101
- package/dist/nutui.react.umd.js +162 -101
- package/dist/packages/cellgroup/cellgroup.scss +1 -1
- package/dist/packages/formitem/formitem.scss +18 -1
- package/dist/packages/tabs/tabs.scss +72 -115
- package/dist/style.css +1 -1
- package/dist/styles/variables-jmapp.scss +1 -0
- 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,
|
|
@@ -5447,75 +5429,60 @@ const Tabs = (props) => {
|
|
|
5447
5429
|
scrollY: direction === "vertical",
|
|
5448
5430
|
scrollLeft,
|
|
5449
5431
|
scrollTop,
|
|
5432
|
+
enhanced: true,
|
|
5450
5433
|
showScrollbar: false,
|
|
5451
5434
|
scrollWithAnimation: rtl && Taro.getEnv() !== "WEB" ? false : scrollWithAnimation.current,
|
|
5452
5435
|
id: `nut-tabs-titles-${name || uuid}`,
|
|
5453
5436
|
className: classesTitle,
|
|
5454
|
-
style:
|
|
5437
|
+
style: tabStyle
|
|
5455
5438
|
},
|
|
5456
|
-
/* @__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) => {
|
|
5457
5440
|
return /* @__PURE__ */ React__default.createElement(
|
|
5458
5441
|
View,
|
|
5459
5442
|
{
|
|
5443
|
+
key: item.value,
|
|
5460
5444
|
ref: (ref) => titleItemsRef.current.push(ref),
|
|
5461
5445
|
id: `scrollIntoView${index}`,
|
|
5462
|
-
onClick: (
|
|
5463
|
-
tabChange(item);
|
|
5464
|
-
},
|
|
5446
|
+
onClick: () => tabChange(item),
|
|
5465
5447
|
className: classNames(`${classPrefix$k}-titles-item`, {
|
|
5466
5448
|
[`nut-tabs-titles-item-active`]: !item.disabled && String(item.value) === String(value),
|
|
5467
5449
|
[`nut-tabs-titles-item-disabled`]: item.disabled,
|
|
5468
5450
|
[`nut-tabs-titles-item-${align}`]: align
|
|
5469
|
-
})
|
|
5470
|
-
key: item.value
|
|
5451
|
+
})
|
|
5471
5452
|
},
|
|
5472
5453
|
activeType === "line" && /* @__PURE__ */ React__default.createElement(
|
|
5473
5454
|
View,
|
|
5474
5455
|
{
|
|
5475
5456
|
className: classNames(
|
|
5476
5457
|
`${classPrefix$k}-titles-item-line`,
|
|
5477
|
-
{
|
|
5478
|
-
[`${classPrefix$k}-titles-item-line-${direction}`]: true
|
|
5479
|
-
}
|
|
5458
|
+
`${classPrefix$k}-titles-item-line-${direction}`
|
|
5480
5459
|
),
|
|
5481
|
-
style:
|
|
5460
|
+
style: { background: activeColor }
|
|
5482
5461
|
}
|
|
5483
5462
|
),
|
|
5484
|
-
activeType === "smile" && /* @__PURE__ */ React__default.createElement(
|
|
5485
|
-
View,
|
|
5486
|
-
{
|
|
5487
|
-
className: `${classPrefix$k}-titles-item-smile`,
|
|
5488
|
-
style: tabsActiveStyle
|
|
5489
|
-
},
|
|
5490
|
-
/* @__PURE__ */ React__default.createElement(L$1, { color: activeColor })
|
|
5491
|
-
),
|
|
5463
|
+
activeType === "smile" && /* @__PURE__ */ React__default.createElement(View, { className: `${classPrefix$k}-titles-item-smile` }, /* @__PURE__ */ React__default.createElement(L$1, { color: activeColor })),
|
|
5492
5464
|
/* @__PURE__ */ React__default.createElement(
|
|
5493
5465
|
View,
|
|
5494
5466
|
{
|
|
5495
5467
|
className: classNames(
|
|
5496
|
-
|
|
5468
|
+
{
|
|
5469
|
+
[`${classPrefix$k}-ellipsis`]: direction === "vertical"
|
|
5470
|
+
},
|
|
5497
5471
|
`${classPrefix$k}-titles-item-text`
|
|
5498
|
-
)
|
|
5472
|
+
),
|
|
5473
|
+
style: { color: activeColor }
|
|
5499
5474
|
},
|
|
5500
5475
|
item.title
|
|
5501
5476
|
)
|
|
5502
5477
|
);
|
|
5503
5478
|
}))
|
|
5504
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) => {
|
|
5505
|
-
if (!React__default.isValidElement(child))
|
|
5506
|
-
|
|
5507
|
-
}
|
|
5508
|
-
let childProps = {
|
|
5480
|
+
if (!React__default.isValidElement(child)) return null;
|
|
5481
|
+
return React__default.cloneElement(child, {
|
|
5509
5482
|
...child.props,
|
|
5510
|
-
active: value === child.props.value
|
|
5511
|
-
|
|
5512
|
-
|
|
5513
|
-
childProps = {
|
|
5514
|
-
...childProps,
|
|
5515
|
-
autoHeightClassName: "inactive"
|
|
5516
|
-
};
|
|
5517
|
-
}
|
|
5518
|
-
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
|
+
});
|
|
5519
5486
|
}))));
|
|
5520
5487
|
};
|
|
5521
5488
|
Tabs.displayName = "NutTabs";
|
|
@@ -8700,6 +8667,14 @@ const DatePicker = (props) => {
|
|
|
8700
8667
|
Number(formatDate[2]),
|
|
8701
8668
|
getMonthEndDay(Number(formatDate[0]), Number(formatDate[1]))
|
|
8702
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
|
+
}
|
|
8703
8678
|
let date4 = null;
|
|
8704
8679
|
if (rangeType === "date" || rangeType === "month-day" || rangeType === "year-month") {
|
|
8705
8680
|
date4 = new Date(year, month, day);
|
|
@@ -9613,7 +9588,7 @@ function newMessages() {
|
|
|
9613
9588
|
pattern: {
|
|
9614
9589
|
mismatch: "%s value %s does not match pattern %s"
|
|
9615
9590
|
},
|
|
9616
|
-
clone: function
|
|
9591
|
+
clone: function clone2() {
|
|
9617
9592
|
var cloned = JSON.parse(JSON.stringify(this));
|
|
9618
9593
|
cloned.clone = this.clone;
|
|
9619
9594
|
return cloned;
|
|
@@ -9877,23 +9852,55 @@ Schema.register = function register(type4, validator) {
|
|
|
9877
9852
|
Schema.warning = warning;
|
|
9878
9853
|
Schema.messages = messages;
|
|
9879
9854
|
Schema.validators = validators;
|
|
9880
|
-
function merge(...
|
|
9881
|
-
|
|
9882
|
-
|
|
9883
|
-
|
|
9884
|
-
|
|
9885
|
-
|
|
9886
|
-
|
|
9887
|
-
|
|
9888
|
-
|
|
9889
|
-
|
|
9890
|
-
|
|
9891
|
-
|
|
9892
|
-
|
|
9893
|
-
|
|
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;
|
|
9894
9902
|
}
|
|
9895
9903
|
}
|
|
9896
|
-
objects.filter((obj) => !!obj).forEach((obj) => mergeHelper(obj));
|
|
9897
9904
|
return result;
|
|
9898
9905
|
}
|
|
9899
9906
|
const SECRET = "NUT_FORM_INTERNAL";
|
|
@@ -9909,9 +9916,6 @@ class FormStore {
|
|
|
9909
9916
|
this.fieldEntities.push(field);
|
|
9910
9917
|
return () => {
|
|
9911
9918
|
this.fieldEntities = this.fieldEntities.filter((item) => item !== field);
|
|
9912
|
-
if (this.store) {
|
|
9913
|
-
delete this.store[field.props.name];
|
|
9914
|
-
}
|
|
9915
9919
|
};
|
|
9916
9920
|
};
|
|
9917
9921
|
this.getFieldValue = (name) => {
|
|
@@ -9933,10 +9937,11 @@ class FormStore {
|
|
|
9933
9937
|
if (init) {
|
|
9934
9938
|
const nextStore = merge(initialValues, this.store);
|
|
9935
9939
|
this.updateStore(nextStore);
|
|
9940
|
+
this.notifyWatch();
|
|
9936
9941
|
}
|
|
9937
9942
|
};
|
|
9938
9943
|
this.setFieldsValue = (newStore) => {
|
|
9939
|
-
const nextStore =
|
|
9944
|
+
const nextStore = recursive(true, this.store, newStore);
|
|
9940
9945
|
this.updateStore(nextStore);
|
|
9941
9946
|
this.fieldEntities.forEach((entity) => {
|
|
9942
9947
|
const { name } = entity.props;
|
|
@@ -9955,12 +9960,14 @@ class FormStore {
|
|
|
9955
9960
|
item.entity.onStoreChange("update");
|
|
9956
9961
|
}
|
|
9957
9962
|
});
|
|
9963
|
+
this.notifyWatch();
|
|
9958
9964
|
};
|
|
9959
9965
|
this.setFieldValue = (name, value) => {
|
|
9960
9966
|
const store = {
|
|
9961
9967
|
[name]: value
|
|
9962
9968
|
};
|
|
9963
9969
|
this.setFieldsValue(store);
|
|
9970
|
+
this.notifyWatch([name]);
|
|
9964
9971
|
};
|
|
9965
9972
|
this.setCallback = (callback) => {
|
|
9966
9973
|
this.callbacks = {
|
|
@@ -10003,7 +10010,6 @@ class FormStore {
|
|
|
10003
10010
|
};
|
|
10004
10011
|
this.validateFields = async (nameList) => {
|
|
10005
10012
|
let filterEntities = [];
|
|
10006
|
-
this.errors.length = 0;
|
|
10007
10013
|
if (!nameList || nameList.length === 0) {
|
|
10008
10014
|
filterEntities = this.fieldEntities;
|
|
10009
10015
|
} else {
|
|
@@ -10028,13 +10034,29 @@ class FormStore {
|
|
|
10028
10034
|
(_d = (_c = this.callbacks).onFinishFailed) == null ? void 0 : _d.call(_c, this.store, errors);
|
|
10029
10035
|
}
|
|
10030
10036
|
};
|
|
10031
|
-
this.resetFields = () => {
|
|
10032
|
-
|
|
10033
|
-
|
|
10034
|
-
|
|
10035
|
-
|
|
10036
|
-
|
|
10037
|
-
|
|
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
|
+
}
|
|
10038
10060
|
};
|
|
10039
10061
|
this.registerUpdate = (field, shouldUpdate) => {
|
|
10040
10062
|
this.updateList.push({
|
|
@@ -10057,7 +10079,8 @@ class FormStore {
|
|
|
10057
10079
|
dispatch: this.dispatch,
|
|
10058
10080
|
store: this.store,
|
|
10059
10081
|
fieldEntities: this.fieldEntities,
|
|
10060
|
-
registerUpdate: this.registerUpdate
|
|
10082
|
+
registerUpdate: this.registerUpdate,
|
|
10083
|
+
registerWatch: this.registerWatch
|
|
10061
10084
|
};
|
|
10062
10085
|
}
|
|
10063
10086
|
};
|
|
@@ -10074,6 +10097,26 @@ class FormStore {
|
|
|
10074
10097
|
getInternal: this.getInternal
|
|
10075
10098
|
};
|
|
10076
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
|
+
};
|
|
10077
10120
|
this.callbacks = {
|
|
10078
10121
|
onFinish: () => {
|
|
10079
10122
|
},
|
|
@@ -10097,6 +10140,24 @@ const useForm = (form) => {
|
|
|
10097
10140
|
}
|
|
10098
10141
|
return [formRef.current];
|
|
10099
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
|
+
};
|
|
10100
10161
|
const defaultProps$Y = {
|
|
10101
10162
|
...ComponentDefaults,
|
|
10102
10163
|
labelPosition: "right",
|
|
@@ -10402,6 +10463,7 @@ let FormItem = _FormItem;
|
|
|
10402
10463
|
const InnerForm = Form;
|
|
10403
10464
|
InnerForm.Item = FormItem;
|
|
10404
10465
|
InnerForm.useForm = useForm;
|
|
10466
|
+
InnerForm.useWatch = useWatch;
|
|
10405
10467
|
function trimExtraChar(value, char, regExp) {
|
|
10406
10468
|
const index = value.indexOf(char);
|
|
10407
10469
|
if (index === -1) {
|
|
@@ -13952,7 +14014,7 @@ const Empty = (props) => {
|
|
|
13952
14014
|
const imageNode = typeof imageUrl === "string" ? /* @__PURE__ */ React__default.createElement("img", { className: "img", src: imageUrl, alt: "empty" }) : imageUrl;
|
|
13953
14015
|
useEffect(() => {
|
|
13954
14016
|
setImgStyle(() => {
|
|
13955
|
-
if (
|
|
14017
|
+
if (typeof imageSize !== "number" && typeof imageSize !== "string") {
|
|
13956
14018
|
return {};
|
|
13957
14019
|
}
|
|
13958
14020
|
if (typeof imageSize === "number") {
|
|
@@ -16964,7 +17026,6 @@ const Swiper = forwardRef((props, ref) => {
|
|
|
16964
17026
|
indicator,
|
|
16965
17027
|
loop,
|
|
16966
17028
|
autoPlay,
|
|
16967
|
-
duration,
|
|
16968
17029
|
direction,
|
|
16969
17030
|
defaultValue,
|
|
16970
17031
|
onChange,
|