@nutui/nutui-react 2.7.1 → 2.7.3
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 +36 -10
- package/dist/esm/Animate/style/style.css +1 -1
- package/dist/esm/Empty.js +9 -1
- package/dist/esm/Form/style/style.css +1 -1
- package/dist/esm/Form.js +3 -3
- package/dist/esm/FormItem/style/style.css +1 -1
- package/dist/esm/Popover/style/style.css +1 -1
- package/dist/esm/Table/style/style.css +1 -1
- package/dist/esm/Tour/style/style.css +1 -1
- package/dist/esm/Uploader/style/style.css +1 -1
- package/dist/esm/Uploader.js +4 -2
- package/dist/esm/Video.js +14 -2
- package/dist/esm/formitem2.js +136 -76
- 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 +198 -107
- package/dist/nutui.react.umd.js +198 -107
- package/dist/packages/animate/animate.scss +0 -3
- package/dist/packages/form/form.scss +0 -68
- package/dist/packages/formitem/formitem.scss +90 -21
- package/dist/packages/popover/popover.scss +16 -11
- package/dist/packages/table/table.scss +1 -0
- package/dist/packages/uploader/uploader.scss +2 -1
- package/dist/style.css +1 -1
- package/dist/styles/variables.scss +1 -0
- package/dist/types/packages/configprovider/types.d.ts +1 -1
- package/dist/types/packages/empty/types.d.ts +10 -1
- package/dist/types/packages/empty/utils.d.ts +2 -0
- package/dist/types/packages/form/form.d.ts +10 -0
- package/dist/types/packages/form/form.taro.d.ts +2 -0
- package/dist/types/packages/form/types.d.ts +2 -1
- package/dist/types/packages/formitem/formitem.d.ts +1 -0
- package/dist/types/packages/formitem/formitem.taro.d.ts +1 -0
- package/dist/types/packages/video/video.d.ts +6 -2
- package/dist/types/utils/merge.d.ts +1 -0
- package/dist/types/utils/to-array.d.ts +1 -0
- 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.3 Fri Dec 13 2024 15:50:56 GMT+0800 (China Standard Time)
|
|
6
6
|
* (c) 2023 @jdf2e.
|
|
7
7
|
* Released under the MIT License.
|
|
8
8
|
*/
|
|
@@ -5332,7 +5332,7 @@
|
|
|
5332
5332
|
}
|
|
5333
5333
|
}
|
|
5334
5334
|
}
|
|
5335
|
-
const toArray = (a) => is.und(a) ? [] : is.arr(a) ? a : [a];
|
|
5335
|
+
const toArray$1 = (a) => is.und(a) ? [] : is.arr(a) ? a : [a];
|
|
5336
5336
|
function flush(queue, iterator) {
|
|
5337
5337
|
if (queue.size) {
|
|
5338
5338
|
const items = Array.from(queue);
|
|
@@ -6340,7 +6340,7 @@
|
|
|
6340
6340
|
function callProp(value, ...args) {
|
|
6341
6341
|
return is.fun(value) ? value(...args) : value;
|
|
6342
6342
|
}
|
|
6343
|
-
const matchProp = (value, key) => value === true || !!(key && value && (is.fun(value) ? value(key) : toArray(value).includes(key)));
|
|
6343
|
+
const matchProp = (value, key) => value === true || !!(key && value && (is.fun(value) ? value(key) : toArray$1(value).includes(key)));
|
|
6344
6344
|
const resolveProp = (prop, key) => is.obj(prop) ? key && prop[key] : prop;
|
|
6345
6345
|
const getDefaultProp = (props, key) => props.default === true ? props[key] : props.default ? props.default[key] : void 0;
|
|
6346
6346
|
const noopTransform = (value) => value;
|
|
@@ -6882,7 +6882,7 @@
|
|
|
6882
6882
|
} = anim;
|
|
6883
6883
|
const payload = getPayload(anim.to);
|
|
6884
6884
|
if (!payload && hasFluidValue(anim.to)) {
|
|
6885
|
-
toValues = toArray(getFluidValue(anim.to));
|
|
6885
|
+
toValues = toArray$1(getFluidValue(anim.to));
|
|
6886
6886
|
}
|
|
6887
6887
|
anim.values.forEach((node2, i2) => {
|
|
6888
6888
|
if (node2.done) return;
|
|
@@ -7235,7 +7235,7 @@
|
|
|
7235
7235
|
if (!hasAsyncTo) {
|
|
7236
7236
|
if (started || hasFluidValue(prevTo)) {
|
|
7237
7237
|
anim.values = node.getPayload();
|
|
7238
|
-
anim.toValues = hasFluidValue(to2) ? null : goalType == AnimatedString ? [1] : toArray(goal);
|
|
7238
|
+
anim.toValues = hasFluidValue(to2) ? null : goalType == AnimatedString ? [1] : toArray$1(goal);
|
|
7239
7239
|
}
|
|
7240
7240
|
if (anim.immediate != immediate) {
|
|
7241
7241
|
anim.immediate = immediate;
|
|
@@ -7508,7 +7508,7 @@
|
|
|
7508
7508
|
queue
|
|
7509
7509
|
} = this;
|
|
7510
7510
|
if (props) {
|
|
7511
|
-
queue = toArray(props).map(createUpdate);
|
|
7511
|
+
queue = toArray$1(props).map(createUpdate);
|
|
7512
7512
|
} else {
|
|
7513
7513
|
this.queue = [];
|
|
7514
7514
|
}
|
|
@@ -7524,7 +7524,7 @@
|
|
|
7524
7524
|
}
|
|
7525
7525
|
if (keys) {
|
|
7526
7526
|
const springs = this.springs;
|
|
7527
|
-
each(toArray(keys), (key) => springs[key].stop(!!arg));
|
|
7527
|
+
each(toArray$1(keys), (key) => springs[key].stop(!!arg));
|
|
7528
7528
|
} else {
|
|
7529
7529
|
stopAsync(this._state, this._lastAsyncId);
|
|
7530
7530
|
this.each((spring) => spring.stop(!!arg));
|
|
@@ -7538,7 +7538,7 @@
|
|
|
7538
7538
|
});
|
|
7539
7539
|
} else {
|
|
7540
7540
|
const springs = this.springs;
|
|
7541
|
-
each(toArray(keys), (key) => springs[key].pause());
|
|
7541
|
+
each(toArray$1(keys), (key) => springs[key].pause());
|
|
7542
7542
|
}
|
|
7543
7543
|
return this;
|
|
7544
7544
|
}
|
|
@@ -7549,7 +7549,7 @@
|
|
|
7549
7549
|
});
|
|
7550
7550
|
} else {
|
|
7551
7551
|
const springs = this.springs;
|
|
7552
|
-
each(toArray(keys), (key) => springs[key].resume());
|
|
7552
|
+
each(toArray$1(keys), (key) => springs[key].resume());
|
|
7553
7553
|
}
|
|
7554
7554
|
return this;
|
|
7555
7555
|
}
|
|
@@ -7700,7 +7700,7 @@
|
|
|
7700
7700
|
function getSprings(ctrl, props) {
|
|
7701
7701
|
const springs = _extends$1({}, ctrl.springs);
|
|
7702
7702
|
if (props) {
|
|
7703
|
-
each(toArray(props), (props2) => {
|
|
7703
|
+
each(toArray$1(props), (props2) => {
|
|
7704
7704
|
if (is.und(props2.keys)) {
|
|
7705
7705
|
props2 = createUpdate(props2);
|
|
7706
7706
|
}
|
|
@@ -7972,7 +7972,7 @@
|
|
|
7972
7972
|
}
|
|
7973
7973
|
}
|
|
7974
7974
|
_get() {
|
|
7975
|
-
const inputs = is.arr(this.source) ? this.source.map(getFluidValue) : toArray(getFluidValue(this.source));
|
|
7975
|
+
const inputs = is.arr(this.source) ? this.source.map(getFluidValue) : toArray$1(getFluidValue(this.source));
|
|
7976
7976
|
return this.calc(...inputs);
|
|
7977
7977
|
}
|
|
7978
7978
|
_start() {
|
|
@@ -7991,7 +7991,7 @@
|
|
|
7991
7991
|
}
|
|
7992
7992
|
_attach() {
|
|
7993
7993
|
let priority2 = 1;
|
|
7994
|
-
each(toArray(this.source), (source) => {
|
|
7994
|
+
each(toArray$1(this.source), (source) => {
|
|
7995
7995
|
if (hasFluidValue(source)) {
|
|
7996
7996
|
addFluidObserver(source, this);
|
|
7997
7997
|
}
|
|
@@ -8006,7 +8006,7 @@
|
|
|
8006
8006
|
this._start();
|
|
8007
8007
|
}
|
|
8008
8008
|
_detach() {
|
|
8009
|
-
each(toArray(this.source), (source) => {
|
|
8009
|
+
each(toArray$1(this.source), (source) => {
|
|
8010
8010
|
if (hasFluidValue(source)) {
|
|
8011
8011
|
removeFluidObserver(source, this);
|
|
8012
8012
|
}
|
|
@@ -8025,7 +8025,7 @@
|
|
|
8025
8025
|
} else if (event.type == "idle") {
|
|
8026
8026
|
this._active.delete(event.parent);
|
|
8027
8027
|
} else if (event.type == "priority") {
|
|
8028
|
-
this.priority = toArray(this.source).reduce((highest, parent) => Math.max(highest, (isFrameValue(parent) ? parent.priority : 0) + 1), 0);
|
|
8028
|
+
this.priority = toArray$1(this.source).reduce((highest, parent) => Math.max(highest, (isFrameValue(parent) ? parent.priority : 0) + 1), 0);
|
|
8029
8029
|
}
|
|
8030
8030
|
}
|
|
8031
8031
|
}
|
|
@@ -8187,7 +8187,7 @@
|
|
|
8187
8187
|
delete style[key];
|
|
8188
8188
|
if (is.und(value)) return;
|
|
8189
8189
|
const unit = pxTransforms.test(key) ? "px" : degTransforms.test(key) ? "deg" : "";
|
|
8190
|
-
inputs.push(toArray(value));
|
|
8190
|
+
inputs.push(toArray$1(value));
|
|
8191
8191
|
transforms.push(key === "rotate3d" ? ([x2, y2, z2, deg]) => [`rotate3d(${x2},${y2},${z2},${addUnit(deg, unit)})`, isValueIdentity(deg, 0)] : (input) => [`${key}(${input.map((v) => addUnit(v, unit)).join(",")})`, isValueIdentity(input, key.startsWith("scale") ? 1 : 0)]);
|
|
8192
8192
|
}
|
|
8193
8193
|
});
|
|
@@ -13719,6 +13719,25 @@
|
|
|
13719
13719
|
Schema.warning = warning;
|
|
13720
13720
|
Schema.messages = messages;
|
|
13721
13721
|
Schema.validators = validators;
|
|
13722
|
+
function merge(...objects) {
|
|
13723
|
+
const result = Array.isArray(objects[0]) ? [] : {};
|
|
13724
|
+
function mergeHelper(obj, path = []) {
|
|
13725
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
13726
|
+
const newPath = [...path, key];
|
|
13727
|
+
if (Array.isArray(value)) {
|
|
13728
|
+
result[key] = [...value];
|
|
13729
|
+
} else if (typeof value === "object" && value !== null) {
|
|
13730
|
+
if (path.some((p2) => p2 === value)) continue;
|
|
13731
|
+
if (!result[key]) result[key] = {};
|
|
13732
|
+
mergeHelper(value, newPath);
|
|
13733
|
+
} else {
|
|
13734
|
+
result[key] = value;
|
|
13735
|
+
}
|
|
13736
|
+
}
|
|
13737
|
+
}
|
|
13738
|
+
objects.filter((obj) => !!obj).forEach((obj) => mergeHelper(obj));
|
|
13739
|
+
return result;
|
|
13740
|
+
}
|
|
13722
13741
|
const SECRET = "NUT_FORM_INTERNAL";
|
|
13723
13742
|
class FormStore {
|
|
13724
13743
|
constructor() {
|
|
@@ -13751,17 +13770,16 @@
|
|
|
13751
13770
|
});
|
|
13752
13771
|
return fieldsValue;
|
|
13753
13772
|
};
|
|
13754
|
-
this.setInitialValues = (
|
|
13773
|
+
this.setInitialValues = (initialValues, init) => {
|
|
13774
|
+
this.initialValues = initialValues || {};
|
|
13755
13775
|
if (init) {
|
|
13756
|
-
|
|
13757
|
-
this.
|
|
13776
|
+
const nextStore = merge(initialValues, this.store);
|
|
13777
|
+
this.updateStore(nextStore);
|
|
13758
13778
|
}
|
|
13759
13779
|
};
|
|
13760
|
-
this.setFieldsValue = (newStore
|
|
13761
|
-
this.store
|
|
13762
|
-
|
|
13763
|
-
...newStore
|
|
13764
|
-
};
|
|
13780
|
+
this.setFieldsValue = (newStore) => {
|
|
13781
|
+
const nextStore = merge(this.store, newStore);
|
|
13782
|
+
this.updateStore(nextStore);
|
|
13765
13783
|
this.fieldEntities.forEach((entity) => {
|
|
13766
13784
|
const { name } = entity.props;
|
|
13767
13785
|
Object.keys(newStore).forEach((key) => {
|
|
@@ -13779,7 +13797,12 @@
|
|
|
13779
13797
|
item.entity.onStoreChange("update");
|
|
13780
13798
|
}
|
|
13781
13799
|
});
|
|
13782
|
-
|
|
13800
|
+
};
|
|
13801
|
+
this.setFieldValue = (name, value) => {
|
|
13802
|
+
const store = {
|
|
13803
|
+
[name]: value
|
|
13804
|
+
};
|
|
13805
|
+
this.setFieldsValue(store);
|
|
13783
13806
|
};
|
|
13784
13807
|
this.setCallback = (callback) => {
|
|
13785
13808
|
this.callbacks = {
|
|
@@ -13787,46 +13810,55 @@
|
|
|
13787
13810
|
...callback
|
|
13788
13811
|
};
|
|
13789
13812
|
};
|
|
13790
|
-
this.
|
|
13813
|
+
this.validateEntities = async (entity, errs) => {
|
|
13791
13814
|
var _a;
|
|
13792
|
-
|
|
13793
|
-
|
|
13815
|
+
const { name, rules: rules2 = [] } = entity.props;
|
|
13816
|
+
if (!name) {
|
|
13817
|
+
console.warn("Form field missing name property");
|
|
13818
|
+
return;
|
|
13819
|
+
}
|
|
13820
|
+
const descriptor = {};
|
|
13821
|
+
if (rules2.length) {
|
|
13822
|
+
if (rules2.length > 1) {
|
|
13823
|
+
descriptor[name] = [];
|
|
13824
|
+
rules2.forEach((v) => {
|
|
13825
|
+
descriptor[name].push(v);
|
|
13826
|
+
});
|
|
13827
|
+
} else {
|
|
13828
|
+
descriptor[name] = rules2[0];
|
|
13829
|
+
}
|
|
13830
|
+
}
|
|
13831
|
+
const validator = new Schema(descriptor);
|
|
13832
|
+
try {
|
|
13833
|
+
await validator.validate({ [name]: (_a = this.store) == null ? void 0 : _a[name] });
|
|
13834
|
+
} catch ({ errors }) {
|
|
13835
|
+
if (errors) {
|
|
13836
|
+
errs.push(...errors);
|
|
13837
|
+
this.errors[name] = errors;
|
|
13838
|
+
}
|
|
13839
|
+
} finally {
|
|
13840
|
+
if (!errs || errs.length === 0) {
|
|
13841
|
+
this.errors[name] = [];
|
|
13842
|
+
}
|
|
13843
|
+
}
|
|
13844
|
+
entity.onStoreChange("validate");
|
|
13845
|
+
};
|
|
13846
|
+
this.validateFields = async (nameList) => {
|
|
13847
|
+
let filterEntities = [];
|
|
13794
13848
|
this.errors.length = 0;
|
|
13795
13849
|
if (!nameList || nameList.length === 0) {
|
|
13796
|
-
|
|
13850
|
+
filterEntities = this.fieldEntities;
|
|
13797
13851
|
} else {
|
|
13798
|
-
|
|
13852
|
+
filterEntities = this.fieldEntities.filter(
|
|
13799
13853
|
({ props: { name } }) => nameList.includes(name)
|
|
13800
13854
|
);
|
|
13801
13855
|
}
|
|
13802
|
-
|
|
13803
|
-
|
|
13804
|
-
|
|
13805
|
-
|
|
13806
|
-
|
|
13807
|
-
|
|
13808
|
-
rules2.forEach((v) => {
|
|
13809
|
-
descriptor[name].push(v);
|
|
13810
|
-
});
|
|
13811
|
-
} else {
|
|
13812
|
-
descriptor[name] = rules2[0];
|
|
13813
|
-
}
|
|
13814
|
-
}
|
|
13815
|
-
const validator = new Schema(descriptor);
|
|
13816
|
-
try {
|
|
13817
|
-
await validator.validate({ [name]: (_a = this.store) == null ? void 0 : _a[name] });
|
|
13818
|
-
} catch ({ errors }) {
|
|
13819
|
-
if (errors) {
|
|
13820
|
-
errs.push(...errors);
|
|
13821
|
-
this.errors[name] = errors;
|
|
13822
|
-
}
|
|
13823
|
-
} finally {
|
|
13824
|
-
if (!errs || errs.length === 0) {
|
|
13825
|
-
this.errors[name] = [];
|
|
13826
|
-
}
|
|
13827
|
-
}
|
|
13828
|
-
entity.onStoreChange("validate");
|
|
13829
|
-
}
|
|
13856
|
+
const errs = [];
|
|
13857
|
+
await Promise.all(
|
|
13858
|
+
filterEntities.map(async (entity) => {
|
|
13859
|
+
await this.validateEntities(entity, errs);
|
|
13860
|
+
})
|
|
13861
|
+
);
|
|
13830
13862
|
return errs;
|
|
13831
13863
|
};
|
|
13832
13864
|
this.submit = async () => {
|
|
@@ -13840,7 +13872,8 @@
|
|
|
13840
13872
|
};
|
|
13841
13873
|
this.resetFields = () => {
|
|
13842
13874
|
this.errors.length = 0;
|
|
13843
|
-
|
|
13875
|
+
const nextStore = merge({}, this.initialValues);
|
|
13876
|
+
this.updateStore(nextStore);
|
|
13844
13877
|
this.fieldEntities.forEach((entity) => {
|
|
13845
13878
|
entity.onStoreChange("reset");
|
|
13846
13879
|
});
|
|
@@ -13875,6 +13908,7 @@
|
|
|
13875
13908
|
getFieldValue: this.getFieldValue,
|
|
13876
13909
|
getFieldsValue: this.getFieldsValue,
|
|
13877
13910
|
setFieldsValue: this.setFieldsValue,
|
|
13911
|
+
setFieldValue: this.setFieldValue,
|
|
13878
13912
|
resetFields: this.resetFields,
|
|
13879
13913
|
validateFields: this.validateFields,
|
|
13880
13914
|
submit: this.submit,
|
|
@@ -13889,6 +13923,9 @@
|
|
|
13889
13923
|
}
|
|
13890
13924
|
};
|
|
13891
13925
|
}
|
|
13926
|
+
updateStore(nextStore) {
|
|
13927
|
+
this.store = nextStore;
|
|
13928
|
+
}
|
|
13892
13929
|
}
|
|
13893
13930
|
const useForm = (form) => {
|
|
13894
13931
|
const formRef = React.useRef();
|
|
@@ -13906,7 +13943,9 @@
|
|
|
13906
13943
|
...ComponentDefaults,
|
|
13907
13944
|
labelPosition: "right",
|
|
13908
13945
|
starPosition: "left",
|
|
13946
|
+
disabled: false,
|
|
13909
13947
|
divider: false,
|
|
13948
|
+
validateTrigger: "onChange",
|
|
13910
13949
|
onFinish: (values) => {
|
|
13911
13950
|
},
|
|
13912
13951
|
onFinishFailed: (values, errorFields) => {
|
|
@@ -13927,8 +13966,10 @@
|
|
|
13927
13966
|
children,
|
|
13928
13967
|
initialValues,
|
|
13929
13968
|
divider,
|
|
13969
|
+
disabled,
|
|
13930
13970
|
onFinish,
|
|
13931
13971
|
onFinishFailed,
|
|
13972
|
+
validateTrigger,
|
|
13932
13973
|
labelPosition,
|
|
13933
13974
|
starPosition,
|
|
13934
13975
|
form
|
|
@@ -13975,7 +14016,13 @@
|
|
|
13975
14016
|
resetFields();
|
|
13976
14017
|
}
|
|
13977
14018
|
},
|
|
13978
|
-
/* @__PURE__ */ React.createElement(Cell.Group, { divider }, /* @__PURE__ */ React.createElement(
|
|
14019
|
+
/* @__PURE__ */ React.createElement(Cell.Group, { divider }, /* @__PURE__ */ React.createElement(
|
|
14020
|
+
Context.Provider,
|
|
14021
|
+
{
|
|
14022
|
+
value: { formInstance, labelPosition, disabled, validateTrigger }
|
|
14023
|
+
},
|
|
14024
|
+
children
|
|
14025
|
+
), footer ? /* @__PURE__ */ React.createElement(Cell, { className: `${classPrefix2}-footer` }, footer) : null)
|
|
13979
14026
|
);
|
|
13980
14027
|
}
|
|
13981
14028
|
);
|
|
@@ -13989,6 +14036,12 @@
|
|
|
13989
14036
|
}
|
|
13990
14037
|
).$$typeof === component.type.$$typeof;
|
|
13991
14038
|
}
|
|
14039
|
+
function toArray(value) {
|
|
14040
|
+
if (value === void 0 || value === null) {
|
|
14041
|
+
return [];
|
|
14042
|
+
}
|
|
14043
|
+
return Array.isArray(value) ? value : [value];
|
|
14044
|
+
}
|
|
13992
14045
|
const defaultProps$W = {
|
|
13993
14046
|
...ComponentDefaults,
|
|
13994
14047
|
required: false,
|
|
@@ -13996,7 +14049,6 @@
|
|
|
13996
14049
|
label: "",
|
|
13997
14050
|
rules: [{ required: false, message: "" }],
|
|
13998
14051
|
errorMessageAlign: "left",
|
|
13999
|
-
validateTrigger: "onChange",
|
|
14000
14052
|
shouldUpdate: false,
|
|
14001
14053
|
noStyle: false
|
|
14002
14054
|
};
|
|
@@ -14005,15 +14057,14 @@
|
|
|
14005
14057
|
super(props);
|
|
14006
14058
|
this.getControlled = (children) => {
|
|
14007
14059
|
var _a;
|
|
14008
|
-
const { setFieldsValue, getFieldValue } = this.context;
|
|
14009
|
-
const { dispatch } = this.context.getInternal(SECRET);
|
|
14060
|
+
const { setFieldsValue, getFieldValue } = this.context.formInstance;
|
|
14061
|
+
const { dispatch } = this.context.formInstance.getInternal(SECRET);
|
|
14010
14062
|
const { name = "" } = this.props;
|
|
14011
|
-
if ((_a = children == null ? void 0 : children.props) == null ? void 0 : _a.defaultValue)
|
|
14012
|
-
console.warn("通过 initialValue 设置初始值");
|
|
14013
|
-
}
|
|
14063
|
+
if ((_a = children == null ? void 0 : children.props) == null ? void 0 : _a.defaultValue) ;
|
|
14014
14064
|
const fieldValue = getFieldValue(name);
|
|
14015
14065
|
const controlled = {
|
|
14016
14066
|
...children.props,
|
|
14067
|
+
className: children.props.className,
|
|
14017
14068
|
[this.props.valuePropName || "value"]: fieldValue !== void 0 ? fieldValue : this.props.initialValue,
|
|
14018
14069
|
[this.props.trigger || "onChange"]: (...args) => {
|
|
14019
14070
|
const originOnChange = children.props[this.props.trigger || "onChange"];
|
|
@@ -14024,27 +14075,25 @@
|
|
|
14024
14075
|
if (this.props.getValueFromEvent) {
|
|
14025
14076
|
next = this.props.getValueFromEvent(...args);
|
|
14026
14077
|
}
|
|
14027
|
-
setFieldsValue({ [name]: next }
|
|
14078
|
+
setFieldsValue({ [name]: next });
|
|
14028
14079
|
}
|
|
14029
14080
|
};
|
|
14030
14081
|
const { validateTrigger } = this.props;
|
|
14031
|
-
|
|
14032
|
-
|
|
14033
|
-
|
|
14034
|
-
|
|
14035
|
-
|
|
14036
|
-
|
|
14037
|
-
|
|
14038
|
-
|
|
14039
|
-
|
|
14040
|
-
|
|
14041
|
-
|
|
14042
|
-
|
|
14043
|
-
|
|
14044
|
-
|
|
14045
|
-
|
|
14046
|
-
});
|
|
14047
|
-
}
|
|
14082
|
+
const mergedValidateTrigger = validateTrigger || this.context.validateTrigger;
|
|
14083
|
+
const validateTriggers = toArray(mergedValidateTrigger);
|
|
14084
|
+
validateTriggers.forEach((trigger) => {
|
|
14085
|
+
const originTrigger = controlled[trigger];
|
|
14086
|
+
controlled[trigger] = (...args) => {
|
|
14087
|
+
if (originTrigger) {
|
|
14088
|
+
originTrigger(...args);
|
|
14089
|
+
}
|
|
14090
|
+
if (this.props.rules && this.props.rules.length) {
|
|
14091
|
+
dispatch({
|
|
14092
|
+
name: this.props.name
|
|
14093
|
+
});
|
|
14094
|
+
}
|
|
14095
|
+
};
|
|
14096
|
+
});
|
|
14048
14097
|
if (isForwardRefComponent(children)) {
|
|
14049
14098
|
controlled.ref = (componentInstance) => {
|
|
14050
14099
|
const originRef = children.ref;
|
|
@@ -14068,7 +14117,7 @@
|
|
|
14068
14117
|
};
|
|
14069
14118
|
this.onStoreChange = (type) => {
|
|
14070
14119
|
if (type === "reset") {
|
|
14071
|
-
this.context.errors[this.props.name] = [];
|
|
14120
|
+
this.context.formInstance.errors[this.props.name] = [];
|
|
14072
14121
|
this.refresh();
|
|
14073
14122
|
} else {
|
|
14074
14123
|
this.forceUpdate();
|
|
@@ -14089,27 +14138,40 @@
|
|
|
14089
14138
|
...this.props
|
|
14090
14139
|
};
|
|
14091
14140
|
const requiredInRules = rules2 == null ? void 0 : rules2.some((rule) => rule.required);
|
|
14092
|
-
const item = name ? this.context.errors[name] : [];
|
|
14093
|
-
const { starPosition } = this.context;
|
|
14094
|
-
const renderStar = (required || requiredInRules) && /* @__PURE__ */ React.createElement("
|
|
14095
|
-
const renderLabel = /* @__PURE__ */ React.createElement(React.Fragment, null, starPosition === "left" ? renderStar : null, label, starPosition === "right" ? renderStar : null);
|
|
14141
|
+
const item = name ? this.context.formInstance.errors[name] : [];
|
|
14142
|
+
const { starPosition } = this.context.formInstance;
|
|
14143
|
+
const renderStar = (required || requiredInRules) && /* @__PURE__ */ React.createElement("div", { className: "nut-form-item-label-required required" }, "*");
|
|
14144
|
+
const renderLabel = /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("span", { className: "nut-form-item-labeltxt" }, starPosition === "left" ? renderStar : null, label), starPosition === "right" ? renderStar : null);
|
|
14096
14145
|
return /* @__PURE__ */ React.createElement(
|
|
14097
14146
|
Cell,
|
|
14098
14147
|
{
|
|
14099
|
-
className:
|
|
14148
|
+
className: `${this.getClassNameWithDirection("nut-form-item")} ${className}`,
|
|
14100
14149
|
style,
|
|
14101
14150
|
align,
|
|
14102
14151
|
onClick: (e) => this.props.onClick && this.props.onClick(e, this.componentRef)
|
|
14103
14152
|
},
|
|
14104
|
-
label ? /* @__PURE__ */ React.createElement(
|
|
14105
|
-
|
|
14153
|
+
label ? /* @__PURE__ */ React.createElement(
|
|
14154
|
+
"div",
|
|
14155
|
+
{
|
|
14156
|
+
className: `nut-cell-title ${this.getClassNameWithDirection("nut-form-item-label")}`
|
|
14157
|
+
},
|
|
14158
|
+
renderLabel
|
|
14159
|
+
) : null,
|
|
14160
|
+
/* @__PURE__ */ React.createElement(
|
|
14106
14161
|
"div",
|
|
14107
14162
|
{
|
|
14108
|
-
className: "nut-form-item-body
|
|
14109
|
-
style: { textAlign: errorMessageAlign }
|
|
14163
|
+
className: `nut-cell-value ${this.getClassNameWithDirection("nut-form-item-body")}`
|
|
14110
14164
|
},
|
|
14111
|
-
item
|
|
14112
|
-
|
|
14165
|
+
/* @__PURE__ */ React.createElement("div", { className: "nut-form-item-body-slots" }, childNode),
|
|
14166
|
+
item && item.length > 0 && /* @__PURE__ */ React.createElement(
|
|
14167
|
+
"div",
|
|
14168
|
+
{
|
|
14169
|
+
className: "nut-form-item-body-tips",
|
|
14170
|
+
style: { textAlign: errorMessageAlign }
|
|
14171
|
+
},
|
|
14172
|
+
item[0].message
|
|
14173
|
+
)
|
|
14174
|
+
)
|
|
14113
14175
|
);
|
|
14114
14176
|
};
|
|
14115
14177
|
this.componentRef = React.createRef();
|
|
@@ -14118,14 +14180,14 @@
|
|
|
14118
14180
|
};
|
|
14119
14181
|
}
|
|
14120
14182
|
componentDidMount() {
|
|
14121
|
-
const { store = {}, setInitialValues } = this.context.getInternal(SECRET);
|
|
14183
|
+
const { store = {}, setInitialValues } = this.context.formInstance.getInternal(SECRET);
|
|
14122
14184
|
if (this.props.initialValue && this.props.name && !Object.keys(store).includes(this.props.name)) {
|
|
14123
14185
|
setInitialValues(
|
|
14124
14186
|
{ ...store, [this.props.name]: this.props.initialValue },
|
|
14125
14187
|
true
|
|
14126
14188
|
);
|
|
14127
14189
|
}
|
|
14128
|
-
const { registerField, registerUpdate } = this.context.getInternal(SECRET);
|
|
14190
|
+
const { registerField, registerUpdate } = this.context.formInstance.getInternal(SECRET);
|
|
14129
14191
|
this.cancelRegister = registerField(this);
|
|
14130
14192
|
this.eventOff = registerUpdate(this, this.props.shouldUpdate);
|
|
14131
14193
|
}
|
|
@@ -14137,6 +14199,12 @@
|
|
|
14137
14199
|
this.eventOff();
|
|
14138
14200
|
}
|
|
14139
14201
|
}
|
|
14202
|
+
getClassNameWithDirection(className) {
|
|
14203
|
+
if (className && this.context.labelPosition) {
|
|
14204
|
+
return `${className} ${className}-${this.context.labelPosition}`;
|
|
14205
|
+
}
|
|
14206
|
+
return className;
|
|
14207
|
+
}
|
|
14140
14208
|
render() {
|
|
14141
14209
|
const { children } = this.props;
|
|
14142
14210
|
const child = Array.isArray(children) ? children[0] : children;
|
|
@@ -14147,9 +14215,9 @@
|
|
|
14147
14215
|
this.getControlled(child)
|
|
14148
14216
|
);
|
|
14149
14217
|
} else {
|
|
14150
|
-
returnChildNode = child(this.context);
|
|
14218
|
+
returnChildNode = child(this.context.formInstance);
|
|
14151
14219
|
}
|
|
14152
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, { key: this.state.resetCount }, this.props.noStyle ? returnChildNode : this.renderLayout(returnChildNode));
|
|
14220
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, { key: this.state.resetCount }, /* @__PURE__ */ React.createElement("div", { className: this.context.disabled ? "nut-form-item-disabled" : "" }, this.props.noStyle ? returnChildNode : this.renderLayout(returnChildNode)));
|
|
14153
14221
|
}
|
|
14154
14222
|
};
|
|
14155
14223
|
_FormItem.defaultProps = defaultProps$W;
|
|
@@ -16902,6 +16970,7 @@
|
|
|
16902
16970
|
}
|
|
16903
16971
|
};
|
|
16904
16972
|
const readFile = (files) => {
|
|
16973
|
+
const results = [];
|
|
16905
16974
|
files.forEach((file, index) => {
|
|
16906
16975
|
var _a;
|
|
16907
16976
|
const formData = new FormData();
|
|
@@ -16918,13 +16987,14 @@
|
|
|
16918
16987
|
const reader = new FileReader();
|
|
16919
16988
|
reader.onload = (event) => {
|
|
16920
16989
|
fileItem.url = event.target.result;
|
|
16921
|
-
|
|
16990
|
+
results.push(fileItem);
|
|
16922
16991
|
};
|
|
16923
16992
|
reader.readAsDataURL(file);
|
|
16924
16993
|
} else {
|
|
16925
|
-
|
|
16994
|
+
results.push(fileItem);
|
|
16926
16995
|
}
|
|
16927
16996
|
});
|
|
16997
|
+
setFileList([...fileList, ...results]);
|
|
16928
16998
|
};
|
|
16929
16999
|
const filterFiles = (files) => {
|
|
16930
17000
|
const maximum = maxCount * 1;
|
|
@@ -17596,6 +17666,12 @@
|
|
|
17596
17666
|
);
|
|
17597
17667
|
};
|
|
17598
17668
|
Drag.displayName = "NutDrag";
|
|
17669
|
+
const getButtonType = (actions, index) => {
|
|
17670
|
+
if (!actions || actions.length === 0) return "default";
|
|
17671
|
+
const action = actions[index];
|
|
17672
|
+
if (action.type) return action.type;
|
|
17673
|
+
return actions.length > 1 && index === 0 ? "default" : "primary";
|
|
17674
|
+
};
|
|
17599
17675
|
const defaultStatus = {
|
|
17600
17676
|
empty: "https://storage.360buyimg.com/imgtools/30186cfda0-0d3eee40-c0ac-11ee-9382-9125782aa3b8.png",
|
|
17601
17677
|
error: "https://storage.360buyimg.com/imgtools/f3278d0ebb-0ce360c0-c0ac-11ee-8375-193101bb1a46.png",
|
|
@@ -17659,10 +17735,13 @@
|
|
|
17659
17735
|
[`${classPrefix$e}-actions-right`]: actions.length === 1,
|
|
17660
17736
|
[`${classPrefix$e}-actions-left`]: actions.length > 1 && index === 0
|
|
17661
17737
|
}),
|
|
17662
|
-
|
|
17663
|
-
|
|
17664
|
-
|
|
17665
|
-
|
|
17738
|
+
style: item.style,
|
|
17739
|
+
type: getButtonType(actions, index),
|
|
17740
|
+
size: item.size || "small",
|
|
17741
|
+
fill: item.fill || "outline",
|
|
17742
|
+
disabled: item.disabled || false,
|
|
17743
|
+
key: `action-${index}`,
|
|
17744
|
+
onClick: item.onClick || (() => void 0)
|
|
17666
17745
|
},
|
|
17667
17746
|
item == null ? void 0 : item.text
|
|
17668
17747
|
);
|
|
@@ -20576,7 +20655,7 @@
|
|
|
20576
20655
|
}
|
|
20577
20656
|
};
|
|
20578
20657
|
const classPrefix$4 = `nut-video`;
|
|
20579
|
-
const Video = (props) => {
|
|
20658
|
+
const Video = React.forwardRef((props, ref) => {
|
|
20580
20659
|
const {
|
|
20581
20660
|
children,
|
|
20582
20661
|
source,
|
|
@@ -20621,6 +20700,18 @@
|
|
|
20621
20700
|
});
|
|
20622
20701
|
}
|
|
20623
20702
|
};
|
|
20703
|
+
const pause = () => {
|
|
20704
|
+
var _a;
|
|
20705
|
+
(_a = rootRef == null ? void 0 : rootRef.current) == null ? void 0 : _a.pause();
|
|
20706
|
+
};
|
|
20707
|
+
const play = () => {
|
|
20708
|
+
var _a;
|
|
20709
|
+
(_a = rootRef == null ? void 0 : rootRef.current) == null ? void 0 : _a.play();
|
|
20710
|
+
};
|
|
20711
|
+
React.useImperativeHandle(ref, () => ({
|
|
20712
|
+
pause,
|
|
20713
|
+
play
|
|
20714
|
+
}));
|
|
20624
20715
|
return /* @__PURE__ */ React.createElement("div", { className: classes, ...restProps }, /* @__PURE__ */ React.createElement(
|
|
20625
20716
|
"video",
|
|
20626
20717
|
{
|
|
@@ -20636,7 +20727,7 @@
|
|
|
20636
20727
|
/* @__PURE__ */ React.createElement("source", { src: source.src, type: source.type }),
|
|
20637
20728
|
/* @__PURE__ */ React.createElement("track", { kind: "captions" })
|
|
20638
20729
|
));
|
|
20639
|
-
};
|
|
20730
|
+
});
|
|
20640
20731
|
Video.displayName = "NutVideo";
|
|
20641
20732
|
const defaultProps$i = {
|
|
20642
20733
|
total: 3,
|