@nutui/nutui-react 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/Cascader/style/style.css +1 -1
- package/dist/esm/DatePicker.js +8 -0
- package/dist/esm/Empty.js +1 -1
- package/dist/esm/Form.js +2 -1
- package/dist/esm/TabPane.js +1 -1
- package/dist/esm/Tabs/style/style.css +1 -1
- package/dist/esm/formitem2.js +121 -31
- package/dist/esm/tabs2.js +26 -42
- 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 +167 -100
- package/dist/nutui.react.umd.js +167 -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 v2.7.
|
|
2
|
+
* @nutui/nutui-react v2.7.7 Fri Jan 24 2025 13:55:36 GMT+0800 (China Standard Time)
|
|
3
3
|
* (c) 2023 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -3153,7 +3153,7 @@ const getRect = (elementRef) => {
|
|
|
3153
3153
|
height: 0
|
|
3154
3154
|
};
|
|
3155
3155
|
};
|
|
3156
|
-
function useWatch(dep, callback, config2 = { immediate: false }) {
|
|
3156
|
+
function useWatch$1(dep, callback, config2 = { immediate: false }) {
|
|
3157
3157
|
const { immediate } = config2;
|
|
3158
3158
|
const prev = useRef();
|
|
3159
3159
|
const inited = useRef(false);
|
|
@@ -3283,7 +3283,7 @@ const Sticky = (props) => {
|
|
|
3283
3283
|
});
|
|
3284
3284
|
setIsFixed(fixed.fixed);
|
|
3285
3285
|
}, [position, threshold, container]);
|
|
3286
|
-
useWatch(isFixed, () => {
|
|
3286
|
+
useWatch$1(isFixed, () => {
|
|
3287
3287
|
onChange && onChange(isFixed);
|
|
3288
3288
|
});
|
|
3289
3289
|
useEffect(() => {
|
|
@@ -9204,7 +9204,7 @@ const TabPane = (props) => {
|
|
|
9204
9204
|
autoHeightClassName,
|
|
9205
9205
|
className
|
|
9206
9206
|
);
|
|
9207
|
-
return children
|
|
9207
|
+
return children && /* @__PURE__ */ React__default.createElement("div", { className: classes }, !disabled && children);
|
|
9208
9208
|
};
|
|
9209
9209
|
const defaultProps$17 = {
|
|
9210
9210
|
...ComponentDefaults,
|
|
@@ -9234,39 +9234,30 @@ const Tabs = (props) => {
|
|
|
9234
9234
|
value: outerValue,
|
|
9235
9235
|
defaultValue: outerDefaultValue,
|
|
9236
9236
|
...rest
|
|
9237
|
-
} = {
|
|
9238
|
-
...defaultProps$17,
|
|
9239
|
-
...props
|
|
9240
|
-
};
|
|
9237
|
+
} = { ...defaultProps$17, ...props };
|
|
9241
9238
|
const [value, setValue] = usePropsValue({
|
|
9242
9239
|
value: outerValue,
|
|
9243
9240
|
defaultValue: outerDefaultValue,
|
|
9244
|
-
finalValue: 0,
|
|
9245
9241
|
onChange
|
|
9246
9242
|
});
|
|
9247
9243
|
const titleItemsRef = useRef([]);
|
|
9248
9244
|
const navRef = useRef(null);
|
|
9249
|
-
const scrollDirection = (nav, to2, duration2
|
|
9250
|
-
|
|
9251
|
-
const from = direction2 === "horizontal" ? nav.scrollLeft : nav.scrollTop;
|
|
9245
|
+
const scrollDirection = (nav, to2, duration2) => {
|
|
9246
|
+
const from = direction === "horizontal" ? nav.scrollLeft : nav.scrollTop;
|
|
9252
9247
|
const frames = Math.round(duration2 * 1e3 / 16);
|
|
9253
|
-
|
|
9254
|
-
|
|
9255
|
-
|
|
9256
|
-
|
|
9257
|
-
|
|
9258
|
-
|
|
9259
|
-
if (++count < frames) {
|
|
9260
|
-
requestAniFrame$1(animate);
|
|
9261
|
-
}
|
|
9262
|
-
}
|
|
9248
|
+
let count = 0;
|
|
9249
|
+
const animate = () => {
|
|
9250
|
+
if (direction === "horizontal") nav.scrollLeft += (to2 - from) / frames;
|
|
9251
|
+
else nav.scrollTop += (to2 - from) / frames;
|
|
9252
|
+
if (++count < frames) requestAniFrame$1(animate);
|
|
9253
|
+
};
|
|
9263
9254
|
animate();
|
|
9264
9255
|
};
|
|
9265
9256
|
const scrollIntoView = (index, immediate) => {
|
|
9266
9257
|
const nav = navRef.current;
|
|
9267
9258
|
const titleItem = titleItemsRef.current;
|
|
9268
9259
|
const titlesLength = titles.current.length;
|
|
9269
|
-
const itemLength =
|
|
9260
|
+
const itemLength = titleItem.length;
|
|
9270
9261
|
if (!nav || !titleItem || !titleItem[itemLength - titlesLength + index]) {
|
|
9271
9262
|
return;
|
|
9272
9263
|
}
|
|
@@ -9278,13 +9269,13 @@ const Tabs = (props) => {
|
|
|
9278
9269
|
} else {
|
|
9279
9270
|
to2 = title2.offsetLeft - (nav.offsetWidth - title2.offsetWidth) / 2;
|
|
9280
9271
|
}
|
|
9281
|
-
scrollDirection(nav, to2, 0.3
|
|
9272
|
+
scrollDirection(nav, to2, 0.3);
|
|
9282
9273
|
};
|
|
9283
9274
|
const getTitles = () => {
|
|
9284
9275
|
const titles2 = [];
|
|
9285
9276
|
React__default.Children.forEach(children, (child, idx) => {
|
|
9286
9277
|
if (React__default.isValidElement(child)) {
|
|
9287
|
-
const
|
|
9278
|
+
const { props: props2 } = child;
|
|
9288
9279
|
if ((props2 == null ? void 0 : props2.title) || (props2 == null ? void 0 : props2.value)) {
|
|
9289
9280
|
titles2.push({
|
|
9290
9281
|
title: props2.title,
|
|
@@ -9319,23 +9310,18 @@ const Tabs = (props) => {
|
|
|
9319
9310
|
);
|
|
9320
9311
|
const classesTitle = classNames(`${classPrefix$j}-titles`, {
|
|
9321
9312
|
[`${classPrefix$j}-titles-${activeType}`]: activeType,
|
|
9322
|
-
[`${classPrefix$j}-titles-scrollable`]: true,
|
|
9323
9313
|
[`${classPrefix$j}-titles-${align}`]: align
|
|
9324
9314
|
});
|
|
9325
|
-
const tabsActiveStyle = {
|
|
9326
|
-
color: activeType === "smile" ? activeColor : "",
|
|
9327
|
-
background: activeType === "line" ? activeColor : ""
|
|
9328
|
-
};
|
|
9329
9315
|
const getContentStyle = () => {
|
|
9330
|
-
let index = titles.current.findIndex((t) => t.value
|
|
9316
|
+
let index = titles.current.findIndex((t) => t.value === value);
|
|
9331
9317
|
index = index < 0 ? 0 : index;
|
|
9332
9318
|
return {
|
|
9333
|
-
transform: direction === "horizontal" ? `translate3d(${rtl ? "" : "-"}${index * 100}%, 0, 0)` : `translate3d( 0
|
|
9319
|
+
transform: direction === "horizontal" ? `translate3d(${rtl ? "" : "-"}${index * 100}%, 0, 0)` : `translate3d( 0, -${index * 100}%, 0)`,
|
|
9334
9320
|
transitionDuration: `${duration}ms`
|
|
9335
9321
|
};
|
|
9336
9322
|
};
|
|
9337
9323
|
useEffect(() => {
|
|
9338
|
-
let index = titles.current.findIndex((t) => t.value
|
|
9324
|
+
let index = titles.current.findIndex((t) => t.value === value);
|
|
9339
9325
|
index = index < 0 ? 0 : index;
|
|
9340
9326
|
setTimeout(() => {
|
|
9341
9327
|
scrollIntoView(index);
|
|
@@ -9343,69 +9329,55 @@ const Tabs = (props) => {
|
|
|
9343
9329
|
}, [value]);
|
|
9344
9330
|
const tabChange = (item) => {
|
|
9345
9331
|
onClick && onClick(item.value);
|
|
9346
|
-
if (item.disabled) {
|
|
9347
|
-
|
|
9332
|
+
if (!item.disabled) {
|
|
9333
|
+
setValue(item.value);
|
|
9348
9334
|
}
|
|
9349
|
-
setValue(item.value);
|
|
9350
9335
|
};
|
|
9351
|
-
return /* @__PURE__ */ React__default.createElement("div", { className: classes, ...rest }, /* @__PURE__ */ React__default.createElement("div", { className: classesTitle, style:
|
|
9336
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: classes, ...rest }, /* @__PURE__ */ React__default.createElement("div", { className: classesTitle, style: tabStyle, ref: navRef }, !!title && typeof title === "function" ? title() : titles.current.map((item) => {
|
|
9352
9337
|
return /* @__PURE__ */ React__default.createElement(
|
|
9353
9338
|
"div",
|
|
9354
9339
|
{
|
|
9355
|
-
|
|
9356
|
-
|
|
9357
|
-
|
|
9340
|
+
key: item.value,
|
|
9341
|
+
ref: (ref) => titleItemsRef.current.push(ref),
|
|
9342
|
+
onClick: () => tabChange(item),
|
|
9358
9343
|
className: classNames(`${classPrefix$j}-titles-item`, {
|
|
9359
9344
|
[`nut-tabs-titles-item-active`]: !item.disabled && String(item.value) === String(value),
|
|
9360
9345
|
[`nut-tabs-titles-item-disabled`]: item.disabled,
|
|
9361
9346
|
[`nut-tabs-titles-item-${align}`]: align
|
|
9362
|
-
})
|
|
9363
|
-
ref: (ref) => titleItemsRef.current.push(ref),
|
|
9364
|
-
key: item.value
|
|
9347
|
+
})
|
|
9365
9348
|
},
|
|
9366
9349
|
activeType === "line" && /* @__PURE__ */ React__default.createElement(
|
|
9367
9350
|
"div",
|
|
9368
9351
|
{
|
|
9369
|
-
className: classNames(
|
|
9370
|
-
|
|
9371
|
-
|
|
9372
|
-
|
|
9352
|
+
className: classNames(
|
|
9353
|
+
`${classPrefix$j}-titles-item-line`,
|
|
9354
|
+
`${classPrefix$j}-titles-item-line-${direction}`
|
|
9355
|
+
),
|
|
9356
|
+
style: { background: activeColor }
|
|
9373
9357
|
}
|
|
9374
9358
|
),
|
|
9375
|
-
activeType === "smile" && /* @__PURE__ */ React__default.createElement(
|
|
9376
|
-
"div",
|
|
9377
|
-
{
|
|
9378
|
-
className: `${classPrefix$j}-titles-item-smile`,
|
|
9379
|
-
style: tabsActiveStyle
|
|
9380
|
-
},
|
|
9381
|
-
/* @__PURE__ */ React__default.createElement(c$3, { color: activeColor, width: 40, height: 20 })
|
|
9382
|
-
),
|
|
9359
|
+
activeType === "smile" && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix$j}-titles-item-smile` }, /* @__PURE__ */ React__default.createElement(c$3, { color: activeColor, width: 40, height: 20 })),
|
|
9383
9360
|
/* @__PURE__ */ React__default.createElement(
|
|
9384
9361
|
"div",
|
|
9385
9362
|
{
|
|
9386
9363
|
className: classNames(
|
|
9387
|
-
|
|
9364
|
+
{
|
|
9365
|
+
[`${classPrefix$j}-ellipsis`]: direction === "vertical"
|
|
9366
|
+
},
|
|
9388
9367
|
`${classPrefix$j}-titles-item-text`
|
|
9389
|
-
)
|
|
9368
|
+
),
|
|
9369
|
+
style: { color: activeColor }
|
|
9390
9370
|
},
|
|
9391
9371
|
item.title
|
|
9392
9372
|
)
|
|
9393
9373
|
);
|
|
9394
9374
|
})), /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix$j}-content-wrap` }, /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix$j}-content`, style: getContentStyle() }, React__default.Children.map(children, (child, idx) => {
|
|
9395
|
-
if (!React__default.isValidElement(child))
|
|
9396
|
-
|
|
9397
|
-
}
|
|
9398
|
-
let childProps = {
|
|
9375
|
+
if (!React__default.isValidElement(child)) return null;
|
|
9376
|
+
return React__default.cloneElement(child, {
|
|
9399
9377
|
...child.props,
|
|
9400
|
-
active: value === child.props.value
|
|
9401
|
-
|
|
9402
|
-
|
|
9403
|
-
childProps = {
|
|
9404
|
-
...childProps,
|
|
9405
|
-
autoHeightClassName: "inactive"
|
|
9406
|
-
};
|
|
9407
|
-
}
|
|
9408
|
-
return React__default.cloneElement(child, childProps);
|
|
9378
|
+
active: value === child.props.value,
|
|
9379
|
+
autoHeightClassName: autoHeight && String(value) !== String(child.props.value || idx) ? "inactive" : void 0
|
|
9380
|
+
});
|
|
9409
9381
|
}))));
|
|
9410
9382
|
};
|
|
9411
9383
|
Tabs.displayName = "NutTabs";
|
|
@@ -12533,6 +12505,14 @@ const DatePicker = (props) => {
|
|
|
12533
12505
|
Number(formatDate[2]),
|
|
12534
12506
|
getMonthEndDay(Number(formatDate[0]), Number(formatDate[1]))
|
|
12535
12507
|
);
|
|
12508
|
+
if (selectedOptions.length >= 2 && ["date", "datehour", "datetime", "month-day"].includes(rangeType)) {
|
|
12509
|
+
const dayOption = formatOption("day", day);
|
|
12510
|
+
if (rangeType === "month-day") {
|
|
12511
|
+
selectedOptions[1] = dayOption;
|
|
12512
|
+
} else {
|
|
12513
|
+
selectedOptions[2] = dayOption;
|
|
12514
|
+
}
|
|
12515
|
+
}
|
|
12536
12516
|
let date4 = null;
|
|
12537
12517
|
if (rangeType === "date" || rangeType === "month-day" || rangeType === "year-month") {
|
|
12538
12518
|
date4 = new Date(year, month, day);
|
|
@@ -13437,7 +13417,7 @@ function newMessages() {
|
|
|
13437
13417
|
pattern: {
|
|
13438
13418
|
mismatch: "%s value %s does not match pattern %s"
|
|
13439
13419
|
},
|
|
13440
|
-
clone: function
|
|
13420
|
+
clone: function clone2() {
|
|
13441
13421
|
var cloned = JSON.parse(JSON.stringify(this));
|
|
13442
13422
|
cloned.clone = this.clone;
|
|
13443
13423
|
return cloned;
|
|
@@ -13701,23 +13681,55 @@ Schema.register = function register(type4, validator) {
|
|
|
13701
13681
|
Schema.warning = warning;
|
|
13702
13682
|
Schema.messages = messages;
|
|
13703
13683
|
Schema.validators = validators;
|
|
13704
|
-
function merge(...
|
|
13705
|
-
|
|
13706
|
-
|
|
13707
|
-
|
|
13708
|
-
|
|
13709
|
-
|
|
13710
|
-
|
|
13711
|
-
|
|
13712
|
-
|
|
13713
|
-
|
|
13714
|
-
|
|
13715
|
-
|
|
13716
|
-
|
|
13717
|
-
|
|
13684
|
+
function merge(...items) {
|
|
13685
|
+
return _merge(items[0] === true, false, items);
|
|
13686
|
+
}
|
|
13687
|
+
function recursive(...items) {
|
|
13688
|
+
return _merge(items[0] === true, true, items);
|
|
13689
|
+
}
|
|
13690
|
+
function clone(input) {
|
|
13691
|
+
if (Array.isArray(input)) {
|
|
13692
|
+
const output = [];
|
|
13693
|
+
for (let index = 0; index < input.length; ++index)
|
|
13694
|
+
output.push(clone(input[index]));
|
|
13695
|
+
return output;
|
|
13696
|
+
}
|
|
13697
|
+
if (isPlainObject(input)) {
|
|
13698
|
+
const output = {};
|
|
13699
|
+
for (const index in input) output[index] = clone(input[index]);
|
|
13700
|
+
return output;
|
|
13701
|
+
}
|
|
13702
|
+
return input;
|
|
13703
|
+
}
|
|
13704
|
+
function isPlainObject(input) {
|
|
13705
|
+
if (input === null || typeof input !== "object") return false;
|
|
13706
|
+
if (Object.getPrototypeOf(input) === null) return true;
|
|
13707
|
+
let ref = input;
|
|
13708
|
+
while (Object.getPrototypeOf(ref) !== null) ref = Object.getPrototypeOf(ref);
|
|
13709
|
+
return Object.getPrototypeOf(input) === ref;
|
|
13710
|
+
}
|
|
13711
|
+
function _recursiveMerge(base, extend) {
|
|
13712
|
+
if (!isPlainObject(base) || !isPlainObject(extend)) return extend;
|
|
13713
|
+
for (const key in extend) {
|
|
13714
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype")
|
|
13715
|
+
continue;
|
|
13716
|
+
base[key] = isPlainObject(base[key]) && isPlainObject(extend[key]) ? _recursiveMerge(base[key], extend[key]) : extend[key];
|
|
13717
|
+
}
|
|
13718
|
+
return base;
|
|
13719
|
+
}
|
|
13720
|
+
function _merge(isClone, isRecursive, items) {
|
|
13721
|
+
let result;
|
|
13722
|
+
if (isClone || !isPlainObject(result = items.shift())) result = {};
|
|
13723
|
+
for (let index = 0; index < items.length; ++index) {
|
|
13724
|
+
const item = items[index];
|
|
13725
|
+
if (!isPlainObject(item)) continue;
|
|
13726
|
+
for (const key in item) {
|
|
13727
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype")
|
|
13728
|
+
continue;
|
|
13729
|
+
const value = isClone ? clone(item[key]) : item[key];
|
|
13730
|
+
result[key] = isRecursive ? _recursiveMerge(result[key], value) : value;
|
|
13718
13731
|
}
|
|
13719
13732
|
}
|
|
13720
|
-
objects.filter((obj) => !!obj).forEach((obj) => mergeHelper(obj));
|
|
13721
13733
|
return result;
|
|
13722
13734
|
}
|
|
13723
13735
|
const SECRET = "NUT_FORM_INTERNAL";
|
|
@@ -13733,9 +13745,6 @@ class FormStore {
|
|
|
13733
13745
|
this.fieldEntities.push(field);
|
|
13734
13746
|
return () => {
|
|
13735
13747
|
this.fieldEntities = this.fieldEntities.filter((item) => item !== field);
|
|
13736
|
-
if (this.store) {
|
|
13737
|
-
delete this.store[field.props.name];
|
|
13738
|
-
}
|
|
13739
13748
|
};
|
|
13740
13749
|
};
|
|
13741
13750
|
this.getFieldValue = (name) => {
|
|
@@ -13757,10 +13766,11 @@ class FormStore {
|
|
|
13757
13766
|
if (init) {
|
|
13758
13767
|
const nextStore = merge(initialValues, this.store);
|
|
13759
13768
|
this.updateStore(nextStore);
|
|
13769
|
+
this.notifyWatch();
|
|
13760
13770
|
}
|
|
13761
13771
|
};
|
|
13762
13772
|
this.setFieldsValue = (newStore) => {
|
|
13763
|
-
const nextStore =
|
|
13773
|
+
const nextStore = recursive(true, this.store, newStore);
|
|
13764
13774
|
this.updateStore(nextStore);
|
|
13765
13775
|
this.fieldEntities.forEach((entity) => {
|
|
13766
13776
|
const { name } = entity.props;
|
|
@@ -13779,12 +13789,14 @@ class FormStore {
|
|
|
13779
13789
|
item.entity.onStoreChange("update");
|
|
13780
13790
|
}
|
|
13781
13791
|
});
|
|
13792
|
+
this.notifyWatch();
|
|
13782
13793
|
};
|
|
13783
13794
|
this.setFieldValue = (name, value) => {
|
|
13784
13795
|
const store = {
|
|
13785
13796
|
[name]: value
|
|
13786
13797
|
};
|
|
13787
13798
|
this.setFieldsValue(store);
|
|
13799
|
+
this.notifyWatch([name]);
|
|
13788
13800
|
};
|
|
13789
13801
|
this.setCallback = (callback) => {
|
|
13790
13802
|
this.callbacks = {
|
|
@@ -13827,7 +13839,6 @@ class FormStore {
|
|
|
13827
13839
|
};
|
|
13828
13840
|
this.validateFields = async (nameList) => {
|
|
13829
13841
|
let filterEntities = [];
|
|
13830
|
-
this.errors.length = 0;
|
|
13831
13842
|
if (!nameList || nameList.length === 0) {
|
|
13832
13843
|
filterEntities = this.fieldEntities;
|
|
13833
13844
|
} else {
|
|
@@ -13852,13 +13863,29 @@ class FormStore {
|
|
|
13852
13863
|
(_d = (_c = this.callbacks).onFinishFailed) == null ? void 0 : _d.call(_c, this.store, errors);
|
|
13853
13864
|
}
|
|
13854
13865
|
};
|
|
13855
|
-
this.resetFields = () => {
|
|
13856
|
-
|
|
13857
|
-
|
|
13858
|
-
|
|
13859
|
-
|
|
13860
|
-
|
|
13861
|
-
|
|
13866
|
+
this.resetFields = (namePaths) => {
|
|
13867
|
+
if (namePaths && namePaths.length) {
|
|
13868
|
+
namePaths.forEach((path) => {
|
|
13869
|
+
this.errors[path] = null;
|
|
13870
|
+
this.fieldEntities.forEach((entity) => {
|
|
13871
|
+
const name = entity.props.name;
|
|
13872
|
+
if (name === path) {
|
|
13873
|
+
if (path in this.initialValues) {
|
|
13874
|
+
this.updateStore({ [path]: this.initialValues[path] });
|
|
13875
|
+
} else {
|
|
13876
|
+
delete this.store[path];
|
|
13877
|
+
}
|
|
13878
|
+
entity.onStoreChange("reset");
|
|
13879
|
+
}
|
|
13880
|
+
});
|
|
13881
|
+
});
|
|
13882
|
+
} else {
|
|
13883
|
+
const nextStore = merge({}, this.initialValues);
|
|
13884
|
+
this.updateStore(nextStore);
|
|
13885
|
+
this.fieldEntities.forEach((entity) => {
|
|
13886
|
+
entity.onStoreChange("reset");
|
|
13887
|
+
});
|
|
13888
|
+
}
|
|
13862
13889
|
};
|
|
13863
13890
|
this.registerUpdate = (field, shouldUpdate) => {
|
|
13864
13891
|
this.updateList.push({
|
|
@@ -13881,7 +13908,8 @@ class FormStore {
|
|
|
13881
13908
|
dispatch: this.dispatch,
|
|
13882
13909
|
store: this.store,
|
|
13883
13910
|
fieldEntities: this.fieldEntities,
|
|
13884
|
-
registerUpdate: this.registerUpdate
|
|
13911
|
+
registerUpdate: this.registerUpdate,
|
|
13912
|
+
registerWatch: this.registerWatch
|
|
13885
13913
|
};
|
|
13886
13914
|
}
|
|
13887
13915
|
};
|
|
@@ -13898,6 +13926,26 @@ class FormStore {
|
|
|
13898
13926
|
getInternal: this.getInternal
|
|
13899
13927
|
};
|
|
13900
13928
|
};
|
|
13929
|
+
this.watchList = [];
|
|
13930
|
+
this.registerWatch = (callback) => {
|
|
13931
|
+
this.watchList.push(callback);
|
|
13932
|
+
return () => {
|
|
13933
|
+
this.watchList = this.watchList.filter((fn) => fn !== callback);
|
|
13934
|
+
};
|
|
13935
|
+
};
|
|
13936
|
+
this.notifyWatch = (namePath = []) => {
|
|
13937
|
+
if (this.watchList.length) {
|
|
13938
|
+
let allValues;
|
|
13939
|
+
if (!namePath || namePath.length === 0) {
|
|
13940
|
+
allValues = this.getFieldsValue(true);
|
|
13941
|
+
} else {
|
|
13942
|
+
allValues = this.getFieldsValue(namePath);
|
|
13943
|
+
}
|
|
13944
|
+
this.watchList.forEach((callback) => {
|
|
13945
|
+
callback(allValues, namePath);
|
|
13946
|
+
});
|
|
13947
|
+
}
|
|
13948
|
+
};
|
|
13901
13949
|
this.callbacks = {
|
|
13902
13950
|
onFinish: () => {
|
|
13903
13951
|
},
|
|
@@ -13921,6 +13969,24 @@ const useForm = (form) => {
|
|
|
13921
13969
|
}
|
|
13922
13970
|
return [formRef.current];
|
|
13923
13971
|
};
|
|
13972
|
+
const useWatch = (path, form) => {
|
|
13973
|
+
const formInstance = form.getInternal(SECRET);
|
|
13974
|
+
const [value, setValue] = useState();
|
|
13975
|
+
useEffect(() => {
|
|
13976
|
+
const unsubscribe = formInstance.registerWatch(
|
|
13977
|
+
(data, namePath) => {
|
|
13978
|
+
const value2 = data[path];
|
|
13979
|
+
setValue(value2);
|
|
13980
|
+
}
|
|
13981
|
+
);
|
|
13982
|
+
const initialValue = form.getFieldsValue(true);
|
|
13983
|
+
if (value !== initialValue[path]) {
|
|
13984
|
+
setValue(initialValue[path]);
|
|
13985
|
+
}
|
|
13986
|
+
return () => unsubscribe();
|
|
13987
|
+
}, [form]);
|
|
13988
|
+
return value;
|
|
13989
|
+
};
|
|
13924
13990
|
const defaultProps$X = {
|
|
13925
13991
|
...ComponentDefaults,
|
|
13926
13992
|
labelPosition: "right",
|
|
@@ -14208,6 +14274,7 @@ let FormItem = _FormItem;
|
|
|
14208
14274
|
const InnerForm = Form;
|
|
14209
14275
|
InnerForm.Item = FormItem;
|
|
14210
14276
|
InnerForm.useForm = useForm;
|
|
14277
|
+
InnerForm.useWatch = useWatch;
|
|
14211
14278
|
function trimExtraChar(value, char, regExp) {
|
|
14212
14279
|
const index = value.indexOf(char);
|
|
14213
14280
|
if (index === -1) {
|
|
@@ -17690,7 +17757,7 @@ const Empty = (props) => {
|
|
|
17690
17757
|
const imageNode = typeof imageUrl === "string" ? /* @__PURE__ */ React__default.createElement("img", { className: "img", src: imageUrl, alt: "empty" }) : imageUrl;
|
|
17691
17758
|
useEffect(() => {
|
|
17692
17759
|
setImgStyle(() => {
|
|
17693
|
-
if (
|
|
17760
|
+
if (typeof imageSize !== "number" && typeof imageSize !== "string") {
|
|
17694
17761
|
return {};
|
|
17695
17762
|
}
|
|
17696
17763
|
if (typeof imageSize === "number") {
|