@nutui/nutui-react 2.0.0-alpha.16 → 2.0.0-alpha.17
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 +12 -0
- package/dist/esm/ActionSheet/style/style.css +1 -1
- package/dist/esm/Button.js +4 -2
- package/dist/esm/Divider/style/style.css +1 -1
- package/dist/esm/Form/style/index.js +3 -1
- package/dist/esm/Form/style/style.css +1 -1
- package/dist/esm/Form.js +64 -48
- package/dist/esm/FormItem/style/index.js +1 -1
- package/dist/esm/FormItem/style/style.css +1 -1
- package/dist/esm/FormItem.js +1 -1
- package/dist/esm/InputNumber.js +7 -7
- package/dist/esm/Pagination/style/style.css +1 -1
- package/dist/esm/Picker.js +31 -11
- package/dist/esm/Popover.js +7 -7
- package/dist/esm/Popup.js +1 -0
- package/dist/esm/SearchBar.js +2 -2
- package/dist/esm/Swipe.js +4 -6
- package/dist/esm/formitem2.js +87 -69
- package/dist/esm/types/src/packages/button/button.d.ts +1 -0
- package/dist/esm/types/src/packages/elevator/elevator.d.ts +0 -1
- package/dist/esm/types/src/packages/elevator/elevator.taro.d.ts +0 -1
- package/dist/esm/types/src/packages/form/__tests__/form.spec.d.ts +1 -0
- package/dist/esm/types/src/packages/form/context.d.ts +4 -0
- package/dist/esm/types/src/packages/form/form.d.ts +11 -4
- package/dist/esm/types/src/packages/form/form.taro.d.ts +14 -4
- package/dist/esm/types/src/packages/form/index.d.ts +1 -0
- package/dist/esm/types/src/packages/form/index.taro.d.ts +1 -0
- package/dist/esm/types/src/packages/form/types.d.ts +4 -52
- package/dist/esm/types/src/packages/formitem/formitem.d.ts +16 -15
- package/dist/esm/types/src/packages/formitem/formitem.taro.d.ts +16 -12
- package/dist/esm/types/src/packages/formitem/index.d.ts +1 -0
- package/dist/esm/types/src/packages/formitem/index.taro.d.ts +1 -0
- package/dist/esm/types/src/packages/formitem/types.d.ts +1 -31
- package/dist/esm/types/src/packages/inputnumber/inputnumber.d.ts +1 -1
- package/dist/esm/types/src/packages/inputnumber/inputnumber.taro.d.ts +1 -1
- package/dist/esm/types/src/packages/picker/picker.d.ts +7 -2
- package/dist/esm/types/src/packages/picker/picker.taro.d.ts +7 -2
- package/dist/esm/types/src/packages/sticky/sticky.d.ts +0 -1
- package/dist/esm/types/src/packages/swipe/swipe.d.ts +2 -6
- package/dist/esm/types/src/packages/swipe/swipe.taro.d.ts +2 -6
- package/dist/esm/types/src/utils/is-forward-ref-component.d.ts +1 -0
- 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 +244 -173
- package/dist/nutui.react.umd.js +244 -173
- package/dist/packages/actionsheet/actionsheet.scss +6 -6
- package/dist/packages/divider/divider.scss +8 -7
- package/dist/packages/formitem/formitem.scss +1 -13
- package/dist/packages/layout/layout.scss +0 -2
- package/dist/packages/pagination/pagination.scss +8 -30
- package/dist/style.css +1 -1
- package/dist/style.mjs +1 -1
- package/dist/types/packages/animate/animate.d.ts +3 -3
- package/dist/types/packages/audio/audio.d.ts +2 -2
- package/dist/types/packages/avatar/avatar.d.ts +5 -5
- package/dist/types/packages/avatargroup/avatargroup.d.ts +5 -5
- package/dist/types/packages/badge/badge.d.ts +1 -1
- package/dist/types/packages/button/button.d.ts +5 -4
- package/dist/types/packages/cascader/cascader.d.ts +4 -4
- package/dist/types/packages/checkboxgroup/checkboxgroup.d.ts +2 -2
- package/dist/types/packages/circleprogress/circleprogress.d.ts +2 -2
- package/dist/types/packages/divider/divider.d.ts +2 -2
- package/dist/types/packages/drag/drag.d.ts +1 -1
- package/dist/types/packages/elevator/elevator.d.ts +0 -1
- package/dist/types/packages/empty/empty.d.ts +3 -3
- package/dist/types/packages/fixednav/fixednav.d.ts +3 -3
- package/dist/types/packages/form/context.d.ts +4 -0
- package/dist/types/packages/form/form.d.ts +43 -4
- package/dist/types/packages/form/index.d.ts +1 -0
- package/dist/types/packages/form/types.d.ts +4 -52
- package/dist/types/packages/formitem/formitem.d.ts +45 -16
- package/dist/types/packages/formitem/index.d.ts +1 -0
- package/dist/types/packages/formitem/types.d.ts +1 -31
- package/dist/types/packages/grid/grid.d.ts +1 -1
- package/dist/types/packages/infiniteloading/infiniteloading.d.ts +1 -1
- package/dist/types/packages/inputnumber/inputnumber.d.ts +1 -1
- package/dist/types/packages/noticebar/noticebar.d.ts +3 -3
- package/dist/types/packages/overlay/overlay.d.ts +1 -1
- package/dist/types/packages/pagination/pagination.d.ts +1 -1
- package/dist/types/packages/picker/picker.d.ts +7 -2
- package/dist/types/packages/popover/popover.d.ts +5 -5
- package/dist/types/packages/popup/popup.d.ts +2 -2
- package/dist/types/packages/radio/radio.d.ts +2 -2
- package/dist/types/packages/searchbar/searchbar.d.ts +7 -7
- package/dist/types/packages/step/step.d.ts +3 -3
- package/dist/types/packages/steps/steps.d.ts +1 -1
- package/dist/types/packages/sticky/sticky.d.ts +1 -2
- package/dist/types/packages/swipe/swipe.d.ts +2 -6
- package/dist/types/packages/swiper/swiper.d.ts +1 -1
- package/dist/types/packages/tabs/tabs.d.ts +1 -1
- package/dist/types/packages/tag/tag.d.ts +1 -1
- package/dist/types/packages/timeselect/timeselect.d.ts +2 -2
- package/dist/types/packages/toast/toast.d.ts +50 -10
- package/dist/types/packages/uploader/uploader.d.ts +17 -17
- package/dist/types/utils/is-forward-ref-component.d.ts +1 -0
- package/package.json +1 -1
- package/dist/esm/types/src/packages/formitem/formitemcontext.d.ts +0 -6
- package/dist/types/packages/formitem/formitemcontext.d.ts +0 -6
- /package/dist/esm/types/src/packages/form/{useForm.d.ts → useform.d.ts} +0 -0
- /package/dist/esm/types/src/packages/form/{useForm.taro.d.ts → useform.taro.d.ts} +0 -0
- /package/dist/types/packages/form/{useForm.d.ts → useform.d.ts} +0 -0
package/dist/esm/Swipe.js
CHANGED
|
@@ -23,10 +23,8 @@ function _objectSpread(target) {
|
|
|
23
23
|
}
|
|
24
24
|
import React__default, { forwardRef, useRef, useState, useCallback, useImperativeHandle, useEffect } from "react";
|
|
25
25
|
import classNames from "classnames";
|
|
26
|
-
import { c as cn } from "./bem.js";
|
|
27
26
|
import { u as useTouch } from "./use-touch.js";
|
|
28
27
|
import { g as getRect } from "./use-client-rect.js";
|
|
29
|
-
import "@bem-react/classname";
|
|
30
28
|
function preventDefault(event, isStopPropagation) {
|
|
31
29
|
if (typeof event.cancelable !== "boolean" || event.cancelable) {
|
|
32
30
|
event.preventDefault();
|
|
@@ -39,7 +37,7 @@ var defaultProps = {
|
|
|
39
37
|
name: ""
|
|
40
38
|
};
|
|
41
39
|
var Swipe = forwardRef(function(props, instanceRef) {
|
|
42
|
-
var
|
|
40
|
+
var classPrefix = "nut-swipe";
|
|
43
41
|
var touch = useTouch();
|
|
44
42
|
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), children = _defaultProps$props.children, className = _defaultProps$props.className, style = _defaultProps$props.style;
|
|
45
43
|
var root = useRef();
|
|
@@ -173,7 +171,7 @@ var Swipe = forwardRef(function(props, instanceRef) {
|
|
|
173
171
|
if (props["".concat(side, "Action")]) {
|
|
174
172
|
return React__default.createElement("div", {
|
|
175
173
|
ref: measuredRef,
|
|
176
|
-
className: "".concat(
|
|
174
|
+
className: "".concat(classPrefix, "__").concat(side),
|
|
177
175
|
onClick: function onClick(e) {
|
|
178
176
|
return handleOperate(e, side);
|
|
179
177
|
}
|
|
@@ -215,7 +213,7 @@ var Swipe = forwardRef(function(props, instanceRef) {
|
|
|
215
213
|
}, []);
|
|
216
214
|
return React__default.createElement("div", {
|
|
217
215
|
ref: root,
|
|
218
|
-
className: classNames(
|
|
216
|
+
className: classNames(classPrefix, className),
|
|
219
217
|
onTouchStart: function onTouchStart(e) {
|
|
220
218
|
return _onTouchStart(e);
|
|
221
219
|
},
|
|
@@ -227,7 +225,7 @@ var Swipe = forwardRef(function(props, instanceRef) {
|
|
|
227
225
|
},
|
|
228
226
|
style
|
|
229
227
|
}, React__default.createElement("div", {
|
|
230
|
-
className: "".concat(
|
|
228
|
+
className: "".concat(classPrefix, "__wrapper"),
|
|
231
229
|
style: wrapperStyle
|
|
232
230
|
}, renderActionContent("left", leftRef), children, renderActionContent("right", rightRef)));
|
|
233
231
|
});
|
package/dist/esm/formitem2.js
CHANGED
|
@@ -57,86 +57,107 @@ function _objectSpread(target) {
|
|
|
57
57
|
import React__default, { createContext } from "react";
|
|
58
58
|
import Cell from "./Cell.js";
|
|
59
59
|
import { C as ComponentDefaults } from "./typings.js";
|
|
60
|
-
var
|
|
60
|
+
var Context = createContext({});
|
|
61
|
+
function isForwardRefComponent(component) {
|
|
62
|
+
return component.type && component.type.$$typeof && // eslint-disable-next-line react/display-name
|
|
63
|
+
React__default.forwardRef(
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
65
|
+
// @ts-ignore
|
|
66
|
+
function() {
|
|
67
|
+
}
|
|
68
|
+
).$$typeof === component.type.$$typeof;
|
|
69
|
+
}
|
|
61
70
|
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
71
|
+
required: false,
|
|
62
72
|
name: "",
|
|
63
73
|
label: "",
|
|
64
|
-
className: "",
|
|
65
74
|
rules: [{
|
|
66
75
|
required: false,
|
|
67
76
|
message: ""
|
|
68
77
|
}],
|
|
69
|
-
|
|
70
|
-
labelWidth: 90,
|
|
71
|
-
errorMessageAlign: "left",
|
|
72
|
-
showErrorLine: true,
|
|
73
|
-
showErrorMessage: true,
|
|
74
|
-
initialValue: ""
|
|
78
|
+
errorMessageAlign: "left"
|
|
75
79
|
});
|
|
76
80
|
var FormItem = /* @__PURE__ */ function(_React__default$Compo) {
|
|
77
81
|
_inherits(FormItem2, _React__default$Compo);
|
|
78
82
|
var _super = _createSuper(FormItem2);
|
|
79
|
-
function FormItem2() {
|
|
83
|
+
function FormItem2(props) {
|
|
80
84
|
var _this;
|
|
81
85
|
_classCallCheck(this, FormItem2);
|
|
82
|
-
|
|
83
|
-
args[_key] = arguments[_key];
|
|
84
|
-
}
|
|
85
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
86
|
+
_this = _super.call(this, props);
|
|
86
87
|
_defineProperty(_assertThisInitialized(_this), "cancelRegister", void 0);
|
|
87
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
88
|
+
_defineProperty(_assertThisInitialized(_this), "componentRef", void 0);
|
|
88
89
|
_defineProperty(_assertThisInitialized(_this), "getControlled", function(children) {
|
|
89
|
-
var _children$props,
|
|
90
|
-
var _this$context = _this.context,
|
|
90
|
+
var _children$props, _objectSpread2;
|
|
91
|
+
var _this$context = _this.context, setFieldsValue = _this$context.setFieldsValue, getFieldValue = _this$context.getFieldValue;
|
|
91
92
|
var name = _this.props.name;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (defaultvalue && !_this.isInitialValue) {
|
|
95
|
-
setFieldsValue(_defineProperty({}, name, defaultvalue));
|
|
96
|
-
_this.isInitialValue = true;
|
|
93
|
+
if (children !== null && children !== void 0 && (_children$props = children.props) !== null && _children$props !== void 0 && _children$props.defaultValue) {
|
|
94
|
+
console.warn("通过 initialValue 设置初始值");
|
|
97
95
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
var originOnChange = children.props.onChange;
|
|
103
|
-
if (originOnChange) {
|
|
104
|
-
originOnChange(event);
|
|
105
|
-
}
|
|
106
|
-
var newValue = event;
|
|
107
|
-
switch (type) {
|
|
108
|
-
case "checkbox":
|
|
109
|
-
newValue = event.target.value;
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
setFieldsValue(_defineProperty({}, name, newValue));
|
|
96
|
+
var controlled = _objectSpread(_objectSpread({}, children.props), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, _this.props.valuePropName || "value", getFieldValue(name) || _this.props.initialValue), _defineProperty(_objectSpread2, _this.props.trigger || "onChange", function() {
|
|
97
|
+
var originOnChange = children.props[_this.props.trigger || "onChange"];
|
|
98
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
99
|
+
args[_key] = arguments[_key];
|
|
113
100
|
}
|
|
114
|
-
|
|
101
|
+
if (originOnChange) {
|
|
102
|
+
originOnChange.apply(void 0, args);
|
|
103
|
+
}
|
|
104
|
+
var next = args[0];
|
|
105
|
+
if (_this.props.getValueFromEvent) {
|
|
106
|
+
var _this$props;
|
|
107
|
+
next = (_this$props = _this.props).getValueFromEvent.apply(_this$props, args);
|
|
108
|
+
}
|
|
109
|
+
setFieldsValue(_defineProperty({}, name, next));
|
|
110
|
+
}), _objectSpread2));
|
|
111
|
+
if (isForwardRefComponent(children)) {
|
|
112
|
+
controlled.ref = function(componentInstance) {
|
|
113
|
+
var originRef = children.ref;
|
|
114
|
+
if (originRef) {
|
|
115
|
+
if (typeof originRef === "function") {
|
|
116
|
+
originRef(componentInstance);
|
|
117
|
+
}
|
|
118
|
+
if ("current" in originRef) {
|
|
119
|
+
originRef.current = componentInstance;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
_this.componentRef = componentInstance;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
return controlled;
|
|
115
126
|
});
|
|
116
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
117
|
-
_this.
|
|
127
|
+
_defineProperty(_assertThisInitialized(_this), "refresh", function() {
|
|
128
|
+
_this.setState(function(_ref) {
|
|
129
|
+
var resetCount = _ref.resetCount;
|
|
130
|
+
return {
|
|
131
|
+
resetCount: resetCount + 1
|
|
132
|
+
};
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
_defineProperty(_assertThisInitialized(_this), "onStoreChange", function(type) {
|
|
136
|
+
if (type === "reset") {
|
|
137
|
+
_this.refresh();
|
|
138
|
+
} else {
|
|
139
|
+
_this.forceUpdate();
|
|
140
|
+
}
|
|
118
141
|
});
|
|
119
142
|
_defineProperty(_assertThisInitialized(_this), "renderLayout", function(childNode) {
|
|
120
|
-
var _this$context$
|
|
121
|
-
var _defaultProps$_this$p = _objectSpread(_objectSpread({}, defaultProps), _this.props), label = _defaultProps$_this$p.label, name = _defaultProps$_this$p.name, _defaultProps$_this$
|
|
122
|
-
|
|
123
|
-
message: ""
|
|
124
|
-
}] : _defaultProps$_this$p2, className = _defaultProps$_this$p.className, labelWidth = _defaultProps$_this$p.labelWidth, errorMessageAlign = _defaultProps$_this$p.errorMessageAlign, showErrorLine = _defaultProps$_this$p.showErrorLine, showErrorMessage = _defaultProps$_this$p.showErrorMessage;
|
|
125
|
-
var item = ((_this$context$errList = _this.context.errList) === null || _this$context$errList === void 0 ? void 0 : _this$context$errList.length) > 0 && ((_this$context$errList2 = _this.context.errList) === null || _this$context$errList2 === void 0 ? void 0 : _this$context$errList2.filter(function(item2) {
|
|
143
|
+
var _this$context$errors, _this$context$errors2;
|
|
144
|
+
var _defaultProps$_this$p = _objectSpread(_objectSpread({}, defaultProps), _this.props), label = _defaultProps$_this$p.label, name = _defaultProps$_this$p.name, required = _defaultProps$_this$p.required, className = _defaultProps$_this$p.className, style = _defaultProps$_this$p.style, errorMessageAlign = _defaultProps$_this$p.errorMessageAlign;
|
|
145
|
+
var item = ((_this$context$errors = _this.context.errors) === null || _this$context$errors === void 0 ? void 0 : _this$context$errors.length) > 0 && ((_this$context$errors2 = _this.context.errors) === null || _this$context$errors2 === void 0 ? void 0 : _this$context$errors2.filter(function(item2) {
|
|
126
146
|
return item2.field === name;
|
|
127
147
|
}));
|
|
128
|
-
var
|
|
129
|
-
var renderStar =
|
|
148
|
+
var starPosition = _this.context.starPosition;
|
|
149
|
+
var renderStar = required && React__default.createElement("i", {
|
|
130
150
|
className: "required"
|
|
131
151
|
});
|
|
132
|
-
var renderLabel =
|
|
152
|
+
var renderLabel = React__default.createElement(React__default.Fragment, null, starPosition === "left" ? renderStar : null, label, starPosition === "right" ? renderStar : null);
|
|
133
153
|
return React__default.createElement(Cell, {
|
|
134
|
-
className: "nut-form-item ".concat(className)
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
width: _this.pxCheck(labelWidth)
|
|
154
|
+
className: "nut-form-item ".concat(className),
|
|
155
|
+
style,
|
|
156
|
+
onClick: function onClick(e) {
|
|
157
|
+
return _this.props.onClick && _this.props.onClick(e, _this.componentRef);
|
|
139
158
|
}
|
|
159
|
+
}, label ? React__default.createElement("div", {
|
|
160
|
+
className: "nut-cell__title nut-form-item__label"
|
|
140
161
|
}, renderLabel) : null, React__default.createElement("div", {
|
|
141
162
|
className: "nut-cell__value nut-form-item__body"
|
|
142
163
|
}, React__default.createElement("div", {
|
|
@@ -148,9 +169,10 @@ var FormItem = /* @__PURE__ */ function(_React__default$Compo) {
|
|
|
148
169
|
}
|
|
149
170
|
}, item[0].message)));
|
|
150
171
|
});
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
172
|
+
_this.componentRef = React__default.createRef();
|
|
173
|
+
_this.state = {
|
|
174
|
+
resetCount: 1
|
|
175
|
+
};
|
|
154
176
|
return _this;
|
|
155
177
|
}
|
|
156
178
|
_createClass(FormItem2, [{
|
|
@@ -168,23 +190,19 @@ var FormItem = /* @__PURE__ */ function(_React__default$Compo) {
|
|
|
168
190
|
}, {
|
|
169
191
|
key: "render",
|
|
170
192
|
value: function render() {
|
|
171
|
-
var
|
|
172
|
-
var
|
|
173
|
-
var
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
var returnChildNode = React__default.cloneElement(restCNode, this.getControlled(restCNode));
|
|
180
|
-
return this.renderLayout(returnChildNode);
|
|
193
|
+
var children = this.props.children;
|
|
194
|
+
var child = Array.isArray(children) ? children[0] : children;
|
|
195
|
+
var returnChildNode = React__default.cloneElement(child, this.getControlled(child));
|
|
196
|
+
return React__default.createElement(React__default.Fragment, {
|
|
197
|
+
key: this.state.resetCount
|
|
198
|
+
}, this.renderLayout(returnChildNode));
|
|
181
199
|
}
|
|
182
200
|
}]);
|
|
183
201
|
return FormItem2;
|
|
184
202
|
}(React__default.Component);
|
|
185
203
|
_defineProperty(FormItem, "defaultProps", defaultProps);
|
|
186
|
-
_defineProperty(FormItem, "contextType",
|
|
204
|
+
_defineProperty(FormItem, "contextType", Context);
|
|
187
205
|
export {
|
|
188
|
-
|
|
189
|
-
FormItem as
|
|
206
|
+
Context as C,
|
|
207
|
+
FormItem as F
|
|
190
208
|
};
|
|
@@ -15,6 +15,7 @@ export interface ButtonProps extends BasicComponent {
|
|
|
15
15
|
disabled: boolean;
|
|
16
16
|
icon: React.ReactNode;
|
|
17
17
|
id: string;
|
|
18
|
+
nativeType: 'submit' | 'reset' | 'button';
|
|
18
19
|
onClick: (e: MouseEvent) => void;
|
|
19
20
|
}
|
|
20
21
|
export declare const Button: React.ForwardRefExoticComponent<Partial<ButtonProps> & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import React, { FunctionComponent } from 'react';
|
|
2
|
-
import { useForm } from './
|
|
1
|
+
import React, { FunctionComponent, ReactNode } from 'react';
|
|
2
|
+
import { useForm } from './useform';
|
|
3
3
|
import { BasicComponent } from '@/utils/typings';
|
|
4
4
|
import { FormItem } from '../formitem/formitem';
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
export interface FormProps extends BasicComponent {
|
|
6
|
+
footer: ReactNode;
|
|
7
|
+
initialValues: any;
|
|
8
|
+
name: string;
|
|
9
|
+
form: any;
|
|
10
|
+
labelPosition: 'top' | 'left' | 'right';
|
|
11
|
+
starPosition: 'left' | 'right';
|
|
12
|
+
onFinish: (values: any) => void;
|
|
13
|
+
onFinishFailed: (values: any, errorFields: any) => void;
|
|
7
14
|
}
|
|
8
15
|
export declare const Form: FunctionComponent<Partial<FormProps> & React.HTMLAttributes<HTMLFormElement>> & {
|
|
9
16
|
Item: typeof FormItem;
|
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
import React, { FunctionComponent } from 'react';
|
|
1
|
+
import React, { FunctionComponent, ReactNode } from 'react';
|
|
2
2
|
import { BasicComponent } from '@/utils/typings';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
export interface FormProps extends BasicComponent
|
|
3
|
+
import { useForm } from './useform.taro';
|
|
4
|
+
import { FormItem } from '../formitem/formitem.taro';
|
|
5
|
+
export interface FormProps extends BasicComponent {
|
|
6
|
+
footer: ReactNode;
|
|
7
|
+
initialValues: any;
|
|
8
|
+
name: string;
|
|
9
|
+
form: any;
|
|
10
|
+
labelPosition: 'top' | 'left' | 'right';
|
|
11
|
+
starPosition: 'left' | 'right';
|
|
12
|
+
onFinish: (values: any) => void;
|
|
13
|
+
onFinishFailed: (values: any, errorFields: any) => void;
|
|
6
14
|
}
|
|
7
15
|
export declare const Form: FunctionComponent<Partial<FormProps> & React.HTMLAttributes<HTMLFormElement>> & {
|
|
8
16
|
Item: typeof FormItem;
|
|
17
|
+
} & {
|
|
18
|
+
useForm: typeof useForm;
|
|
9
19
|
};
|
|
@@ -1,63 +1,18 @@
|
|
|
1
|
-
export interface BaseForm {
|
|
2
|
-
/**
|
|
3
|
-
* 经 Form.useForm() 创建的 form 控制实例,不提供时会自动创建
|
|
4
|
-
*/
|
|
5
|
-
form: any;
|
|
6
|
-
/**
|
|
7
|
-
* label的位置
|
|
8
|
-
* 可选值 top/left/right
|
|
9
|
-
*/
|
|
10
|
-
labelPosition: string | number;
|
|
11
|
-
/**
|
|
12
|
-
* 表单分组名称
|
|
13
|
-
*/
|
|
14
|
-
formGroupTitle: string;
|
|
15
|
-
starPositon: string;
|
|
16
|
-
/**
|
|
17
|
-
* 表单校验成功回调
|
|
18
|
-
*/
|
|
19
|
-
onFinish: (obj: object) => void;
|
|
20
|
-
/**
|
|
21
|
-
* 表单校验失败回调
|
|
22
|
-
*/
|
|
23
|
-
onFinishFailed: (value: []) => void;
|
|
24
|
-
}
|
|
25
1
|
export interface FormItemRuleWithoutValidator {
|
|
26
2
|
[key: string]: any;
|
|
27
3
|
regex?: RegExp;
|
|
28
4
|
required?: boolean;
|
|
29
5
|
message?: string;
|
|
30
6
|
}
|
|
31
|
-
export
|
|
32
|
-
validator?: (value: any, ruleCfg: FormItemRuleWithoutValidator) => boolean | string | Promise<boolean | string>;
|
|
33
|
-
}
|
|
34
|
-
export interface BaseFormField {
|
|
35
|
-
/**
|
|
36
|
-
* 字段名
|
|
37
|
-
*/
|
|
38
|
-
name: string;
|
|
39
|
-
/**
|
|
40
|
-
* label 标签的文本
|
|
41
|
-
*/
|
|
42
|
-
label: string;
|
|
43
|
-
/**
|
|
44
|
-
* 校验规则,设置字段的校验逻辑
|
|
45
|
-
*/
|
|
46
|
-
rules: FormItemRule[];
|
|
47
|
-
/**
|
|
48
|
-
* 是否禁用表单项
|
|
49
|
-
*/
|
|
50
|
-
disabled: boolean;
|
|
51
|
-
}
|
|
52
|
-
export type StoreValue = string | number;
|
|
7
|
+
export type StoreValue = any;
|
|
53
8
|
export type NamePath = string | number;
|
|
54
9
|
export interface Callbacks<Values = any> {
|
|
55
10
|
onValuesChange?: (values: Values) => void;
|
|
56
11
|
onFinish?: (values: Values) => void;
|
|
57
|
-
onFinishFailed?: (Values:
|
|
12
|
+
onFinishFailed?: (values: Values, errorFields: any) => void;
|
|
58
13
|
}
|
|
59
14
|
export interface Store {
|
|
60
|
-
[name: string]:
|
|
15
|
+
[name: string]: any;
|
|
61
16
|
}
|
|
62
17
|
export interface FormInstance<Values = any> {
|
|
63
18
|
registerField: (entity: FieldEntity) => () => void;
|
|
@@ -68,7 +23,7 @@ export interface FormInstance<Values = any> {
|
|
|
68
23
|
setCallback: (callbacks: Callbacks) => void;
|
|
69
24
|
}
|
|
70
25
|
export interface FieldEntity {
|
|
71
|
-
onStoreChange: () => void;
|
|
26
|
+
onStoreChange: (type?: string) => void;
|
|
72
27
|
getNamePath: () => NamePath;
|
|
73
28
|
props: {
|
|
74
29
|
name: NamePath;
|
|
@@ -77,6 +32,3 @@ export interface FieldEntity {
|
|
|
77
32
|
initialValue?: any;
|
|
78
33
|
};
|
|
79
34
|
}
|
|
80
|
-
export interface IDescriptor {
|
|
81
|
-
[name: string]: string;
|
|
82
|
-
}
|
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { BaseFormField } from './types';
|
|
3
|
-
import {
|
|
3
|
+
import { Context } from '../form/context';
|
|
4
4
|
import { BasicComponent } from '@/utils/typings';
|
|
5
5
|
type TextAlign = 'start' | 'end' | 'left' | 'right' | 'center' | 'justify' | 'match-parent';
|
|
6
6
|
export interface FormItemProps extends BasicComponent, BaseFormField {
|
|
7
|
-
|
|
7
|
+
required: boolean;
|
|
8
|
+
initialValue: any;
|
|
9
|
+
trigger: string;
|
|
10
|
+
valuePropName: string;
|
|
11
|
+
getValueFromEvent: (...args: any) => any;
|
|
12
|
+
onClick: (event: React.MouseEvent, componentRef: React.MutableRefObject<any>) => void;
|
|
8
13
|
errorMessageAlign: TextAlign;
|
|
9
|
-
showErrorLine: boolean;
|
|
10
|
-
showErrorMessage: boolean;
|
|
11
|
-
initialValue: string;
|
|
12
14
|
}
|
|
13
15
|
declare const defaultProps: FormItemProps;
|
|
14
16
|
export type FieldProps = typeof defaultProps & Partial<BaseFormField>;
|
|
15
|
-
export declare class FormItem extends React.Component<FieldProps
|
|
17
|
+
export declare class FormItem extends React.Component<FieldProps, {
|
|
18
|
+
resetCount: number;
|
|
19
|
+
}> {
|
|
16
20
|
static defaultProps: FormItemProps;
|
|
17
21
|
static contextType: any;
|
|
18
|
-
context: React.ContextType<typeof
|
|
22
|
+
context: React.ContextType<typeof Context>;
|
|
19
23
|
private cancelRegister;
|
|
20
|
-
private
|
|
24
|
+
private componentRef;
|
|
25
|
+
constructor(props: FieldProps);
|
|
21
26
|
componentDidMount(): void;
|
|
22
27
|
componentWillUnmount(): void;
|
|
23
|
-
getControlled: (children: React.ReactElement) =>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
onChange: (event: React.ChangeEvent<HTMLInputElement> | number | string | string[]) => void;
|
|
27
|
-
};
|
|
28
|
-
onStoreChange: () => void;
|
|
28
|
+
getControlled: (children: React.ReactElement) => any;
|
|
29
|
+
refresh: () => void;
|
|
30
|
+
onStoreChange: (type?: string) => void;
|
|
29
31
|
renderLayout: (childNode: React.ReactNode) => JSX.Element;
|
|
30
|
-
pxCheck: (value: string | number) => string;
|
|
31
32
|
render(): JSX.Element;
|
|
32
33
|
}
|
|
33
34
|
export {};
|
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { BaseFormField } from './types';
|
|
3
|
-
import {
|
|
3
|
+
import { Context } from '../form/context';
|
|
4
4
|
import { BasicComponent } from '@/utils/typings';
|
|
5
5
|
type TextAlign = 'start' | 'end' | 'left' | 'right' | 'center' | 'justify' | 'match-parent';
|
|
6
6
|
export interface FormItemProps extends BasicComponent, BaseFormField {
|
|
7
|
-
|
|
7
|
+
required: boolean;
|
|
8
|
+
initialValue: any;
|
|
9
|
+
trigger: string;
|
|
10
|
+
valuePropName: string;
|
|
11
|
+
getValueFromEvent: (...args: any) => any;
|
|
12
|
+
onClick: (event: React.MouseEvent, componentRef: React.MutableRefObject<any>) => void;
|
|
8
13
|
errorMessageAlign: TextAlign;
|
|
9
|
-
showErrorLine: boolean;
|
|
10
|
-
showErrorMessage: boolean;
|
|
11
14
|
}
|
|
12
15
|
declare const defaultProps: FormItemProps;
|
|
13
16
|
export type FieldProps = typeof defaultProps & Partial<BaseFormField>;
|
|
14
|
-
export declare class FormItem extends React.Component<FieldProps
|
|
17
|
+
export declare class FormItem extends React.Component<FieldProps, {
|
|
18
|
+
resetCount: number;
|
|
19
|
+
}> {
|
|
15
20
|
static defaultProps: FormItemProps;
|
|
16
21
|
static contextType: any;
|
|
17
|
-
context: React.ContextType<typeof
|
|
22
|
+
context: React.ContextType<typeof Context>;
|
|
18
23
|
private cancelRegister;
|
|
24
|
+
private componentRef;
|
|
25
|
+
constructor(props: FieldProps);
|
|
19
26
|
componentDidMount(): void;
|
|
20
27
|
componentWillUnmount(): void;
|
|
21
|
-
getControlled: (children: React.ReactElement) =>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
onStoreChange: () => void;
|
|
28
|
+
getControlled: (children: React.ReactElement) => any;
|
|
29
|
+
refresh: () => void;
|
|
30
|
+
onStoreChange: (type?: string) => void;
|
|
26
31
|
renderLayout: (childNode: React.ReactNode) => JSX.Element;
|
|
27
|
-
pxCheck: (value: string | number) => string;
|
|
28
32
|
render(): JSX.Element;
|
|
29
33
|
}
|
|
30
34
|
export {};
|
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
export interface BaseForm {
|
|
2
|
-
/**
|
|
3
|
-
* 经 Form.useForm() 创建的 form 控制实例,不提供时会自动创建
|
|
4
|
-
*/
|
|
5
|
-
form: any;
|
|
6
|
-
/**
|
|
7
|
-
* label的位置
|
|
8
|
-
* 可选值 top/left/right
|
|
9
|
-
*/
|
|
10
|
-
labelPosition: string | number;
|
|
11
|
-
/**
|
|
12
|
-
* 表单分组名称
|
|
13
|
-
*/
|
|
14
|
-
formGroupTitle: string;
|
|
15
|
-
starPositon: string;
|
|
16
|
-
/**
|
|
17
|
-
* 表单校验成功回调
|
|
18
|
-
*/
|
|
19
|
-
onFinish: (obj: object) => void;
|
|
20
|
-
/**
|
|
21
|
-
* 表单校验失败回调
|
|
22
|
-
*/
|
|
23
|
-
onFinishFailed: (value: []) => void;
|
|
24
|
-
}
|
|
25
1
|
export interface FormItemRuleWithoutValidator {
|
|
26
2
|
[key: string]: any;
|
|
27
3
|
regex?: RegExp;
|
|
@@ -49,16 +25,13 @@ export interface BaseFormField {
|
|
|
49
25
|
*/
|
|
50
26
|
disabled: boolean;
|
|
51
27
|
}
|
|
52
|
-
export type StoreValue =
|
|
28
|
+
export type StoreValue = any;
|
|
53
29
|
export type NamePath = string | number;
|
|
54
30
|
export interface Callbacks<Values = any> {
|
|
55
31
|
onValuesChange?: (values: Values) => void;
|
|
56
32
|
onFinish?: (values: Values) => void;
|
|
57
33
|
onFinishFailed?: (Values: Values) => void;
|
|
58
34
|
}
|
|
59
|
-
export interface Store {
|
|
60
|
-
[name: string]: StoreValue;
|
|
61
|
-
}
|
|
62
35
|
export interface FormInstance<Values = any> {
|
|
63
36
|
registerField: (entity: FieldEntity) => () => void;
|
|
64
37
|
getFieldValue: (name: NamePath) => StoreValue;
|
|
@@ -77,6 +50,3 @@ export interface FieldEntity {
|
|
|
77
50
|
initialValue?: any;
|
|
78
51
|
};
|
|
79
52
|
}
|
|
80
|
-
export interface IDescriptor {
|
|
81
|
-
[name: string]: string;
|
|
82
|
-
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import React, { RefObject } from 'react';
|
|
2
2
|
import { PickerOption } from './types';
|
|
3
3
|
import { BasicComponent } from '@/utils/typings';
|
|
4
|
-
export
|
|
5
|
-
|
|
4
|
+
export type PickerActions = {
|
|
5
|
+
open: () => void;
|
|
6
|
+
close: () => void;
|
|
7
|
+
};
|
|
8
|
+
export interface PickerProps extends Omit<BasicComponent, 'children'> {
|
|
9
|
+
visible?: boolean | undefined;
|
|
6
10
|
title?: string;
|
|
7
11
|
options: (PickerOption | PickerOption[])[];
|
|
8
12
|
value?: (number | string)[];
|
|
@@ -13,6 +17,7 @@ export interface PickerProps extends BasicComponent {
|
|
|
13
17
|
onClose?: (selectedOptions: PickerOption[], selectedValue: (string | number)[]) => void;
|
|
14
18
|
afterClose?: (selectedOptions: PickerOption[], selectedValue: (string | number)[], pickerRef: RefObject<HTMLDivElement>) => void;
|
|
15
19
|
onChange?: (selectedOptions: PickerOption[], selectedValue: (string | number)[], columnIndex: number) => void;
|
|
20
|
+
children?: any;
|
|
16
21
|
}
|
|
17
22
|
declare const Picker: React.ForwardRefExoticComponent<Partial<PickerProps> & React.RefAttributes<unknown>>;
|
|
18
23
|
export default Picker;
|