@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.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
|
|
5
|
+
* @nutui/nutui-react v2.7.7 Fri Jan 24 2025 13:57:13 GMT+0800 (China Standard Time)
|
|
6
6
|
* (c) 2023 @jdf2e.
|
|
7
7
|
* Released under the MIT License.
|
|
8
8
|
*/
|
|
@@ -3938,7 +3938,7 @@
|
|
|
3938
3938
|
}));
|
|
3939
3939
|
};
|
|
3940
3940
|
Space.displayName = "NutSpace";
|
|
3941
|
-
function useWatch(dep, callback, config2 = { immediate: false }) {
|
|
3941
|
+
function useWatch$1(dep, callback, config2 = { immediate: false }) {
|
|
3942
3942
|
const { immediate } = config2;
|
|
3943
3943
|
const prev = React.useRef();
|
|
3944
3944
|
const inited = React.useRef(false);
|
|
@@ -4074,7 +4074,7 @@
|
|
|
4074
4074
|
const [rootRect, setRootRect] = React.useState({});
|
|
4075
4075
|
const [fixed, setFixed] = React.useState(false);
|
|
4076
4076
|
const [transform, setTransform] = React.useState(0);
|
|
4077
|
-
useWatch(fixed, () => {
|
|
4077
|
+
useWatch$1(fixed, () => {
|
|
4078
4078
|
onChange && onChange(fixed);
|
|
4079
4079
|
});
|
|
4080
4080
|
const rootStyle = React.useMemo(() => {
|
|
@@ -5269,7 +5269,7 @@
|
|
|
5269
5269
|
autoHeightClassName,
|
|
5270
5270
|
className
|
|
5271
5271
|
);
|
|
5272
|
-
return children
|
|
5272
|
+
return children && /* @__PURE__ */ React.createElement(components.View, { className: classes }, !disabled && children);
|
|
5273
5273
|
};
|
|
5274
5274
|
const inBrowser = typeof window !== "undefined";
|
|
5275
5275
|
function requestAniFrame() {
|
|
@@ -5313,24 +5313,19 @@
|
|
|
5313
5313
|
value: outerValue,
|
|
5314
5314
|
defaultValue: outerDefaultValue,
|
|
5315
5315
|
...rest
|
|
5316
|
-
} = {
|
|
5317
|
-
...defaultProps$18,
|
|
5318
|
-
...props
|
|
5319
|
-
};
|
|
5316
|
+
} = { ...defaultProps$18, ...props };
|
|
5320
5317
|
const uuid = useUuid();
|
|
5321
5318
|
const [value, setValue] = usePropsValue({
|
|
5322
5319
|
value: outerValue,
|
|
5323
5320
|
defaultValue: outerDefaultValue,
|
|
5324
|
-
finalValue: 0,
|
|
5325
5321
|
onChange
|
|
5326
5322
|
});
|
|
5327
5323
|
const titleItemsRef = React.useRef([]);
|
|
5328
|
-
const navRef = React.useRef(null);
|
|
5329
5324
|
const getTitles = () => {
|
|
5330
5325
|
const titles2 = [];
|
|
5331
5326
|
React.Children.forEach(children, (child, idx) => {
|
|
5332
5327
|
if (React.isValidElement(child)) {
|
|
5333
|
-
const
|
|
5328
|
+
const { props: props2 } = child;
|
|
5334
5329
|
if ((props2 == null ? void 0 : props2.title) || (props2 == null ? void 0 : props2.value)) {
|
|
5335
5330
|
titles2.push({
|
|
5336
5331
|
title: props2.title,
|
|
@@ -5365,13 +5360,8 @@
|
|
|
5365
5360
|
);
|
|
5366
5361
|
const classesTitle = classNames(`${classPrefix$k}-titles`, {
|
|
5367
5362
|
[`${classPrefix$k}-titles-${activeType}`]: activeType,
|
|
5368
|
-
[`${classPrefix$k}-titles-scrollable`]: true,
|
|
5369
5363
|
[`${classPrefix$k}-titles-${align}`]: align
|
|
5370
5364
|
});
|
|
5371
|
-
const tabsActiveStyle = {
|
|
5372
|
-
color: activeType === "smile" ? activeColor : "",
|
|
5373
|
-
background: activeType === "line" ? activeColor : ""
|
|
5374
|
-
};
|
|
5375
5365
|
const getRect2 = (selector) => {
|
|
5376
5366
|
return new Promise((resolve) => {
|
|
5377
5367
|
Taro.createSelectorQuery().select(selector).boundingClientRect().exec((rect = []) => {
|
|
@@ -5387,22 +5377,15 @@
|
|
|
5387
5377
|
});
|
|
5388
5378
|
};
|
|
5389
5379
|
const scrollWithAnimation = React.useRef(false);
|
|
5390
|
-
const navRectRef = React.useRef();
|
|
5391
|
-
const titleRectRef = React.useRef([]);
|
|
5392
5380
|
const [scrollLeft, setScrollLeft] = React.useState(0);
|
|
5393
5381
|
const [scrollTop, setScrollTop] = React.useState(0);
|
|
5394
5382
|
const scrollDirection = (to, direction2) => {
|
|
5395
5383
|
let count = 0;
|
|
5396
5384
|
const frames = 1;
|
|
5397
5385
|
function animate() {
|
|
5398
|
-
if (direction2 === "horizontal")
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
setScrollTop(to);
|
|
5402
|
-
}
|
|
5403
|
-
if (++count < frames) {
|
|
5404
|
-
requestAniFrame$1(animate);
|
|
5405
|
-
}
|
|
5386
|
+
if (direction2 === "horizontal") setScrollLeft(to);
|
|
5387
|
+
else setScrollTop(to);
|
|
5388
|
+
if (++count < frames) requestAniFrame$1(animate);
|
|
5406
5389
|
}
|
|
5407
5390
|
animate();
|
|
5408
5391
|
};
|
|
@@ -5412,17 +5395,17 @@
|
|
|
5412
5395
|
getRect2(`#nut-tabs-titles-${name || uuid} .nut-tabs-list`),
|
|
5413
5396
|
getAllRect(`#nut-tabs-titles-${name || uuid} .nut-tabs-titles-item`)
|
|
5414
5397
|
]).then(([navRect, titleRects]) => {
|
|
5415
|
-
|
|
5416
|
-
titleRectRef.current = titleRects;
|
|
5417
|
-
const titleRect = titleRectRef.current[index];
|
|
5398
|
+
const titleRect = titleRects[index];
|
|
5418
5399
|
if (!titleRect) return;
|
|
5419
5400
|
let to = 0;
|
|
5420
5401
|
if (direction === "vertical") {
|
|
5421
5402
|
const top = titleRects.slice(0, index).reduce((prev, curr) => prev + curr.height, 0);
|
|
5422
|
-
to = top - (
|
|
5403
|
+
to = top - (navRect.height - titleRect.height) / 2;
|
|
5423
5404
|
} else {
|
|
5424
5405
|
const left2 = titleRects.slice(0, index).reduce((prev, curr) => prev + curr.width, 0);
|
|
5425
|
-
to =
|
|
5406
|
+
to = left2 - (navRect.width - titleRect.width) / 2;
|
|
5407
|
+
if (to < 0) return;
|
|
5408
|
+
to = rtl ? -to : to;
|
|
5426
5409
|
}
|
|
5427
5410
|
Taro.nextTick(() => {
|
|
5428
5411
|
scrollWithAnimation.current = true;
|
|
@@ -5437,7 +5420,7 @@
|
|
|
5437
5420
|
);
|
|
5438
5421
|
index = index < 0 ? 0 : index;
|
|
5439
5422
|
return {
|
|
5440
|
-
transform: direction === "horizontal" ? `translate3d(${rtl ? "" : "-"}${index * 100}%, 0, 0)` : `translate3d( 0
|
|
5423
|
+
transform: direction === "horizontal" ? `translate3d(${rtl ? "" : "-"}${index * 100}%, 0, 0)` : `translate3d( 0, -${index * 100}%, 0)`,
|
|
5441
5424
|
transitionDuration: `${duration}ms`
|
|
5442
5425
|
};
|
|
5443
5426
|
};
|
|
@@ -5448,12 +5431,11 @@
|
|
|
5448
5431
|
index = index < 0 ? 0 : index;
|
|
5449
5432
|
scrollIntoView(index);
|
|
5450
5433
|
}, [value]);
|
|
5451
|
-
const tabChange = (item
|
|
5434
|
+
const tabChange = (item) => {
|
|
5452
5435
|
onClick && onClick(item.value);
|
|
5453
|
-
if (item.disabled) {
|
|
5454
|
-
|
|
5436
|
+
if (!item.disabled) {
|
|
5437
|
+
setValue(item.value);
|
|
5455
5438
|
}
|
|
5456
|
-
setValue(item.value);
|
|
5457
5439
|
};
|
|
5458
5440
|
return /* @__PURE__ */ React.createElement(components.View, { className: classes, ...rest }, /* @__PURE__ */ React.createElement(
|
|
5459
5441
|
components.ScrollView,
|
|
@@ -5463,75 +5445,60 @@
|
|
|
5463
5445
|
scrollY: direction === "vertical",
|
|
5464
5446
|
scrollLeft,
|
|
5465
5447
|
scrollTop,
|
|
5448
|
+
enhanced: true,
|
|
5466
5449
|
showScrollbar: false,
|
|
5467
5450
|
scrollWithAnimation: rtl && Taro.getEnv() !== "WEB" ? false : scrollWithAnimation.current,
|
|
5468
5451
|
id: `nut-tabs-titles-${name || uuid}`,
|
|
5469
5452
|
className: classesTitle,
|
|
5470
|
-
style:
|
|
5453
|
+
style: tabStyle
|
|
5471
5454
|
},
|
|
5472
|
-
/* @__PURE__ */ React.createElement(components.View, { className: "nut-tabs-list"
|
|
5455
|
+
/* @__PURE__ */ React.createElement(components.View, { className: "nut-tabs-list" }, !!title && typeof title === "function" ? title() : titles.current.map((item, index) => {
|
|
5473
5456
|
return /* @__PURE__ */ React.createElement(
|
|
5474
5457
|
components.View,
|
|
5475
5458
|
{
|
|
5459
|
+
key: item.value,
|
|
5476
5460
|
ref: (ref) => titleItemsRef.current.push(ref),
|
|
5477
5461
|
id: `scrollIntoView${index}`,
|
|
5478
|
-
onClick: (
|
|
5479
|
-
tabChange(item);
|
|
5480
|
-
},
|
|
5462
|
+
onClick: () => tabChange(item),
|
|
5481
5463
|
className: classNames(`${classPrefix$k}-titles-item`, {
|
|
5482
5464
|
[`nut-tabs-titles-item-active`]: !item.disabled && String(item.value) === String(value),
|
|
5483
5465
|
[`nut-tabs-titles-item-disabled`]: item.disabled,
|
|
5484
5466
|
[`nut-tabs-titles-item-${align}`]: align
|
|
5485
|
-
})
|
|
5486
|
-
key: item.value
|
|
5467
|
+
})
|
|
5487
5468
|
},
|
|
5488
5469
|
activeType === "line" && /* @__PURE__ */ React.createElement(
|
|
5489
5470
|
components.View,
|
|
5490
5471
|
{
|
|
5491
5472
|
className: classNames(
|
|
5492
5473
|
`${classPrefix$k}-titles-item-line`,
|
|
5493
|
-
{
|
|
5494
|
-
[`${classPrefix$k}-titles-item-line-${direction}`]: true
|
|
5495
|
-
}
|
|
5474
|
+
`${classPrefix$k}-titles-item-line-${direction}`
|
|
5496
5475
|
),
|
|
5497
|
-
style:
|
|
5476
|
+
style: { background: activeColor }
|
|
5498
5477
|
}
|
|
5499
5478
|
),
|
|
5500
|
-
activeType === "smile" && /* @__PURE__ */ React.createElement(
|
|
5501
|
-
components.View,
|
|
5502
|
-
{
|
|
5503
|
-
className: `${classPrefix$k}-titles-item-smile`,
|
|
5504
|
-
style: tabsActiveStyle
|
|
5505
|
-
},
|
|
5506
|
-
/* @__PURE__ */ React.createElement(L$1, { color: activeColor })
|
|
5507
|
-
),
|
|
5479
|
+
activeType === "smile" && /* @__PURE__ */ React.createElement(components.View, { className: `${classPrefix$k}-titles-item-smile` }, /* @__PURE__ */ React.createElement(L$1, { color: activeColor })),
|
|
5508
5480
|
/* @__PURE__ */ React.createElement(
|
|
5509
5481
|
components.View,
|
|
5510
5482
|
{
|
|
5511
5483
|
className: classNames(
|
|
5512
|
-
|
|
5484
|
+
{
|
|
5485
|
+
[`${classPrefix$k}-ellipsis`]: direction === "vertical"
|
|
5486
|
+
},
|
|
5513
5487
|
`${classPrefix$k}-titles-item-text`
|
|
5514
|
-
)
|
|
5488
|
+
),
|
|
5489
|
+
style: { color: activeColor }
|
|
5515
5490
|
},
|
|
5516
5491
|
item.title
|
|
5517
5492
|
)
|
|
5518
5493
|
);
|
|
5519
5494
|
}))
|
|
5520
5495
|
), /* @__PURE__ */ React.createElement(components.View, { className: `${classPrefix$k}-content-wrap` }, /* @__PURE__ */ React.createElement(components.View, { className: `${classPrefix$k}-content`, style: getContentStyle() }, React.Children.map(children, (child, idx) => {
|
|
5521
|
-
if (!React.isValidElement(child))
|
|
5522
|
-
|
|
5523
|
-
}
|
|
5524
|
-
let childProps = {
|
|
5496
|
+
if (!React.isValidElement(child)) return null;
|
|
5497
|
+
return React.cloneElement(child, {
|
|
5525
5498
|
...child.props,
|
|
5526
|
-
active: value === child.props.value
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
childProps = {
|
|
5530
|
-
...childProps,
|
|
5531
|
-
autoHeightClassName: "inactive"
|
|
5532
|
-
};
|
|
5533
|
-
}
|
|
5534
|
-
return React.cloneElement(child, childProps);
|
|
5499
|
+
active: value === child.props.value,
|
|
5500
|
+
autoHeightClassName: autoHeight && String(value) !== String(child.props.value || idx) ? "inactive" : void 0
|
|
5501
|
+
});
|
|
5535
5502
|
}))));
|
|
5536
5503
|
};
|
|
5537
5504
|
Tabs.displayName = "NutTabs";
|
|
@@ -8716,6 +8683,14 @@
|
|
|
8716
8683
|
Number(formatDate[2]),
|
|
8717
8684
|
getMonthEndDay(Number(formatDate[0]), Number(formatDate[1]))
|
|
8718
8685
|
);
|
|
8686
|
+
if (selectedOptions.length >= 2 && ["date", "datehour", "datetime", "month-day"].includes(rangeType)) {
|
|
8687
|
+
const dayOption = formatOption("day", day);
|
|
8688
|
+
if (rangeType === "month-day") {
|
|
8689
|
+
selectedOptions[1] = dayOption;
|
|
8690
|
+
} else {
|
|
8691
|
+
selectedOptions[2] = dayOption;
|
|
8692
|
+
}
|
|
8693
|
+
}
|
|
8719
8694
|
let date2 = null;
|
|
8720
8695
|
if (rangeType === "date" || rangeType === "month-day" || rangeType === "year-month") {
|
|
8721
8696
|
date2 = new Date(year, month, day);
|
|
@@ -9629,7 +9604,7 @@
|
|
|
9629
9604
|
pattern: {
|
|
9630
9605
|
mismatch: "%s value %s does not match pattern %s"
|
|
9631
9606
|
},
|
|
9632
|
-
clone: function
|
|
9607
|
+
clone: function clone2() {
|
|
9633
9608
|
var cloned = JSON.parse(JSON.stringify(this));
|
|
9634
9609
|
cloned.clone = this.clone;
|
|
9635
9610
|
return cloned;
|
|
@@ -9893,23 +9868,55 @@
|
|
|
9893
9868
|
Schema.warning = warning;
|
|
9894
9869
|
Schema.messages = messages;
|
|
9895
9870
|
Schema.validators = validators;
|
|
9896
|
-
function merge(...
|
|
9897
|
-
|
|
9898
|
-
|
|
9899
|
-
|
|
9900
|
-
|
|
9901
|
-
|
|
9902
|
-
|
|
9903
|
-
|
|
9904
|
-
|
|
9905
|
-
|
|
9906
|
-
|
|
9907
|
-
|
|
9908
|
-
|
|
9909
|
-
|
|
9871
|
+
function merge(...items) {
|
|
9872
|
+
return _merge(items[0] === true, false, items);
|
|
9873
|
+
}
|
|
9874
|
+
function recursive(...items) {
|
|
9875
|
+
return _merge(items[0] === true, true, items);
|
|
9876
|
+
}
|
|
9877
|
+
function clone(input) {
|
|
9878
|
+
if (Array.isArray(input)) {
|
|
9879
|
+
const output = [];
|
|
9880
|
+
for (let index = 0; index < input.length; ++index)
|
|
9881
|
+
output.push(clone(input[index]));
|
|
9882
|
+
return output;
|
|
9883
|
+
}
|
|
9884
|
+
if (isPlainObject(input)) {
|
|
9885
|
+
const output = {};
|
|
9886
|
+
for (const index in input) output[index] = clone(input[index]);
|
|
9887
|
+
return output;
|
|
9888
|
+
}
|
|
9889
|
+
return input;
|
|
9890
|
+
}
|
|
9891
|
+
function isPlainObject(input) {
|
|
9892
|
+
if (input === null || typeof input !== "object") return false;
|
|
9893
|
+
if (Object.getPrototypeOf(input) === null) return true;
|
|
9894
|
+
let ref = input;
|
|
9895
|
+
while (Object.getPrototypeOf(ref) !== null) ref = Object.getPrototypeOf(ref);
|
|
9896
|
+
return Object.getPrototypeOf(input) === ref;
|
|
9897
|
+
}
|
|
9898
|
+
function _recursiveMerge(base, extend) {
|
|
9899
|
+
if (!isPlainObject(base) || !isPlainObject(extend)) return extend;
|
|
9900
|
+
for (const key in extend) {
|
|
9901
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype")
|
|
9902
|
+
continue;
|
|
9903
|
+
base[key] = isPlainObject(base[key]) && isPlainObject(extend[key]) ? _recursiveMerge(base[key], extend[key]) : extend[key];
|
|
9904
|
+
}
|
|
9905
|
+
return base;
|
|
9906
|
+
}
|
|
9907
|
+
function _merge(isClone, isRecursive, items) {
|
|
9908
|
+
let result;
|
|
9909
|
+
if (isClone || !isPlainObject(result = items.shift())) result = {};
|
|
9910
|
+
for (let index = 0; index < items.length; ++index) {
|
|
9911
|
+
const item = items[index];
|
|
9912
|
+
if (!isPlainObject(item)) continue;
|
|
9913
|
+
for (const key in item) {
|
|
9914
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype")
|
|
9915
|
+
continue;
|
|
9916
|
+
const value = isClone ? clone(item[key]) : item[key];
|
|
9917
|
+
result[key] = isRecursive ? _recursiveMerge(result[key], value) : value;
|
|
9910
9918
|
}
|
|
9911
9919
|
}
|
|
9912
|
-
objects.filter((obj) => !!obj).forEach((obj) => mergeHelper(obj));
|
|
9913
9920
|
return result;
|
|
9914
9921
|
}
|
|
9915
9922
|
const SECRET = "NUT_FORM_INTERNAL";
|
|
@@ -9925,9 +9932,6 @@
|
|
|
9925
9932
|
this.fieldEntities.push(field);
|
|
9926
9933
|
return () => {
|
|
9927
9934
|
this.fieldEntities = this.fieldEntities.filter((item) => item !== field);
|
|
9928
|
-
if (this.store) {
|
|
9929
|
-
delete this.store[field.props.name];
|
|
9930
|
-
}
|
|
9931
9935
|
};
|
|
9932
9936
|
};
|
|
9933
9937
|
this.getFieldValue = (name) => {
|
|
@@ -9949,10 +9953,11 @@
|
|
|
9949
9953
|
if (init) {
|
|
9950
9954
|
const nextStore = merge(initialValues, this.store);
|
|
9951
9955
|
this.updateStore(nextStore);
|
|
9956
|
+
this.notifyWatch();
|
|
9952
9957
|
}
|
|
9953
9958
|
};
|
|
9954
9959
|
this.setFieldsValue = (newStore) => {
|
|
9955
|
-
const nextStore =
|
|
9960
|
+
const nextStore = recursive(true, this.store, newStore);
|
|
9956
9961
|
this.updateStore(nextStore);
|
|
9957
9962
|
this.fieldEntities.forEach((entity) => {
|
|
9958
9963
|
const { name } = entity.props;
|
|
@@ -9971,12 +9976,14 @@
|
|
|
9971
9976
|
item.entity.onStoreChange("update");
|
|
9972
9977
|
}
|
|
9973
9978
|
});
|
|
9979
|
+
this.notifyWatch();
|
|
9974
9980
|
};
|
|
9975
9981
|
this.setFieldValue = (name, value) => {
|
|
9976
9982
|
const store = {
|
|
9977
9983
|
[name]: value
|
|
9978
9984
|
};
|
|
9979
9985
|
this.setFieldsValue(store);
|
|
9986
|
+
this.notifyWatch([name]);
|
|
9980
9987
|
};
|
|
9981
9988
|
this.setCallback = (callback) => {
|
|
9982
9989
|
this.callbacks = {
|
|
@@ -10019,7 +10026,6 @@
|
|
|
10019
10026
|
};
|
|
10020
10027
|
this.validateFields = async (nameList) => {
|
|
10021
10028
|
let filterEntities = [];
|
|
10022
|
-
this.errors.length = 0;
|
|
10023
10029
|
if (!nameList || nameList.length === 0) {
|
|
10024
10030
|
filterEntities = this.fieldEntities;
|
|
10025
10031
|
} else {
|
|
@@ -10044,13 +10050,29 @@
|
|
|
10044
10050
|
(_d = (_c = this.callbacks).onFinishFailed) == null ? void 0 : _d.call(_c, this.store, errors);
|
|
10045
10051
|
}
|
|
10046
10052
|
};
|
|
10047
|
-
this.resetFields = () => {
|
|
10048
|
-
|
|
10049
|
-
|
|
10050
|
-
|
|
10051
|
-
|
|
10052
|
-
|
|
10053
|
-
|
|
10053
|
+
this.resetFields = (namePaths) => {
|
|
10054
|
+
if (namePaths && namePaths.length) {
|
|
10055
|
+
namePaths.forEach((path) => {
|
|
10056
|
+
this.errors[path] = null;
|
|
10057
|
+
this.fieldEntities.forEach((entity) => {
|
|
10058
|
+
const name = entity.props.name;
|
|
10059
|
+
if (name === path) {
|
|
10060
|
+
if (path in this.initialValues) {
|
|
10061
|
+
this.updateStore({ [path]: this.initialValues[path] });
|
|
10062
|
+
} else {
|
|
10063
|
+
delete this.store[path];
|
|
10064
|
+
}
|
|
10065
|
+
entity.onStoreChange("reset");
|
|
10066
|
+
}
|
|
10067
|
+
});
|
|
10068
|
+
});
|
|
10069
|
+
} else {
|
|
10070
|
+
const nextStore = merge({}, this.initialValues);
|
|
10071
|
+
this.updateStore(nextStore);
|
|
10072
|
+
this.fieldEntities.forEach((entity) => {
|
|
10073
|
+
entity.onStoreChange("reset");
|
|
10074
|
+
});
|
|
10075
|
+
}
|
|
10054
10076
|
};
|
|
10055
10077
|
this.registerUpdate = (field, shouldUpdate) => {
|
|
10056
10078
|
this.updateList.push({
|
|
@@ -10073,7 +10095,8 @@
|
|
|
10073
10095
|
dispatch: this.dispatch,
|
|
10074
10096
|
store: this.store,
|
|
10075
10097
|
fieldEntities: this.fieldEntities,
|
|
10076
|
-
registerUpdate: this.registerUpdate
|
|
10098
|
+
registerUpdate: this.registerUpdate,
|
|
10099
|
+
registerWatch: this.registerWatch
|
|
10077
10100
|
};
|
|
10078
10101
|
}
|
|
10079
10102
|
};
|
|
@@ -10090,6 +10113,26 @@
|
|
|
10090
10113
|
getInternal: this.getInternal
|
|
10091
10114
|
};
|
|
10092
10115
|
};
|
|
10116
|
+
this.watchList = [];
|
|
10117
|
+
this.registerWatch = (callback) => {
|
|
10118
|
+
this.watchList.push(callback);
|
|
10119
|
+
return () => {
|
|
10120
|
+
this.watchList = this.watchList.filter((fn) => fn !== callback);
|
|
10121
|
+
};
|
|
10122
|
+
};
|
|
10123
|
+
this.notifyWatch = (namePath = []) => {
|
|
10124
|
+
if (this.watchList.length) {
|
|
10125
|
+
let allValues;
|
|
10126
|
+
if (!namePath || namePath.length === 0) {
|
|
10127
|
+
allValues = this.getFieldsValue(true);
|
|
10128
|
+
} else {
|
|
10129
|
+
allValues = this.getFieldsValue(namePath);
|
|
10130
|
+
}
|
|
10131
|
+
this.watchList.forEach((callback) => {
|
|
10132
|
+
callback(allValues, namePath);
|
|
10133
|
+
});
|
|
10134
|
+
}
|
|
10135
|
+
};
|
|
10093
10136
|
this.callbacks = {
|
|
10094
10137
|
onFinish: () => {
|
|
10095
10138
|
},
|
|
@@ -10113,6 +10156,24 @@
|
|
|
10113
10156
|
}
|
|
10114
10157
|
return [formRef.current];
|
|
10115
10158
|
};
|
|
10159
|
+
const useWatch = (path, form) => {
|
|
10160
|
+
const formInstance = form.getInternal(SECRET);
|
|
10161
|
+
const [value, setValue] = React.useState();
|
|
10162
|
+
React.useEffect(() => {
|
|
10163
|
+
const unsubscribe = formInstance.registerWatch(
|
|
10164
|
+
(data, namePath) => {
|
|
10165
|
+
const value2 = data[path];
|
|
10166
|
+
setValue(value2);
|
|
10167
|
+
}
|
|
10168
|
+
);
|
|
10169
|
+
const initialValue = form.getFieldsValue(true);
|
|
10170
|
+
if (value !== initialValue[path]) {
|
|
10171
|
+
setValue(initialValue[path]);
|
|
10172
|
+
}
|
|
10173
|
+
return () => unsubscribe();
|
|
10174
|
+
}, [form]);
|
|
10175
|
+
return value;
|
|
10176
|
+
};
|
|
10116
10177
|
const defaultProps$Y = {
|
|
10117
10178
|
...ComponentDefaults,
|
|
10118
10179
|
labelPosition: "right",
|
|
@@ -10418,6 +10479,7 @@
|
|
|
10418
10479
|
const InnerForm = Form;
|
|
10419
10480
|
InnerForm.Item = FormItem;
|
|
10420
10481
|
InnerForm.useForm = useForm;
|
|
10482
|
+
InnerForm.useWatch = useWatch;
|
|
10421
10483
|
function trimExtraChar(value, char, regExp) {
|
|
10422
10484
|
const index = value.indexOf(char);
|
|
10423
10485
|
if (index === -1) {
|
|
@@ -13968,7 +14030,7 @@
|
|
|
13968
14030
|
const imageNode = typeof imageUrl === "string" ? /* @__PURE__ */ React.createElement("img", { className: "img", src: imageUrl, alt: "empty" }) : imageUrl;
|
|
13969
14031
|
React.useEffect(() => {
|
|
13970
14032
|
setImgStyle(() => {
|
|
13971
|
-
if (
|
|
14033
|
+
if (typeof imageSize !== "number" && typeof imageSize !== "string") {
|
|
13972
14034
|
return {};
|
|
13973
14035
|
}
|
|
13974
14036
|
if (typeof imageSize === "number") {
|
|
@@ -16980,7 +17042,6 @@
|
|
|
16980
17042
|
indicator,
|
|
16981
17043
|
loop,
|
|
16982
17044
|
autoPlay,
|
|
16983
|
-
duration,
|
|
16984
17045
|
direction,
|
|
16985
17046
|
defaultValue,
|
|
16986
17047
|
onChange,
|
|
@@ -25,11 +25,12 @@
|
|
|
25
25
|
position: absolute;
|
|
26
26
|
left: -0.8em;
|
|
27
27
|
}
|
|
28
|
+
|
|
28
29
|
.nut-form-item-labeltxt {
|
|
29
30
|
font-size: $form-item-label-font-size;
|
|
30
|
-
height: 10px;
|
|
31
31
|
position: relative;
|
|
32
32
|
}
|
|
33
|
+
|
|
33
34
|
&-body {
|
|
34
35
|
flex: 1;
|
|
35
36
|
display: flex;
|
|
@@ -60,6 +61,7 @@
|
|
|
60
61
|
|
|
61
62
|
.nut-textarea {
|
|
62
63
|
padding: 0;
|
|
64
|
+
|
|
63
65
|
.nut-textarea-textarea {
|
|
64
66
|
font: inherit;
|
|
65
67
|
text-align: $form-item-body-input-text-align;
|
|
@@ -75,6 +77,16 @@
|
|
|
75
77
|
}
|
|
76
78
|
}
|
|
77
79
|
|
|
80
|
+
.nut-form {
|
|
81
|
+
.nut-cell-group {
|
|
82
|
+
.nut-cell-group-wrap-divider {
|
|
83
|
+
.nut-cell-divider {
|
|
84
|
+
border-top: $cell-divider-border-bottom;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
78
90
|
[dir='rtl'] .nut-form-item,
|
|
79
91
|
.nut-rtl .nut-form-item {
|
|
80
92
|
&-label {
|
|
@@ -89,21 +101,26 @@
|
|
|
89
101
|
}
|
|
90
102
|
}
|
|
91
103
|
}
|
|
104
|
+
|
|
92
105
|
&-body {
|
|
93
106
|
&-slots {
|
|
94
107
|
text-align: right;
|
|
108
|
+
|
|
95
109
|
.nut-icon-ArrowRight,
|
|
96
110
|
.nut-icon-ArrowLeft {
|
|
97
111
|
transform: rotateY(180deg);
|
|
98
112
|
}
|
|
113
|
+
|
|
99
114
|
.nut-input-text {
|
|
100
115
|
text-align: right;
|
|
101
116
|
}
|
|
117
|
+
|
|
102
118
|
.nut-textarea-textarea {
|
|
103
119
|
text-align: right;
|
|
104
120
|
}
|
|
105
121
|
}
|
|
106
122
|
}
|
|
123
|
+
|
|
107
124
|
&-tips {
|
|
108
125
|
text-align: right;
|
|
109
126
|
}
|