@nutui/nutui-react 2.0.15 → 2.0.17-beta.0
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 +28 -0
- package/dist/esm/Audio.js +1 -2
- package/dist/esm/Avatar.js +2 -2
- package/dist/esm/AvatarGroup.js +1 -1
- package/dist/esm/Cell.js +5 -3
- package/dist/esm/CellGroup.js +6 -1
- package/dist/esm/Dialog.js +4 -3
- package/dist/esm/Form/style/style.css +1 -1
- package/dist/esm/Form.js +65 -10
- package/dist/esm/FormItem/style/style.css +1 -1
- package/dist/esm/InputNumber.js +2 -2
- package/dist/esm/Picker.js +4 -6
- package/dist/esm/SideNavBar.js +1 -1
- package/dist/esm/Step.js +1 -1
- package/dist/esm/Steps.js +1 -1
- package/dist/esm/SubSideNavBar.js +1 -1
- package/dist/esm/Swiper.js +1 -1
- package/dist/esm/SwiperItem.js +1 -1
- package/dist/esm/Table.js +4 -4
- package/dist/esm/VirtualList.js +3 -4
- package/dist/esm/cascader2.js +3 -3
- package/dist/esm/context.js +2 -16
- package/dist/esm/context2.js +16 -2
- package/dist/esm/context3.js +2 -2
- package/dist/esm/context5.js +5 -0
- package/dist/esm/formitem2.js +29 -9
- package/dist/esm/overlay2.js +4 -1
- package/dist/esm/popup2.js +3 -0
- package/dist/esm/types/src/packages/cascader/cascader.d.ts +2 -1
- package/dist/esm/types/src/packages/cascader/cascader.taro.d.ts +2 -1
- package/dist/esm/types/src/packages/cellgroup/context.d.ts +5 -0
- package/dist/esm/types/src/packages/dialog/config.d.ts +2 -1
- package/dist/esm/types/src/packages/dialog/content.taro.d.ts +2 -1
- package/dist/esm/types/src/packages/form/form.d.ts +4 -8
- package/dist/esm/types/src/packages/form/form.taro.d.ts +4 -8
- package/dist/esm/types/src/packages/form/index.d.ts +11 -2
- package/dist/esm/types/src/packages/form/index.taro.d.ts +11 -2
- package/dist/esm/types/src/packages/form/types.d.ts +2 -0
- package/dist/esm/types/src/packages/formitem/formitem.d.ts +1 -0
- package/dist/esm/types/src/packages/formitem/formitem.taro.d.ts +1 -0
- package/dist/esm/types/src/packages/swipe/swipe.taro.d.ts +5 -4
- package/dist/esm/types/src/packages/table/types.d.ts +1 -1
- package/dist/esm/types/src/packages/toast/toast.taro.d.ts +3 -6
- package/dist/esm/types/src/packages/virtuallist/utils.d.ts +1 -1
- package/dist/esm/types/src/utils/get-rect-by-taro.d.ts +12 -0
- package/dist/esm/types/src/utils/use-client-rect.d.ts +3 -9
- package/dist/esm/types/src/utils/use-custom-event.d.ts +1 -1
- package/dist/esm/types/src/utils/use-uuid.d.ts +1 -0
- package/dist/locales/src/locales/base.js +5 -0
- package/dist/locales/{en-US.js → src/locales/en-US.js} +1 -1
- package/dist/locales/{id-ID.js → src/locales/id-ID.js} +1 -1
- package/dist/locales/{tr-TR.js → src/locales/tr-TR.js} +1 -1
- package/dist/locales/{zh-CN.js → src/locales/zh-CN.js} +1 -1
- package/dist/locales/{zh-TW.js → src/locales/zh-TW.js} +1 -1
- package/dist/locales/{zh-UG.js → src/locales/zh-UG.js} +1 -1
- package/dist/nutui.react.es.js +254 -127
- package/dist/nutui.react.umd.js +254 -127
- package/dist/packages/form/form.scss +9 -1
- package/dist/packages/formitem/formitem.scss +0 -11
- package/dist/style.css +1 -1
- package/dist/style.mjs +1 -1
- package/dist/types/packages/cascader/cascader.d.ts +2 -1
- package/dist/types/packages/cellgroup/context.d.ts +5 -0
- package/dist/types/packages/dialog/config.d.ts +2 -1
- package/dist/types/packages/form/form.d.ts +4 -8
- package/dist/types/packages/form/index.d.ts +11 -2
- package/dist/types/packages/form/types.d.ts +2 -0
- package/dist/types/packages/formitem/formitem.d.ts +5 -0
- package/dist/types/packages/table/types.d.ts +1 -1
- package/dist/types/packages/virtuallist/utils.d.ts +1 -1
- package/dist/types/utils/use-client-rect.d.ts +3 -9
- package/package.json +1 -1
- package/dist/locales/base.js +0 -5
package/dist/nutui.react.es.js
CHANGED
|
@@ -6,7 +6,7 @@ var __publicField = (obj, key, value) => {
|
|
|
6
6
|
};
|
|
7
7
|
var _a;
|
|
8
8
|
/*!
|
|
9
|
-
* @nutui/nutui-react v2.0.
|
|
9
|
+
* @nutui/nutui-react v2.0.17 Wed Sep 13 2023 16:45:40 GMT+0800 (中国标准时间)
|
|
10
10
|
* (c) 2023 @jdf2e.
|
|
11
11
|
* Released under the MIT License.
|
|
12
12
|
*/
|
|
@@ -2523,6 +2523,7 @@ const Button = React__default.forwardRef(
|
|
|
2523
2523
|
}
|
|
2524
2524
|
);
|
|
2525
2525
|
Button.displayName = "NutButton";
|
|
2526
|
+
const CellGroupContext = createContext(null);
|
|
2526
2527
|
const defaultProps$1r = {
|
|
2527
2528
|
...ComponentDefaults,
|
|
2528
2529
|
title: "",
|
|
@@ -2540,7 +2541,7 @@ const CellGroup = (props) => {
|
|
|
2540
2541
|
{
|
|
2541
2542
|
className: `${classPrefix$p}__wrap ${divider ? `${classPrefix$p}__wrap--divider` : ""}`
|
|
2542
2543
|
},
|
|
2543
|
-
children
|
|
2544
|
+
/* @__PURE__ */ React__default.createElement(CellGroupContext.Provider, { value: { divider } }, children)
|
|
2544
2545
|
));
|
|
2545
2546
|
};
|
|
2546
2547
|
CellGroup.defaultProps = defaultProps$1r;
|
|
@@ -2557,6 +2558,7 @@ const defaultProps$1q = {
|
|
|
2557
2558
|
};
|
|
2558
2559
|
const classPrefix$o = "nut-cell";
|
|
2559
2560
|
const Cell = (props) => {
|
|
2561
|
+
const ctx2 = useContext(CellGroupContext);
|
|
2560
2562
|
const {
|
|
2561
2563
|
children,
|
|
2562
2564
|
onClick,
|
|
@@ -2598,7 +2600,8 @@ const Cell = (props) => {
|
|
|
2598
2600
|
style: styles
|
|
2599
2601
|
},
|
|
2600
2602
|
extra
|
|
2601
|
-
) : null,
|
|
2603
|
+
) : null),
|
|
2604
|
+
(ctx2 == null ? void 0 : ctx2.divider) ? /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix$o}__divider` }) : null
|
|
2602
2605
|
);
|
|
2603
2606
|
};
|
|
2604
2607
|
Cell.defaultProps = defaultProps$1q;
|
|
@@ -5671,6 +5674,7 @@ const Overlay = (props) => {
|
|
|
5671
5674
|
};
|
|
5672
5675
|
const [innerVisible, setInnerVisible] = useState(visible);
|
|
5673
5676
|
const classPrefix2 = `nut-overlay`;
|
|
5677
|
+
const nodeRef = useRef(null);
|
|
5674
5678
|
useEffect(() => {
|
|
5675
5679
|
if (visible) {
|
|
5676
5680
|
setInnerVisible(true);
|
|
@@ -5709,6 +5713,7 @@ const Overlay = (props) => {
|
|
|
5709
5713
|
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
|
|
5710
5714
|
CSSTransition$1,
|
|
5711
5715
|
{
|
|
5716
|
+
nodeRef,
|
|
5712
5717
|
classNames: `${classPrefix2}-slide`,
|
|
5713
5718
|
unmountOnExit: true,
|
|
5714
5719
|
timeout: duration,
|
|
@@ -5716,7 +5721,17 @@ const Overlay = (props) => {
|
|
|
5716
5721
|
onEntered: onHandleOpened,
|
|
5717
5722
|
onExited: onHandleClosed
|
|
5718
5723
|
},
|
|
5719
|
-
/* @__PURE__ */ React__default.createElement(
|
|
5724
|
+
/* @__PURE__ */ React__default.createElement(
|
|
5725
|
+
"div",
|
|
5726
|
+
{
|
|
5727
|
+
ref: nodeRef,
|
|
5728
|
+
className: classes,
|
|
5729
|
+
style: styles,
|
|
5730
|
+
...rest,
|
|
5731
|
+
onClick: handleClick2
|
|
5732
|
+
},
|
|
5733
|
+
children
|
|
5734
|
+
)
|
|
5720
5735
|
));
|
|
5721
5736
|
};
|
|
5722
5737
|
Overlay.defaultProps = defaultOverlayProps;
|
|
@@ -11863,6 +11878,7 @@ const Popup = (props) => {
|
|
|
11863
11878
|
afterClose,
|
|
11864
11879
|
onClick
|
|
11865
11880
|
} = { ...defaultProps$1c, ...props };
|
|
11881
|
+
const nodeRef = React__default.useRef(null);
|
|
11866
11882
|
const [index, setIndex] = useState(zIndex || _zIndex);
|
|
11867
11883
|
const [innerVisible, setInnerVisible] = useState(visible);
|
|
11868
11884
|
const [showChildren, setShowChildren] = useState(true);
|
|
@@ -11954,6 +11970,7 @@ const Popup = (props) => {
|
|
|
11954
11970
|
return /* @__PURE__ */ React__default.createElement(
|
|
11955
11971
|
CSSTransition$1,
|
|
11956
11972
|
{
|
|
11973
|
+
nodeRef,
|
|
11957
11974
|
classNames: transitionName,
|
|
11958
11975
|
unmountOnExit: true,
|
|
11959
11976
|
timeout: duration,
|
|
@@ -11961,7 +11978,18 @@ const Popup = (props) => {
|
|
|
11961
11978
|
onEntered: onHandleOpened,
|
|
11962
11979
|
onExited: onHandleClosed
|
|
11963
11980
|
},
|
|
11964
|
-
/* @__PURE__ */ React__default.createElement(
|
|
11981
|
+
/* @__PURE__ */ React__default.createElement(
|
|
11982
|
+
"div",
|
|
11983
|
+
{
|
|
11984
|
+
ref: nodeRef,
|
|
11985
|
+
style: popStyles,
|
|
11986
|
+
className: popClassName,
|
|
11987
|
+
onClick: onHandleClick
|
|
11988
|
+
},
|
|
11989
|
+
renderTitle(),
|
|
11990
|
+
renderIcon(),
|
|
11991
|
+
showChildren ? children : ""
|
|
11992
|
+
)
|
|
11965
11993
|
);
|
|
11966
11994
|
};
|
|
11967
11995
|
const renderNode = () => {
|
|
@@ -12624,6 +12652,7 @@ class Tree {
|
|
|
12624
12652
|
constructor(nodes, config2) {
|
|
12625
12653
|
__publicField(this, "nodes");
|
|
12626
12654
|
__publicField(this, "config");
|
|
12655
|
+
// eslint-disable-next-line class-methods-use-this
|
|
12627
12656
|
__publicField(this, "isLeaf", (node, lazy) => {
|
|
12628
12657
|
const { leaf, children } = node;
|
|
12629
12658
|
const hasChildren = Array.isArray(children) && Boolean(children.length);
|
|
@@ -12713,6 +12742,7 @@ const InternalCascader = (props, ref) => {
|
|
|
12713
12742
|
activeColor,
|
|
12714
12743
|
activeIcon,
|
|
12715
12744
|
popup,
|
|
12745
|
+
popupProps = {},
|
|
12716
12746
|
visible,
|
|
12717
12747
|
options: options2,
|
|
12718
12748
|
value,
|
|
@@ -13008,6 +13038,7 @@ const InternalCascader = (props, ref) => {
|
|
|
13008
13038
|
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, popup ? /* @__PURE__ */ React__default.createElement(
|
|
13009
13039
|
Popup,
|
|
13010
13040
|
{
|
|
13041
|
+
...popupProps,
|
|
13011
13042
|
visible,
|
|
13012
13043
|
position: "bottom",
|
|
13013
13044
|
round: true,
|
|
@@ -14559,7 +14590,7 @@ const InternalPickerPanel = (props, ref) => {
|
|
|
14559
14590
|
}
|
|
14560
14591
|
return false;
|
|
14561
14592
|
};
|
|
14562
|
-
const setTransform = (
|
|
14593
|
+
const setTransform = (type4, deg, time = DEFAULT_DURATION, translateY = 0) => {
|
|
14563
14594
|
let nTime = time;
|
|
14564
14595
|
if (type4 !== "end") {
|
|
14565
14596
|
nTime = 0;
|
|
@@ -14579,7 +14610,7 @@ const InternalPickerPanel = (props, ref) => {
|
|
|
14579
14610
|
}
|
|
14580
14611
|
const endMove = Math.round(updateMove / lineSpacing) * lineSpacing;
|
|
14581
14612
|
const deg = `${(Math.abs(Math.round(endMove / lineSpacing)) + 1) * rotation}deg`;
|
|
14582
|
-
setTransform(
|
|
14613
|
+
setTransform(type4, deg, time, endMove);
|
|
14583
14614
|
setCurrIndex(Math.abs(Math.round(endMove / lineSpacing)) + 1);
|
|
14584
14615
|
} else {
|
|
14585
14616
|
let deg = 0;
|
|
@@ -14588,7 +14619,7 @@ const InternalPickerPanel = (props, ref) => {
|
|
|
14588
14619
|
const minDeg = 0;
|
|
14589
14620
|
deg = Math.min(Math.max(currentDeg, minDeg), maxDeg);
|
|
14590
14621
|
if (minDeg < deg && deg < maxDeg) {
|
|
14591
|
-
setTransform(
|
|
14622
|
+
setTransform("", `${deg}deg`, void 0, updateMove);
|
|
14592
14623
|
setCurrIndex(Math.abs(Math.round(updateMove / lineSpacing)) + 1);
|
|
14593
14624
|
}
|
|
14594
14625
|
}
|
|
@@ -14822,9 +14853,7 @@ const InternalPicker = (props, ref) => {
|
|
|
14822
14853
|
while (columnOptions && columnOptions.children) {
|
|
14823
14854
|
const options22 = columnOptions.children;
|
|
14824
14855
|
const value = values[columnIndex2];
|
|
14825
|
-
let index = options22.findIndex(
|
|
14826
|
-
(columnItem) => columnItem.value === value
|
|
14827
|
-
);
|
|
14856
|
+
let index = options22.findIndex((columnItem) => columnItem.value === value);
|
|
14828
14857
|
if (index === -1)
|
|
14829
14858
|
index = 0;
|
|
14830
14859
|
columnOptions = columnOptions.children[index];
|
|
@@ -16376,7 +16405,7 @@ class FormStore {
|
|
|
16376
16405
|
__publicField(this, "fieldEntities", []);
|
|
16377
16406
|
// 校验成功或失败的回调,onFinish、onFinishFailed
|
|
16378
16407
|
__publicField(this, "callbacks", {});
|
|
16379
|
-
__publicField(this, "errors",
|
|
16408
|
+
__publicField(this, "errors", {});
|
|
16380
16409
|
/**
|
|
16381
16410
|
* 注册组件实例
|
|
16382
16411
|
* @param field
|
|
@@ -16398,6 +16427,19 @@ class FormStore {
|
|
|
16398
16427
|
var _a2;
|
|
16399
16428
|
return (_a2 = this.store) == null ? void 0 : _a2[name];
|
|
16400
16429
|
});
|
|
16430
|
+
/**
|
|
16431
|
+
* 获取全部字段
|
|
16432
|
+
*/
|
|
16433
|
+
__publicField(this, "getFieldsValue", (name) => {
|
|
16434
|
+
if (typeof name === "boolean") {
|
|
16435
|
+
return JSON.parse(JSON.stringify(this.store));
|
|
16436
|
+
}
|
|
16437
|
+
const fieldsValue = {};
|
|
16438
|
+
name.forEach((field) => {
|
|
16439
|
+
fieldsValue[field] = this.getFieldValue(field);
|
|
16440
|
+
});
|
|
16441
|
+
return fieldsValue;
|
|
16442
|
+
});
|
|
16401
16443
|
/**
|
|
16402
16444
|
* 设置 form 的初始值,之后在 reset 的时候使用
|
|
16403
16445
|
* @param values
|
|
@@ -16455,13 +16497,45 @@ class FormStore {
|
|
|
16455
16497
|
validator.validate({ [name]: (_a2 = this.store) == null ? void 0 : _a2[name] }, (errors) => {
|
|
16456
16498
|
if (errors) {
|
|
16457
16499
|
err.push(...errors);
|
|
16458
|
-
this.errors
|
|
16500
|
+
this.errors[name] = errors;
|
|
16459
16501
|
}
|
|
16460
16502
|
entity.onStoreChange("validate");
|
|
16461
16503
|
});
|
|
16462
16504
|
});
|
|
16463
16505
|
return err;
|
|
16464
16506
|
});
|
|
16507
|
+
__publicField(this, "validateFields", (nameList) => {
|
|
16508
|
+
if (!nameList || nameList.length === 0) {
|
|
16509
|
+
this.validate();
|
|
16510
|
+
return;
|
|
16511
|
+
}
|
|
16512
|
+
this.fieldEntities.filter(({ props: { name } }) => {
|
|
16513
|
+
return nameList.includes(name);
|
|
16514
|
+
}).forEach((entity) => {
|
|
16515
|
+
var _a2;
|
|
16516
|
+
const { name, rules: rules2 = [] } = entity.props;
|
|
16517
|
+
const descriptor = {};
|
|
16518
|
+
if (rules2.length) {
|
|
16519
|
+
if (rules2.length > 1) {
|
|
16520
|
+
descriptor[name] = [];
|
|
16521
|
+
rules2.forEach((v) => {
|
|
16522
|
+
descriptor[name].push(v);
|
|
16523
|
+
});
|
|
16524
|
+
} else {
|
|
16525
|
+
descriptor[name] = rules2[0];
|
|
16526
|
+
}
|
|
16527
|
+
}
|
|
16528
|
+
const validator = new Schema(descriptor);
|
|
16529
|
+
validator.messages();
|
|
16530
|
+
validator.validate({ [name]: (_a2 = this.store) == null ? void 0 : _a2[name] }, (errors) => {
|
|
16531
|
+
this.errors[name] = [];
|
|
16532
|
+
if (errors) {
|
|
16533
|
+
this.errors[name] = errors;
|
|
16534
|
+
}
|
|
16535
|
+
entity.onStoreChange("validate");
|
|
16536
|
+
});
|
|
16537
|
+
});
|
|
16538
|
+
});
|
|
16465
16539
|
__publicField(this, "submit", () => {
|
|
16466
16540
|
var _a2, _b, _c, _d;
|
|
16467
16541
|
const errors = this.validate();
|
|
@@ -16478,12 +16552,17 @@ class FormStore {
|
|
|
16478
16552
|
entity.onStoreChange("reset");
|
|
16479
16553
|
});
|
|
16480
16554
|
});
|
|
16555
|
+
__publicField(this, "dispatch", ({ name }) => {
|
|
16556
|
+
this.validateFields([name]);
|
|
16557
|
+
});
|
|
16481
16558
|
__publicField(this, "getForm", () => {
|
|
16482
16559
|
return {
|
|
16560
|
+
dispatch: this.dispatch,
|
|
16483
16561
|
setInitialValues: this.setInitialValues,
|
|
16484
16562
|
setCallback: this.setCallback,
|
|
16485
16563
|
registerField: this.registerField,
|
|
16486
16564
|
getFieldValue: this.getFieldValue,
|
|
16565
|
+
getFieldsValue: this.getFieldsValue,
|
|
16487
16566
|
setFieldsValue: this.setFieldsValue,
|
|
16488
16567
|
resetFields: this.resetFields,
|
|
16489
16568
|
submit: this.submit,
|
|
@@ -16512,6 +16591,84 @@ const useForm = (form) => {
|
|
|
16512
16591
|
}
|
|
16513
16592
|
return [formRef.current];
|
|
16514
16593
|
};
|
|
16594
|
+
const defaultProps$W = {
|
|
16595
|
+
...ComponentDefaults,
|
|
16596
|
+
labelPosition: "right",
|
|
16597
|
+
starPosition: "left",
|
|
16598
|
+
divider: false,
|
|
16599
|
+
onFinish: (values) => {
|
|
16600
|
+
},
|
|
16601
|
+
onFinishFailed: (values, errorFields) => {
|
|
16602
|
+
}
|
|
16603
|
+
};
|
|
16604
|
+
const PositionInfo = {
|
|
16605
|
+
top: "form-layout-top",
|
|
16606
|
+
left: "form-layout-left",
|
|
16607
|
+
right: "form-layout-right"
|
|
16608
|
+
};
|
|
16609
|
+
const Form = React__default.forwardRef(
|
|
16610
|
+
(props, ref) => {
|
|
16611
|
+
const classPrefix2 = "nut-form";
|
|
16612
|
+
const {
|
|
16613
|
+
className,
|
|
16614
|
+
style,
|
|
16615
|
+
footer,
|
|
16616
|
+
children,
|
|
16617
|
+
initialValues,
|
|
16618
|
+
divider,
|
|
16619
|
+
onFinish,
|
|
16620
|
+
onFinishFailed,
|
|
16621
|
+
labelPosition,
|
|
16622
|
+
starPosition,
|
|
16623
|
+
form
|
|
16624
|
+
} = {
|
|
16625
|
+
...defaultProps$W,
|
|
16626
|
+
...props
|
|
16627
|
+
};
|
|
16628
|
+
let formInstance;
|
|
16629
|
+
if (form !== void 0) {
|
|
16630
|
+
formInstance = form;
|
|
16631
|
+
} else {
|
|
16632
|
+
[formInstance] = useForm();
|
|
16633
|
+
}
|
|
16634
|
+
React__default.useImperativeHandle(ref, () => formInstance);
|
|
16635
|
+
formInstance.starPosition = starPosition;
|
|
16636
|
+
const { setCallback, submit, resetFields, setInitialValues } = formInstance;
|
|
16637
|
+
setCallback({
|
|
16638
|
+
onFinish,
|
|
16639
|
+
onFinishFailed
|
|
16640
|
+
});
|
|
16641
|
+
const mountRef = React__default.useRef(false);
|
|
16642
|
+
setInitialValues(initialValues, !mountRef.current);
|
|
16643
|
+
if (!mountRef.current) {
|
|
16644
|
+
mountRef.current = true;
|
|
16645
|
+
}
|
|
16646
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
16647
|
+
"form",
|
|
16648
|
+
{
|
|
16649
|
+
className: classNames(
|
|
16650
|
+
classPrefix2,
|
|
16651
|
+
className,
|
|
16652
|
+
PositionInfo[labelPosition]
|
|
16653
|
+
),
|
|
16654
|
+
style,
|
|
16655
|
+
onSubmit: (e) => {
|
|
16656
|
+
e.preventDefault();
|
|
16657
|
+
e.stopPropagation();
|
|
16658
|
+
submit();
|
|
16659
|
+
},
|
|
16660
|
+
onReset: (e) => {
|
|
16661
|
+
e.preventDefault();
|
|
16662
|
+
e.stopPropagation();
|
|
16663
|
+
resetFields();
|
|
16664
|
+
}
|
|
16665
|
+
},
|
|
16666
|
+
/* @__PURE__ */ React__default.createElement(Cell.Group, { divider }, /* @__PURE__ */ React__default.createElement(Context.Provider, { value: formInstance }, children), footer ? /* @__PURE__ */ React__default.createElement(Cell, null, footer) : null)
|
|
16667
|
+
);
|
|
16668
|
+
}
|
|
16669
|
+
);
|
|
16670
|
+
Form.defaultProps = defaultProps$W;
|
|
16671
|
+
Form.displayName = "NutForm";
|
|
16515
16672
|
function isForwardRefComponent(component) {
|
|
16516
16673
|
return component.type && component.type.$$typeof && // eslint-disable-next-line react/display-name
|
|
16517
16674
|
React__default.forwardRef(
|
|
@@ -16521,13 +16678,14 @@ function isForwardRefComponent(component) {
|
|
|
16521
16678
|
}
|
|
16522
16679
|
).$$typeof === component.type.$$typeof;
|
|
16523
16680
|
}
|
|
16524
|
-
const defaultProps$
|
|
16681
|
+
const defaultProps$V = {
|
|
16525
16682
|
...ComponentDefaults,
|
|
16526
16683
|
required: false,
|
|
16527
16684
|
name: "",
|
|
16528
16685
|
label: "",
|
|
16529
16686
|
rules: [{ required: false, message: "" }],
|
|
16530
|
-
errorMessageAlign: "left"
|
|
16687
|
+
errorMessageAlign: "left",
|
|
16688
|
+
validateTrigger: "onChange"
|
|
16531
16689
|
};
|
|
16532
16690
|
class FormItem extends React__default.Component {
|
|
16533
16691
|
constructor(props) {
|
|
@@ -16537,7 +16695,7 @@ class FormItem extends React__default.Component {
|
|
|
16537
16695
|
// children添加value属性和onChange事件
|
|
16538
16696
|
__publicField(this, "getControlled", (children) => {
|
|
16539
16697
|
var _a2;
|
|
16540
|
-
const { setFieldsValue, getFieldValue } = this.context;
|
|
16698
|
+
const { setFieldsValue, getFieldValue, dispatch } = this.context;
|
|
16541
16699
|
const { name = "" } = this.props;
|
|
16542
16700
|
if ((_a2 = children == null ? void 0 : children.props) == null ? void 0 : _a2.defaultValue) {
|
|
16543
16701
|
console.warn("通过 initialValue 设置初始值");
|
|
@@ -16558,6 +16716,24 @@ class FormItem extends React__default.Component {
|
|
|
16558
16716
|
setFieldsValue({ [name]: next });
|
|
16559
16717
|
}
|
|
16560
16718
|
};
|
|
16719
|
+
const { validateTrigger } = this.props;
|
|
16720
|
+
let validateTriggers = [this.props.trigger || "onChange"];
|
|
16721
|
+
if (validateTrigger) {
|
|
16722
|
+
validateTriggers = typeof validateTrigger === "string" ? [...validateTriggers, validateTrigger] : [...validateTriggers, ...validateTrigger];
|
|
16723
|
+
validateTriggers.forEach((trigger) => {
|
|
16724
|
+
const originTrigger = controlled[trigger];
|
|
16725
|
+
controlled[trigger] = (...args) => {
|
|
16726
|
+
if (originTrigger) {
|
|
16727
|
+
originTrigger(...args);
|
|
16728
|
+
}
|
|
16729
|
+
if (this.props.rules && this.props.rules.length) {
|
|
16730
|
+
dispatch({
|
|
16731
|
+
name: this.props.name
|
|
16732
|
+
});
|
|
16733
|
+
}
|
|
16734
|
+
};
|
|
16735
|
+
});
|
|
16736
|
+
}
|
|
16561
16737
|
if (isForwardRefComponent(children)) {
|
|
16562
16738
|
controlled.ref = (componentInstance) => {
|
|
16563
16739
|
const originRef = children.ref;
|
|
@@ -16587,16 +16763,22 @@ class FormItem extends React__default.Component {
|
|
|
16587
16763
|
}
|
|
16588
16764
|
});
|
|
16589
16765
|
__publicField(this, "renderLayout", (childNode) => {
|
|
16590
|
-
|
|
16591
|
-
|
|
16592
|
-
|
|
16766
|
+
const {
|
|
16767
|
+
label,
|
|
16768
|
+
name,
|
|
16769
|
+
required: required4,
|
|
16770
|
+
rules: rules2,
|
|
16771
|
+
className,
|
|
16772
|
+
style,
|
|
16773
|
+
errorMessageAlign
|
|
16774
|
+
} = {
|
|
16775
|
+
...defaultProps$V,
|
|
16593
16776
|
...this.props
|
|
16594
16777
|
};
|
|
16595
|
-
const
|
|
16596
|
-
|
|
16597
|
-
}));
|
|
16778
|
+
const requiredInRules = rules2 == null ? void 0 : rules2.some((rule) => rule.required);
|
|
16779
|
+
const item = name ? this.context.errors[name] : [];
|
|
16598
16780
|
const { starPosition } = this.context;
|
|
16599
|
-
const renderStar = required4 && /* @__PURE__ */ React__default.createElement("i", { className: "required" });
|
|
16781
|
+
const renderStar = (required4 || requiredInRules) && /* @__PURE__ */ React__default.createElement("i", { className: "required" });
|
|
16600
16782
|
const renderLabel = /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, starPosition === "left" ? renderStar : null, label, starPosition === "right" ? renderStar : null);
|
|
16601
16783
|
return /* @__PURE__ */ React__default.createElement(
|
|
16602
16784
|
Cell,
|
|
@@ -16606,7 +16788,7 @@ class FormItem extends React__default.Component {
|
|
|
16606
16788
|
onClick: (e) => this.props.onClick && this.props.onClick(e, this.componentRef)
|
|
16607
16789
|
},
|
|
16608
16790
|
label ? /* @__PURE__ */ React__default.createElement("div", { className: "nut-cell__title nut-form-item__label" }, renderLabel) : null,
|
|
16609
|
-
/* @__PURE__ */ React__default.createElement("div", { className: "nut-cell__value nut-form-item__body" }, /* @__PURE__ */ React__default.createElement("div", { className: "nut-form-item__body__slots" }, childNode), item.length > 0 && /* @__PURE__ */ React__default.createElement(
|
|
16791
|
+
/* @__PURE__ */ React__default.createElement("div", { className: "nut-cell__value nut-form-item__body" }, /* @__PURE__ */ React__default.createElement("div", { className: "nut-form-item__body__slots" }, childNode), item && item.length > 0 && /* @__PURE__ */ React__default.createElement(
|
|
16610
16792
|
"div",
|
|
16611
16793
|
{
|
|
16612
16794
|
className: "nut-form-item__body__tips",
|
|
@@ -16639,83 +16821,11 @@ class FormItem extends React__default.Component {
|
|
|
16639
16821
|
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, { key: this.state.resetCount }, this.renderLayout(returnChildNode));
|
|
16640
16822
|
}
|
|
16641
16823
|
}
|
|
16642
|
-
__publicField(FormItem, "defaultProps", defaultProps$
|
|
16824
|
+
__publicField(FormItem, "defaultProps", defaultProps$V);
|
|
16643
16825
|
__publicField(FormItem, "contextType", Context);
|
|
16644
|
-
const
|
|
16645
|
-
|
|
16646
|
-
|
|
16647
|
-
starPosition: "left",
|
|
16648
|
-
onFinish: (values) => {
|
|
16649
|
-
},
|
|
16650
|
-
onFinishFailed: (values, errorFields) => {
|
|
16651
|
-
}
|
|
16652
|
-
};
|
|
16653
|
-
const PositionInfo = {
|
|
16654
|
-
top: "form-layout-top",
|
|
16655
|
-
left: "form-layout-left",
|
|
16656
|
-
right: "form-layout-right"
|
|
16657
|
-
};
|
|
16658
|
-
const Form = (props) => {
|
|
16659
|
-
const classPrefix2 = "nut-form";
|
|
16660
|
-
const {
|
|
16661
|
-
className,
|
|
16662
|
-
style,
|
|
16663
|
-
footer,
|
|
16664
|
-
children,
|
|
16665
|
-
initialValues,
|
|
16666
|
-
onFinish,
|
|
16667
|
-
onFinishFailed,
|
|
16668
|
-
labelPosition,
|
|
16669
|
-
starPosition,
|
|
16670
|
-
form
|
|
16671
|
-
} = {
|
|
16672
|
-
...defaultProps$V,
|
|
16673
|
-
...props
|
|
16674
|
-
};
|
|
16675
|
-
let formInstance;
|
|
16676
|
-
if (form !== void 0) {
|
|
16677
|
-
formInstance = form;
|
|
16678
|
-
} else {
|
|
16679
|
-
[formInstance] = useForm();
|
|
16680
|
-
}
|
|
16681
|
-
formInstance.starPosition = starPosition;
|
|
16682
|
-
const { setCallback, submit, resetFields, setInitialValues } = formInstance;
|
|
16683
|
-
setCallback({
|
|
16684
|
-
onFinish,
|
|
16685
|
-
onFinishFailed
|
|
16686
|
-
});
|
|
16687
|
-
const mountRef = React__default.useRef(false);
|
|
16688
|
-
setInitialValues(initialValues, !mountRef.current);
|
|
16689
|
-
if (!mountRef.current) {
|
|
16690
|
-
mountRef.current = true;
|
|
16691
|
-
}
|
|
16692
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
16693
|
-
"form",
|
|
16694
|
-
{
|
|
16695
|
-
className: classNames(
|
|
16696
|
-
classPrefix2,
|
|
16697
|
-
className,
|
|
16698
|
-
PositionInfo[labelPosition]
|
|
16699
|
-
),
|
|
16700
|
-
style,
|
|
16701
|
-
onSubmit: (e) => {
|
|
16702
|
-
e.preventDefault();
|
|
16703
|
-
e.stopPropagation();
|
|
16704
|
-
submit();
|
|
16705
|
-
},
|
|
16706
|
-
onReset: (e) => {
|
|
16707
|
-
e.preventDefault();
|
|
16708
|
-
e.stopPropagation();
|
|
16709
|
-
resetFields();
|
|
16710
|
-
}
|
|
16711
|
-
},
|
|
16712
|
-
/* @__PURE__ */ React__default.createElement(Cell.Group, null, /* @__PURE__ */ React__default.createElement(Context.Provider, { value: formInstance }, children), footer ? /* @__PURE__ */ React__default.createElement(Cell, null, footer) : null)
|
|
16713
|
-
);
|
|
16714
|
-
};
|
|
16715
|
-
Form.defaultProps = defaultProps$V;
|
|
16716
|
-
Form.displayName = "NutForm";
|
|
16717
|
-
Form.Item = FormItem;
|
|
16718
|
-
Form.useForm = useForm;
|
|
16826
|
+
const InnerForm = Form;
|
|
16827
|
+
InnerForm.Item = FormItem;
|
|
16828
|
+
InnerForm.useForm = useForm;
|
|
16719
16829
|
function trimExtraChar(value, char, regExp) {
|
|
16720
16830
|
const index = value.indexOf(char);
|
|
16721
16831
|
if (index === -1) {
|
|
@@ -17066,7 +17176,7 @@ const InputNumber = (props) => {
|
|
|
17066
17176
|
};
|
|
17067
17177
|
const changeFormatValue = (e) => {
|
|
17068
17178
|
const input = e.target.value;
|
|
17069
|
-
const numReg =
|
|
17179
|
+
const numReg = /^[0-9]*$/;
|
|
17070
17180
|
const numValue = input.replace(/[^0-9|.]/gi, "");
|
|
17071
17181
|
if (formatter) {
|
|
17072
17182
|
if (!numReg.test(input[0]) && numValue) {
|
|
@@ -17085,7 +17195,7 @@ const InputNumber = (props) => {
|
|
|
17085
17195
|
};
|
|
17086
17196
|
const burFormatValue = (e) => {
|
|
17087
17197
|
const input = e.target.value;
|
|
17088
|
-
const numReg =
|
|
17198
|
+
const numReg = /^[0-9]*$/;
|
|
17089
17199
|
const numValue = input.replace(/[^0-9|.]/gi, "");
|
|
17090
17200
|
if (formatter) {
|
|
17091
17201
|
if (formatter(numValue) === input) {
|
|
@@ -18669,7 +18779,9 @@ const InternalSignature = (props, ref) => {
|
|
|
18669
18779
|
}));
|
|
18670
18780
|
return /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2} ${className}`, style, ...rest }, /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}__inner`, ref: wrapRef }, /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, isCanvasSupported ? /* @__PURE__ */ React__default.createElement("canvas", { ref: canvasRef, height: canvasHeight, width: canvasWidth }) : unsupported ? /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, unsupported) : /* @__PURE__ */ React__default.createElement("p", { className: `${classPrefix2}__unsupport` }, locale.signature.unsupported))));
|
|
18671
18781
|
};
|
|
18672
|
-
const Signature = React__default.forwardRef(
|
|
18782
|
+
const Signature = React__default.forwardRef(
|
|
18783
|
+
InternalSignature
|
|
18784
|
+
);
|
|
18673
18785
|
Signature.defaultProps = defaultProps$J;
|
|
18674
18786
|
Signature.displayName = "NutSignature";
|
|
18675
18787
|
const defaultProps$I = {
|
|
@@ -19709,16 +19821,24 @@ const Content = (props) => {
|
|
|
19709
19821
|
const handleClick2 = (e) => {
|
|
19710
19822
|
onClick && onClick(e);
|
|
19711
19823
|
};
|
|
19712
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
19824
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
19713
19825
|
"div",
|
|
19714
19826
|
{
|
|
19715
|
-
className: classPrefix2,
|
|
19716
|
-
style:
|
|
19827
|
+
className: classNames(`${classPrefix2}__outer`, props.className),
|
|
19828
|
+
style: props.style,
|
|
19829
|
+
onClick: (e) => handleClick2(e)
|
|
19717
19830
|
},
|
|
19718
|
-
|
|
19719
|
-
|
|
19720
|
-
|
|
19721
|
-
|
|
19831
|
+
/* @__PURE__ */ React__default.createElement(
|
|
19832
|
+
"div",
|
|
19833
|
+
{
|
|
19834
|
+
className: classPrefix2,
|
|
19835
|
+
style: { display: visible ? "flex" : "none" }
|
|
19836
|
+
},
|
|
19837
|
+
renderHeader(),
|
|
19838
|
+
/* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}__content` }, /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, children)),
|
|
19839
|
+
renderFooter()
|
|
19840
|
+
)
|
|
19841
|
+
);
|
|
19722
19842
|
};
|
|
19723
19843
|
Content.displayName = "NutContent";
|
|
19724
19844
|
const defaultDialogProps = {
|
|
@@ -19777,6 +19897,7 @@ const DialogWrap = (props) => {
|
|
|
19777
19897
|
DialogWrap.defaultProps = defaultDialogProps;
|
|
19778
19898
|
DialogWrap.displayName = "NutDialogWrap";
|
|
19779
19899
|
const defaultProps$D = {
|
|
19900
|
+
...ComponentDefaults,
|
|
19780
19901
|
confirmText: "",
|
|
19781
19902
|
cancelText: "",
|
|
19782
19903
|
overlay: true,
|
|
@@ -20437,10 +20558,13 @@ const NoticeBar = (props) => {
|
|
|
20437
20558
|
if (childCount <= 1)
|
|
20438
20559
|
return;
|
|
20439
20560
|
stopAutoPlay();
|
|
20440
|
-
swiperRef.current.autoplayTimer = setTimeout(
|
|
20441
|
-
|
|
20442
|
-
|
|
20443
|
-
|
|
20561
|
+
swiperRef.current.autoplayTimer = setTimeout(
|
|
20562
|
+
() => {
|
|
20563
|
+
next();
|
|
20564
|
+
autoplay();
|
|
20565
|
+
},
|
|
20566
|
+
Number(duration) + 100 * speed
|
|
20567
|
+
);
|
|
20444
20568
|
};
|
|
20445
20569
|
const move = ({ pace = 0, offset: offset2 = 0 }) => {
|
|
20446
20570
|
if (childCount <= 1)
|
|
@@ -21343,7 +21467,7 @@ const Avatar = (props) => {
|
|
|
21343
21467
|
...icon.props,
|
|
21344
21468
|
className: `${icon.props.className || ""} icon`
|
|
21345
21469
|
}) : null, children && /* @__PURE__ */ React__default.createElement("span", { className: "text" }, children), !src && !icon && !children && /* @__PURE__ */ React__default.createElement(k$2, { className: "icon" })),
|
|
21346
|
-
showMax && /* @__PURE__ */ React__default.createElement("div", { className: "text" }, ((_l = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _l.maxContent) ? (_m = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _m.maxContent : `+ ${avatarIndex - ((_n = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _n.max)}`)
|
|
21470
|
+
showMax && /* @__PURE__ */ React__default.createElement("div", { className: "text" }, ((_l = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _l.maxContent) ? (_m = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _m.maxContent : `+ ${avatarIndex - Number(((_n = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _n.max) || 0)}`)
|
|
21347
21471
|
));
|
|
21348
21472
|
};
|
|
21349
21473
|
Avatar.defaultProps = defaultProps$u;
|
|
@@ -22008,10 +22132,9 @@ const Audio = (props) => {
|
|
|
22008
22132
|
handPlaying: false
|
|
22009
22133
|
});
|
|
22010
22134
|
const classPrefix2 = "nut-audio";
|
|
22011
|
-
const warn = console.warn;
|
|
22012
22135
|
const handleEnded = (e) => {
|
|
22013
22136
|
if (props.loop) {
|
|
22014
|
-
warn(locale.audio.tips || "onPlayEnd事件在loop=false时才会触发");
|
|
22137
|
+
console.warn(locale.audio.tips || "onPlayEnd事件在loop=false时才会触发");
|
|
22015
22138
|
} else {
|
|
22016
22139
|
props.onEnd && props.onEnd(e);
|
|
22017
22140
|
}
|
|
@@ -22724,7 +22847,9 @@ const InternalCountDown = (props, ref) => {
|
|
|
22724
22847
|
)
|
|
22725
22848
|
);
|
|
22726
22849
|
};
|
|
22727
|
-
const CountDown = React__default.forwardRef(
|
|
22850
|
+
const CountDown = React__default.forwardRef(
|
|
22851
|
+
InternalCountDown
|
|
22852
|
+
);
|
|
22728
22853
|
CountDown.defaultProps = defaultProps$k;
|
|
22729
22854
|
CountDown.displayName = "NutCountDown";
|
|
22730
22855
|
const useIsomorphicLayoutEffect = canUseDom ? useLayoutEffect : useEffect;
|
|
@@ -24061,8 +24186,8 @@ const Table = (props) => {
|
|
|
24061
24186
|
return [columns2.key, columns2.render];
|
|
24062
24187
|
});
|
|
24063
24188
|
};
|
|
24064
|
-
const renderBodyTds = (item) => {
|
|
24065
|
-
return sortDataItem().map(([value, render2]
|
|
24189
|
+
const renderBodyTds = (item, rowIndex) => {
|
|
24190
|
+
return sortDataItem().map(([value, render2]) => {
|
|
24066
24191
|
return /* @__PURE__ */ React__default.createElement(
|
|
24067
24192
|
"span",
|
|
24068
24193
|
{
|
|
@@ -24072,13 +24197,13 @@ const Table = (props) => {
|
|
|
24072
24197
|
),
|
|
24073
24198
|
key: value
|
|
24074
24199
|
},
|
|
24075
|
-
typeof item[value] === "function" || typeof render2 === "function" ? /* @__PURE__ */ React__default.createElement("div", null, render2 ? render2(item) : item[value](item)) : item[value]
|
|
24200
|
+
typeof item[value] === "function" || typeof render2 === "function" ? /* @__PURE__ */ React__default.createElement("div", null, render2 ? render2(item, rowIndex) : item[value](item)) : item[value]
|
|
24076
24201
|
);
|
|
24077
24202
|
});
|
|
24078
24203
|
};
|
|
24079
24204
|
const renderBoyTrs = () => {
|
|
24080
24205
|
return curData.map((item, index) => {
|
|
24081
|
-
return /* @__PURE__ */ React__default.createElement("div", { className: bodyClassPrefix, key: index }, renderBodyTds(item));
|
|
24206
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: bodyClassPrefix, key: index }, renderBodyTds(item, index));
|
|
24082
24207
|
});
|
|
24083
24208
|
};
|
|
24084
24209
|
return /* @__PURE__ */ React__default.createElement("div", { className: cls, style, ...rest }, /* @__PURE__ */ React__default.createElement(
|
|
@@ -24388,7 +24513,7 @@ const getListTotalSize = (positions, horizontal) => {
|
|
|
24388
24513
|
}
|
|
24389
24514
|
return size;
|
|
24390
24515
|
};
|
|
24391
|
-
const binarySearch = (positionsList, value = 0
|
|
24516
|
+
const binarySearch = (positionsList, horizontal, value = 0) => {
|
|
24392
24517
|
let start2 = 0;
|
|
24393
24518
|
let end = positionsList.length - 1;
|
|
24394
24519
|
let tempIndex = null;
|
|
@@ -24564,7 +24689,7 @@ const VirtualList = (props) => {
|
|
|
24564
24689
|
const scroll = useCallback(() => {
|
|
24565
24690
|
requestAnimationFrame((e) => {
|
|
24566
24691
|
const scrollSize = getElement()[scrollKey];
|
|
24567
|
-
const startIndex = binarySearch(positions,
|
|
24692
|
+
const startIndex = binarySearch(positions, horizontal, scrollSize);
|
|
24568
24693
|
const overStart = startIndex - overscan > -1 ? startIndex - overscan : 0;
|
|
24569
24694
|
if (!itemEqual) {
|
|
24570
24695
|
updateTotalSize();
|
|
@@ -24744,7 +24869,9 @@ const InternalBarrage = (props, ref) => {
|
|
|
24744
24869
|
};
|
|
24745
24870
|
return /* @__PURE__ */ React__default.createElement("div", { className: classes, ref: barrageBody, ...restProps }, /* @__PURE__ */ React__default.createElement("div", { ref: barrageContainer, className: "bContainer" }));
|
|
24746
24871
|
};
|
|
24747
|
-
const Barrage = React__default.forwardRef(
|
|
24872
|
+
const Barrage = React__default.forwardRef(
|
|
24873
|
+
InternalBarrage
|
|
24874
|
+
);
|
|
24748
24875
|
Barrage.defaultProps = defaultProps$5;
|
|
24749
24876
|
Barrage.displayName = "NutBarrage";
|
|
24750
24877
|
const defaultProps$4 = {
|
|
@@ -25024,7 +25151,7 @@ const TrendArrow = (props) => {
|
|
|
25024
25151
|
return console.warn(`传入的值:${num}不是一个数字`);
|
|
25025
25152
|
}
|
|
25026
25153
|
num = parseFloat(num);
|
|
25027
|
-
const numPow =
|
|
25154
|
+
const numPow = 10 ** digit;
|
|
25028
25155
|
return (Math.round((num + Number.EPSILON) * numPow) / numPow).toFixed(digit);
|
|
25029
25156
|
};
|
|
25030
25157
|
const calcStyle = (() => {
|
|
@@ -25212,7 +25339,7 @@ export {
|
|
|
25212
25339
|
Ellipsis,
|
|
25213
25340
|
Empty,
|
|
25214
25341
|
FixedNav,
|
|
25215
|
-
Form,
|
|
25342
|
+
InnerForm as Form,
|
|
25216
25343
|
FormItem,
|
|
25217
25344
|
Grid,
|
|
25218
25345
|
GridItem,
|