@nutui/nutui-react 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/Cascader/style/style.css +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 +8 -0
- 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/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/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("react-dom")) : typeof define === "function" && define.amd ? define(["exports", "react", "react-dom"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2.nutui = {}, global2.React, global2.ReactDOM));
|
|
3
3
|
})(this, function(exports2, React, ReactDOM) {
|
|
4
4
|
"use strict";/*!
|
|
5
|
-
* @nutui/nutui-react v2.7.
|
|
5
|
+
* @nutui/nutui-react v2.7.7 Fri Jan 24 2025 13:55:36 GMT+0800 (China Standard Time)
|
|
6
6
|
* (c) 2023 @jdf2e.
|
|
7
7
|
* Released under the MIT License.
|
|
8
8
|
*/
|
|
@@ -3171,7 +3171,7 @@
|
|
|
3171
3171
|
height: 0
|
|
3172
3172
|
};
|
|
3173
3173
|
};
|
|
3174
|
-
function useWatch(dep, callback, config2 = { immediate: false }) {
|
|
3174
|
+
function useWatch$1(dep, callback, config2 = { immediate: false }) {
|
|
3175
3175
|
const { immediate } = config2;
|
|
3176
3176
|
const prev = React.useRef();
|
|
3177
3177
|
const inited = React.useRef(false);
|
|
@@ -3301,7 +3301,7 @@
|
|
|
3301
3301
|
});
|
|
3302
3302
|
setIsFixed(fixed.fixed);
|
|
3303
3303
|
}, [position, threshold, container]);
|
|
3304
|
-
useWatch(isFixed, () => {
|
|
3304
|
+
useWatch$1(isFixed, () => {
|
|
3305
3305
|
onChange && onChange(isFixed);
|
|
3306
3306
|
});
|
|
3307
3307
|
React.useEffect(() => {
|
|
@@ -9222,7 +9222,7 @@
|
|
|
9222
9222
|
autoHeightClassName,
|
|
9223
9223
|
className
|
|
9224
9224
|
);
|
|
9225
|
-
return children
|
|
9225
|
+
return children && /* @__PURE__ */ React.createElement("div", { className: classes }, !disabled && children);
|
|
9226
9226
|
};
|
|
9227
9227
|
const defaultProps$17 = {
|
|
9228
9228
|
...ComponentDefaults,
|
|
@@ -9252,39 +9252,30 @@
|
|
|
9252
9252
|
value: outerValue,
|
|
9253
9253
|
defaultValue: outerDefaultValue,
|
|
9254
9254
|
...rest
|
|
9255
|
-
} = {
|
|
9256
|
-
...defaultProps$17,
|
|
9257
|
-
...props
|
|
9258
|
-
};
|
|
9255
|
+
} = { ...defaultProps$17, ...props };
|
|
9259
9256
|
const [value, setValue] = usePropsValue({
|
|
9260
9257
|
value: outerValue,
|
|
9261
9258
|
defaultValue: outerDefaultValue,
|
|
9262
|
-
finalValue: 0,
|
|
9263
9259
|
onChange
|
|
9264
9260
|
});
|
|
9265
9261
|
const titleItemsRef = React.useRef([]);
|
|
9266
9262
|
const navRef = React.useRef(null);
|
|
9267
|
-
const scrollDirection = (nav, to2, duration2
|
|
9268
|
-
|
|
9269
|
-
const from = direction2 === "horizontal" ? nav.scrollLeft : nav.scrollTop;
|
|
9263
|
+
const scrollDirection = (nav, to2, duration2) => {
|
|
9264
|
+
const from = direction === "horizontal" ? nav.scrollLeft : nav.scrollTop;
|
|
9270
9265
|
const frames = Math.round(duration2 * 1e3 / 16);
|
|
9271
|
-
|
|
9272
|
-
|
|
9273
|
-
|
|
9274
|
-
|
|
9275
|
-
|
|
9276
|
-
|
|
9277
|
-
if (++count < frames) {
|
|
9278
|
-
requestAniFrame$1(animate);
|
|
9279
|
-
}
|
|
9280
|
-
}
|
|
9266
|
+
let count = 0;
|
|
9267
|
+
const animate = () => {
|
|
9268
|
+
if (direction === "horizontal") nav.scrollLeft += (to2 - from) / frames;
|
|
9269
|
+
else nav.scrollTop += (to2 - from) / frames;
|
|
9270
|
+
if (++count < frames) requestAniFrame$1(animate);
|
|
9271
|
+
};
|
|
9281
9272
|
animate();
|
|
9282
9273
|
};
|
|
9283
9274
|
const scrollIntoView = (index, immediate) => {
|
|
9284
9275
|
const nav = navRef.current;
|
|
9285
9276
|
const titleItem = titleItemsRef.current;
|
|
9286
9277
|
const titlesLength = titles.current.length;
|
|
9287
|
-
const itemLength =
|
|
9278
|
+
const itemLength = titleItem.length;
|
|
9288
9279
|
if (!nav || !titleItem || !titleItem[itemLength - titlesLength + index]) {
|
|
9289
9280
|
return;
|
|
9290
9281
|
}
|
|
@@ -9296,13 +9287,13 @@
|
|
|
9296
9287
|
} else {
|
|
9297
9288
|
to2 = title2.offsetLeft - (nav.offsetWidth - title2.offsetWidth) / 2;
|
|
9298
9289
|
}
|
|
9299
|
-
scrollDirection(nav, to2, 0.3
|
|
9290
|
+
scrollDirection(nav, to2, 0.3);
|
|
9300
9291
|
};
|
|
9301
9292
|
const getTitles = () => {
|
|
9302
9293
|
const titles2 = [];
|
|
9303
9294
|
React.Children.forEach(children, (child, idx) => {
|
|
9304
9295
|
if (React.isValidElement(child)) {
|
|
9305
|
-
const
|
|
9296
|
+
const { props: props2 } = child;
|
|
9306
9297
|
if ((props2 == null ? void 0 : props2.title) || (props2 == null ? void 0 : props2.value)) {
|
|
9307
9298
|
titles2.push({
|
|
9308
9299
|
title: props2.title,
|
|
@@ -9337,23 +9328,18 @@
|
|
|
9337
9328
|
);
|
|
9338
9329
|
const classesTitle = classNames(`${classPrefix$j}-titles`, {
|
|
9339
9330
|
[`${classPrefix$j}-titles-${activeType}`]: activeType,
|
|
9340
|
-
[`${classPrefix$j}-titles-scrollable`]: true,
|
|
9341
9331
|
[`${classPrefix$j}-titles-${align}`]: align
|
|
9342
9332
|
});
|
|
9343
|
-
const tabsActiveStyle = {
|
|
9344
|
-
color: activeType === "smile" ? activeColor : "",
|
|
9345
|
-
background: activeType === "line" ? activeColor : ""
|
|
9346
|
-
};
|
|
9347
9333
|
const getContentStyle = () => {
|
|
9348
|
-
let index = titles.current.findIndex((t) => t.value
|
|
9334
|
+
let index = titles.current.findIndex((t) => t.value === value);
|
|
9349
9335
|
index = index < 0 ? 0 : index;
|
|
9350
9336
|
return {
|
|
9351
|
-
transform: direction === "horizontal" ? `translate3d(${rtl ? "" : "-"}${index * 100}%, 0, 0)` : `translate3d( 0
|
|
9337
|
+
transform: direction === "horizontal" ? `translate3d(${rtl ? "" : "-"}${index * 100}%, 0, 0)` : `translate3d( 0, -${index * 100}%, 0)`,
|
|
9352
9338
|
transitionDuration: `${duration}ms`
|
|
9353
9339
|
};
|
|
9354
9340
|
};
|
|
9355
9341
|
React.useEffect(() => {
|
|
9356
|
-
let index = titles.current.findIndex((t) => t.value
|
|
9342
|
+
let index = titles.current.findIndex((t) => t.value === value);
|
|
9357
9343
|
index = index < 0 ? 0 : index;
|
|
9358
9344
|
setTimeout(() => {
|
|
9359
9345
|
scrollIntoView(index);
|
|
@@ -9361,69 +9347,55 @@
|
|
|
9361
9347
|
}, [value]);
|
|
9362
9348
|
const tabChange = (item) => {
|
|
9363
9349
|
onClick && onClick(item.value);
|
|
9364
|
-
if (item.disabled) {
|
|
9365
|
-
|
|
9350
|
+
if (!item.disabled) {
|
|
9351
|
+
setValue(item.value);
|
|
9366
9352
|
}
|
|
9367
|
-
setValue(item.value);
|
|
9368
9353
|
};
|
|
9369
|
-
return /* @__PURE__ */ React.createElement("div", { className: classes, ...rest }, /* @__PURE__ */ React.createElement("div", { className: classesTitle, style:
|
|
9354
|
+
return /* @__PURE__ */ React.createElement("div", { className: classes, ...rest }, /* @__PURE__ */ React.createElement("div", { className: classesTitle, style: tabStyle, ref: navRef }, !!title && typeof title === "function" ? title() : titles.current.map((item) => {
|
|
9370
9355
|
return /* @__PURE__ */ React.createElement(
|
|
9371
9356
|
"div",
|
|
9372
9357
|
{
|
|
9373
|
-
|
|
9374
|
-
|
|
9375
|
-
|
|
9358
|
+
key: item.value,
|
|
9359
|
+
ref: (ref) => titleItemsRef.current.push(ref),
|
|
9360
|
+
onClick: () => tabChange(item),
|
|
9376
9361
|
className: classNames(`${classPrefix$j}-titles-item`, {
|
|
9377
9362
|
[`nut-tabs-titles-item-active`]: !item.disabled && String(item.value) === String(value),
|
|
9378
9363
|
[`nut-tabs-titles-item-disabled`]: item.disabled,
|
|
9379
9364
|
[`nut-tabs-titles-item-${align}`]: align
|
|
9380
|
-
})
|
|
9381
|
-
ref: (ref) => titleItemsRef.current.push(ref),
|
|
9382
|
-
key: item.value
|
|
9365
|
+
})
|
|
9383
9366
|
},
|
|
9384
9367
|
activeType === "line" && /* @__PURE__ */ React.createElement(
|
|
9385
9368
|
"div",
|
|
9386
9369
|
{
|
|
9387
|
-
className: classNames(
|
|
9388
|
-
|
|
9389
|
-
|
|
9390
|
-
|
|
9370
|
+
className: classNames(
|
|
9371
|
+
`${classPrefix$j}-titles-item-line`,
|
|
9372
|
+
`${classPrefix$j}-titles-item-line-${direction}`
|
|
9373
|
+
),
|
|
9374
|
+
style: { background: activeColor }
|
|
9391
9375
|
}
|
|
9392
9376
|
),
|
|
9393
|
-
activeType === "smile" && /* @__PURE__ */ React.createElement(
|
|
9394
|
-
"div",
|
|
9395
|
-
{
|
|
9396
|
-
className: `${classPrefix$j}-titles-item-smile`,
|
|
9397
|
-
style: tabsActiveStyle
|
|
9398
|
-
},
|
|
9399
|
-
/* @__PURE__ */ React.createElement(c$3, { color: activeColor, width: 40, height: 20 })
|
|
9400
|
-
),
|
|
9377
|
+
activeType === "smile" && /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$j}-titles-item-smile` }, /* @__PURE__ */ React.createElement(c$3, { color: activeColor, width: 40, height: 20 })),
|
|
9401
9378
|
/* @__PURE__ */ React.createElement(
|
|
9402
9379
|
"div",
|
|
9403
9380
|
{
|
|
9404
9381
|
className: classNames(
|
|
9405
|
-
|
|
9382
|
+
{
|
|
9383
|
+
[`${classPrefix$j}-ellipsis`]: direction === "vertical"
|
|
9384
|
+
},
|
|
9406
9385
|
`${classPrefix$j}-titles-item-text`
|
|
9407
|
-
)
|
|
9386
|
+
),
|
|
9387
|
+
style: { color: activeColor }
|
|
9408
9388
|
},
|
|
9409
9389
|
item.title
|
|
9410
9390
|
)
|
|
9411
9391
|
);
|
|
9412
9392
|
})), /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$j}-content-wrap` }, /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$j}-content`, style: getContentStyle() }, React.Children.map(children, (child, idx) => {
|
|
9413
|
-
if (!React.isValidElement(child))
|
|
9414
|
-
|
|
9415
|
-
}
|
|
9416
|
-
let childProps = {
|
|
9393
|
+
if (!React.isValidElement(child)) return null;
|
|
9394
|
+
return React.cloneElement(child, {
|
|
9417
9395
|
...child.props,
|
|
9418
|
-
active: value === child.props.value
|
|
9419
|
-
|
|
9420
|
-
|
|
9421
|
-
childProps = {
|
|
9422
|
-
...childProps,
|
|
9423
|
-
autoHeightClassName: "inactive"
|
|
9424
|
-
};
|
|
9425
|
-
}
|
|
9426
|
-
return React.cloneElement(child, childProps);
|
|
9396
|
+
active: value === child.props.value,
|
|
9397
|
+
autoHeightClassName: autoHeight && String(value) !== String(child.props.value || idx) ? "inactive" : void 0
|
|
9398
|
+
});
|
|
9427
9399
|
}))));
|
|
9428
9400
|
};
|
|
9429
9401
|
Tabs.displayName = "NutTabs";
|
|
@@ -12551,6 +12523,14 @@
|
|
|
12551
12523
|
Number(formatDate[2]),
|
|
12552
12524
|
getMonthEndDay(Number(formatDate[0]), Number(formatDate[1]))
|
|
12553
12525
|
);
|
|
12526
|
+
if (selectedOptions.length >= 2 && ["date", "datehour", "datetime", "month-day"].includes(rangeType)) {
|
|
12527
|
+
const dayOption = formatOption("day", day);
|
|
12528
|
+
if (rangeType === "month-day") {
|
|
12529
|
+
selectedOptions[1] = dayOption;
|
|
12530
|
+
} else {
|
|
12531
|
+
selectedOptions[2] = dayOption;
|
|
12532
|
+
}
|
|
12533
|
+
}
|
|
12554
12534
|
let date = null;
|
|
12555
12535
|
if (rangeType === "date" || rangeType === "month-day" || rangeType === "year-month") {
|
|
12556
12536
|
date = new Date(year, month, day);
|
|
@@ -13455,7 +13435,7 @@
|
|
|
13455
13435
|
pattern: {
|
|
13456
13436
|
mismatch: "%s value %s does not match pattern %s"
|
|
13457
13437
|
},
|
|
13458
|
-
clone: function
|
|
13438
|
+
clone: function clone2() {
|
|
13459
13439
|
var cloned = JSON.parse(JSON.stringify(this));
|
|
13460
13440
|
cloned.clone = this.clone;
|
|
13461
13441
|
return cloned;
|
|
@@ -13719,23 +13699,55 @@
|
|
|
13719
13699
|
Schema.warning = warning;
|
|
13720
13700
|
Schema.messages = messages;
|
|
13721
13701
|
Schema.validators = validators;
|
|
13722
|
-
function merge(...
|
|
13723
|
-
|
|
13724
|
-
|
|
13725
|
-
|
|
13726
|
-
|
|
13727
|
-
|
|
13728
|
-
|
|
13729
|
-
|
|
13730
|
-
|
|
13731
|
-
|
|
13732
|
-
|
|
13733
|
-
|
|
13734
|
-
|
|
13735
|
-
|
|
13702
|
+
function merge(...items) {
|
|
13703
|
+
return _merge(items[0] === true, false, items);
|
|
13704
|
+
}
|
|
13705
|
+
function recursive(...items) {
|
|
13706
|
+
return _merge(items[0] === true, true, items);
|
|
13707
|
+
}
|
|
13708
|
+
function clone(input) {
|
|
13709
|
+
if (Array.isArray(input)) {
|
|
13710
|
+
const output = [];
|
|
13711
|
+
for (let index = 0; index < input.length; ++index)
|
|
13712
|
+
output.push(clone(input[index]));
|
|
13713
|
+
return output;
|
|
13714
|
+
}
|
|
13715
|
+
if (isPlainObject(input)) {
|
|
13716
|
+
const output = {};
|
|
13717
|
+
for (const index in input) output[index] = clone(input[index]);
|
|
13718
|
+
return output;
|
|
13719
|
+
}
|
|
13720
|
+
return input;
|
|
13721
|
+
}
|
|
13722
|
+
function isPlainObject(input) {
|
|
13723
|
+
if (input === null || typeof input !== "object") return false;
|
|
13724
|
+
if (Object.getPrototypeOf(input) === null) return true;
|
|
13725
|
+
let ref = input;
|
|
13726
|
+
while (Object.getPrototypeOf(ref) !== null) ref = Object.getPrototypeOf(ref);
|
|
13727
|
+
return Object.getPrototypeOf(input) === ref;
|
|
13728
|
+
}
|
|
13729
|
+
function _recursiveMerge(base, extend) {
|
|
13730
|
+
if (!isPlainObject(base) || !isPlainObject(extend)) return extend;
|
|
13731
|
+
for (const key in extend) {
|
|
13732
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype")
|
|
13733
|
+
continue;
|
|
13734
|
+
base[key] = isPlainObject(base[key]) && isPlainObject(extend[key]) ? _recursiveMerge(base[key], extend[key]) : extend[key];
|
|
13735
|
+
}
|
|
13736
|
+
return base;
|
|
13737
|
+
}
|
|
13738
|
+
function _merge(isClone, isRecursive, items) {
|
|
13739
|
+
let result;
|
|
13740
|
+
if (isClone || !isPlainObject(result = items.shift())) result = {};
|
|
13741
|
+
for (let index = 0; index < items.length; ++index) {
|
|
13742
|
+
const item = items[index];
|
|
13743
|
+
if (!isPlainObject(item)) continue;
|
|
13744
|
+
for (const key in item) {
|
|
13745
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype")
|
|
13746
|
+
continue;
|
|
13747
|
+
const value = isClone ? clone(item[key]) : item[key];
|
|
13748
|
+
result[key] = isRecursive ? _recursiveMerge(result[key], value) : value;
|
|
13736
13749
|
}
|
|
13737
13750
|
}
|
|
13738
|
-
objects.filter((obj) => !!obj).forEach((obj) => mergeHelper(obj));
|
|
13739
13751
|
return result;
|
|
13740
13752
|
}
|
|
13741
13753
|
const SECRET = "NUT_FORM_INTERNAL";
|
|
@@ -13751,9 +13763,6 @@
|
|
|
13751
13763
|
this.fieldEntities.push(field);
|
|
13752
13764
|
return () => {
|
|
13753
13765
|
this.fieldEntities = this.fieldEntities.filter((item) => item !== field);
|
|
13754
|
-
if (this.store) {
|
|
13755
|
-
delete this.store[field.props.name];
|
|
13756
|
-
}
|
|
13757
13766
|
};
|
|
13758
13767
|
};
|
|
13759
13768
|
this.getFieldValue = (name) => {
|
|
@@ -13775,10 +13784,11 @@
|
|
|
13775
13784
|
if (init) {
|
|
13776
13785
|
const nextStore = merge(initialValues, this.store);
|
|
13777
13786
|
this.updateStore(nextStore);
|
|
13787
|
+
this.notifyWatch();
|
|
13778
13788
|
}
|
|
13779
13789
|
};
|
|
13780
13790
|
this.setFieldsValue = (newStore) => {
|
|
13781
|
-
const nextStore =
|
|
13791
|
+
const nextStore = recursive(true, this.store, newStore);
|
|
13782
13792
|
this.updateStore(nextStore);
|
|
13783
13793
|
this.fieldEntities.forEach((entity) => {
|
|
13784
13794
|
const { name } = entity.props;
|
|
@@ -13797,12 +13807,14 @@
|
|
|
13797
13807
|
item.entity.onStoreChange("update");
|
|
13798
13808
|
}
|
|
13799
13809
|
});
|
|
13810
|
+
this.notifyWatch();
|
|
13800
13811
|
};
|
|
13801
13812
|
this.setFieldValue = (name, value) => {
|
|
13802
13813
|
const store = {
|
|
13803
13814
|
[name]: value
|
|
13804
13815
|
};
|
|
13805
13816
|
this.setFieldsValue(store);
|
|
13817
|
+
this.notifyWatch([name]);
|
|
13806
13818
|
};
|
|
13807
13819
|
this.setCallback = (callback) => {
|
|
13808
13820
|
this.callbacks = {
|
|
@@ -13845,7 +13857,6 @@
|
|
|
13845
13857
|
};
|
|
13846
13858
|
this.validateFields = async (nameList) => {
|
|
13847
13859
|
let filterEntities = [];
|
|
13848
|
-
this.errors.length = 0;
|
|
13849
13860
|
if (!nameList || nameList.length === 0) {
|
|
13850
13861
|
filterEntities = this.fieldEntities;
|
|
13851
13862
|
} else {
|
|
@@ -13870,13 +13881,29 @@
|
|
|
13870
13881
|
(_d = (_c = this.callbacks).onFinishFailed) == null ? void 0 : _d.call(_c, this.store, errors);
|
|
13871
13882
|
}
|
|
13872
13883
|
};
|
|
13873
|
-
this.resetFields = () => {
|
|
13874
|
-
|
|
13875
|
-
|
|
13876
|
-
|
|
13877
|
-
|
|
13878
|
-
|
|
13879
|
-
|
|
13884
|
+
this.resetFields = (namePaths) => {
|
|
13885
|
+
if (namePaths && namePaths.length) {
|
|
13886
|
+
namePaths.forEach((path) => {
|
|
13887
|
+
this.errors[path] = null;
|
|
13888
|
+
this.fieldEntities.forEach((entity) => {
|
|
13889
|
+
const name = entity.props.name;
|
|
13890
|
+
if (name === path) {
|
|
13891
|
+
if (path in this.initialValues) {
|
|
13892
|
+
this.updateStore({ [path]: this.initialValues[path] });
|
|
13893
|
+
} else {
|
|
13894
|
+
delete this.store[path];
|
|
13895
|
+
}
|
|
13896
|
+
entity.onStoreChange("reset");
|
|
13897
|
+
}
|
|
13898
|
+
});
|
|
13899
|
+
});
|
|
13900
|
+
} else {
|
|
13901
|
+
const nextStore = merge({}, this.initialValues);
|
|
13902
|
+
this.updateStore(nextStore);
|
|
13903
|
+
this.fieldEntities.forEach((entity) => {
|
|
13904
|
+
entity.onStoreChange("reset");
|
|
13905
|
+
});
|
|
13906
|
+
}
|
|
13880
13907
|
};
|
|
13881
13908
|
this.registerUpdate = (field, shouldUpdate) => {
|
|
13882
13909
|
this.updateList.push({
|
|
@@ -13899,7 +13926,8 @@
|
|
|
13899
13926
|
dispatch: this.dispatch,
|
|
13900
13927
|
store: this.store,
|
|
13901
13928
|
fieldEntities: this.fieldEntities,
|
|
13902
|
-
registerUpdate: this.registerUpdate
|
|
13929
|
+
registerUpdate: this.registerUpdate,
|
|
13930
|
+
registerWatch: this.registerWatch
|
|
13903
13931
|
};
|
|
13904
13932
|
}
|
|
13905
13933
|
};
|
|
@@ -13916,6 +13944,26 @@
|
|
|
13916
13944
|
getInternal: this.getInternal
|
|
13917
13945
|
};
|
|
13918
13946
|
};
|
|
13947
|
+
this.watchList = [];
|
|
13948
|
+
this.registerWatch = (callback) => {
|
|
13949
|
+
this.watchList.push(callback);
|
|
13950
|
+
return () => {
|
|
13951
|
+
this.watchList = this.watchList.filter((fn) => fn !== callback);
|
|
13952
|
+
};
|
|
13953
|
+
};
|
|
13954
|
+
this.notifyWatch = (namePath = []) => {
|
|
13955
|
+
if (this.watchList.length) {
|
|
13956
|
+
let allValues;
|
|
13957
|
+
if (!namePath || namePath.length === 0) {
|
|
13958
|
+
allValues = this.getFieldsValue(true);
|
|
13959
|
+
} else {
|
|
13960
|
+
allValues = this.getFieldsValue(namePath);
|
|
13961
|
+
}
|
|
13962
|
+
this.watchList.forEach((callback) => {
|
|
13963
|
+
callback(allValues, namePath);
|
|
13964
|
+
});
|
|
13965
|
+
}
|
|
13966
|
+
};
|
|
13919
13967
|
this.callbacks = {
|
|
13920
13968
|
onFinish: () => {
|
|
13921
13969
|
},
|
|
@@ -13939,6 +13987,24 @@
|
|
|
13939
13987
|
}
|
|
13940
13988
|
return [formRef.current];
|
|
13941
13989
|
};
|
|
13990
|
+
const useWatch = (path, form) => {
|
|
13991
|
+
const formInstance = form.getInternal(SECRET);
|
|
13992
|
+
const [value, setValue] = React.useState();
|
|
13993
|
+
React.useEffect(() => {
|
|
13994
|
+
const unsubscribe = formInstance.registerWatch(
|
|
13995
|
+
(data, namePath) => {
|
|
13996
|
+
const value2 = data[path];
|
|
13997
|
+
setValue(value2);
|
|
13998
|
+
}
|
|
13999
|
+
);
|
|
14000
|
+
const initialValue = form.getFieldsValue(true);
|
|
14001
|
+
if (value !== initialValue[path]) {
|
|
14002
|
+
setValue(initialValue[path]);
|
|
14003
|
+
}
|
|
14004
|
+
return () => unsubscribe();
|
|
14005
|
+
}, [form]);
|
|
14006
|
+
return value;
|
|
14007
|
+
};
|
|
13942
14008
|
const defaultProps$X = {
|
|
13943
14009
|
...ComponentDefaults,
|
|
13944
14010
|
labelPosition: "right",
|
|
@@ -14226,6 +14292,7 @@
|
|
|
14226
14292
|
const InnerForm = Form;
|
|
14227
14293
|
InnerForm.Item = FormItem;
|
|
14228
14294
|
InnerForm.useForm = useForm;
|
|
14295
|
+
InnerForm.useWatch = useWatch;
|
|
14229
14296
|
function trimExtraChar(value, char, regExp) {
|
|
14230
14297
|
const index = value.indexOf(char);
|
|
14231
14298
|
if (index === -1) {
|
|
@@ -17708,7 +17775,7 @@
|
|
|
17708
17775
|
const imageNode = typeof imageUrl === "string" ? /* @__PURE__ */ React.createElement("img", { className: "img", src: imageUrl, alt: "empty" }) : imageUrl;
|
|
17709
17776
|
React.useEffect(() => {
|
|
17710
17777
|
setImgStyle(() => {
|
|
17711
|
-
if (
|
|
17778
|
+
if (typeof imageSize !== "number" && typeof imageSize !== "string") {
|
|
17712
17779
|
return {};
|
|
17713
17780
|
}
|
|
17714
17781
|
if (typeof imageSize === "number") {
|
|
@@ -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
|
}
|