@power-xa/m-ui 0.0.1 → 0.0.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/dist/ActionSheet/index.less +2 -1
- package/dist/Button/index.js +1 -1
- package/dist/CreatorEdit/index.js +2 -1
- package/dist/DatePicker/index.d.ts +13 -0
- package/dist/DatePicker/index.js +150 -0
- package/dist/DatePicker/index.less +35 -0
- package/dist/Filter/index.d.ts +13 -0
- package/dist/Filter/index.js +77 -0
- package/dist/Filter/index.less +78 -0
- package/dist/FloatButton/index.js +24 -19
- package/dist/Popup/index.js +8 -1
- package/dist/Popup/index.less +1 -0
- package/dist/ProForm/{controls → Controls}/Date/index.js +23 -8
- package/dist/ProForm/Controls/List/index.d.ts +30 -0
- package/dist/ProForm/Controls/List/index.js +130 -0
- package/dist/ProForm/{controls → Controls}/List/index.less +31 -0
- package/dist/ProForm/{controls → Controls}/Select/index.js +23 -13
- package/dist/ProForm/{controls → Controls}/Select/index.less +6 -0
- package/dist/ProForm/Controls/Text/index.js +45 -0
- package/dist/ProForm/{controls → Controls}/TextArea/index.js +14 -4
- package/dist/ProForm/{controls → Controls}/Upload/index.js +5 -1
- package/dist/ProForm/Field/index.d.ts +2 -1
- package/dist/ProForm/Field/index.js +1 -1
- package/dist/ProForm/Field/index.less +2 -0
- package/dist/ProForm/Form/index.d.ts +6 -6
- package/dist/ProForm/Form/index.js +154 -57
- package/dist/ProForm/Group/index.js +31 -45
- package/dist/ProForm/index.d.ts +0 -2
- package/dist/ProForm/typings.d.ts +18 -16
- package/dist/ProList/index.d.ts +1 -1
- package/dist/ProList/index.js +36 -14
- package/dist/SearchInput/index.d.ts +9 -0
- package/dist/SearchInput/index.js +22 -0
- package/dist/SearchInput/index.less +29 -0
- package/dist/index.d.ts +10 -7
- package/dist/index.js +10 -7
- package/dist/request/index.js +1 -1
- package/dist/utils/tools.d.ts +11 -1
- package/dist/utils/tools.js +43 -9
- package/package.json +1 -1
- package/dist/ProForm/controls/List/index.d.ts +0 -23
- package/dist/ProForm/controls/List/index.js +0 -77
- package/dist/ProForm/controls/Text/index.js +0 -29
- /package/dist/ProForm/{controls → Controls}/Date/index.d.ts +0 -0
- /package/dist/ProForm/{controls → Controls}/Select/index.d.ts +0 -0
- /package/dist/ProForm/{controls → Controls}/Text/index.d.ts +0 -0
- /package/dist/ProForm/{controls → Controls}/Text/index.less +0 -0
- /package/dist/ProForm/{controls → Controls}/TextArea/index.d.ts +0 -0
- /package/dist/ProForm/{controls → Controls}/TextArea/index.less +0 -0
- /package/dist/ProForm/{controls → Controls}/Upload/index.d.ts +0 -0
- /package/dist/ProForm/{controls → Controls}/Upload/index.less +0 -0
|
@@ -10,72 +10,181 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
10
10
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
11
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
-
import React, { cloneElement, Fragment, useCallback, useEffect, useState } from "react";
|
|
13
|
+
import React, { cloneElement, forwardRef, Fragment, useCallback, useEffect, useImperativeHandle, useState } from "react";
|
|
14
14
|
import { getWindowInfo, showToast } from "@tarojs/taro";
|
|
15
15
|
import { ScrollView, Text, View } from "@tarojs/components";
|
|
16
|
-
import { Button, ActionSheet } from "../..";
|
|
16
|
+
import { Button, ActionSheet, getObjectPathValue, setObjectPathValue } from "../..";
|
|
17
17
|
import "./index.less";
|
|
18
|
-
var ProForm = function ProForm(_ref) {
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
className = _ref$className === void 0 ? "" : _ref$className,
|
|
18
|
+
var ProForm = function ProForm(_ref, ref) {
|
|
19
|
+
var className = _ref.className,
|
|
20
|
+
children = _ref.children,
|
|
22
21
|
_ref$initialValues = _ref.initialValues,
|
|
23
22
|
initialValues = _ref$initialValues === void 0 ? {} : _ref$initialValues,
|
|
24
23
|
onOk = _ref.onOk,
|
|
25
24
|
onDelete = _ref.onDelete,
|
|
26
25
|
onSave = _ref.onSave,
|
|
26
|
+
footer = _ref.footer,
|
|
27
27
|
disabled = _ref.disabled;
|
|
28
28
|
var _getWindowInfo = getWindowInfo(),
|
|
29
29
|
safeArea = _getWindowInfo.safeArea;
|
|
30
30
|
var _ref2 = safeArea,
|
|
31
31
|
height = _ref2.height,
|
|
32
32
|
bottom = _ref2.bottom;
|
|
33
|
-
var _useState = useState(
|
|
33
|
+
var _useState = useState({}),
|
|
34
34
|
_useState2 = _slicedToArray(_useState, 2),
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
var _useState3 = useState({}),
|
|
38
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
39
|
-
form = _useState4[0],
|
|
40
|
-
setForm = _useState4[1];
|
|
35
|
+
form = _useState2[0],
|
|
36
|
+
setForm = _useState2[1];
|
|
41
37
|
useEffect(function () {
|
|
42
38
|
if (initialValues && JSON.stringify(initialValues) !== "{}") {
|
|
43
39
|
setForm(initialValues || {});
|
|
44
40
|
}
|
|
45
41
|
}, [initialValues]);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
useImperativeHandle(ref, function () {
|
|
43
|
+
return {
|
|
44
|
+
form: form,
|
|
45
|
+
setForm: setForm
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
var getProFormListControlsList = useCallback(function (el, name, i, list) {
|
|
49
|
+
if (el.props) {
|
|
50
|
+
if (el.props.name) {
|
|
51
|
+
list.push( /*#__PURE__*/cloneElement(el, _objectSpread(_objectSpread({}, el.props), {}, {
|
|
52
|
+
value: getObjectPathValue(el.props.name, form[name][i])
|
|
53
|
+
})));
|
|
54
|
+
} else {
|
|
55
|
+
if (el.props.children instanceof Array) {
|
|
56
|
+
el.props.children.map(function (item) {
|
|
57
|
+
return getProFormListControlsList(item, name, i, list);
|
|
58
|
+
});
|
|
59
|
+
} else {
|
|
60
|
+
getProFormListControlsList(el.props.children, name, i, list);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
51
63
|
}
|
|
52
|
-
}, [
|
|
53
|
-
var
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return
|
|
57
|
-
|
|
64
|
+
}, [form]);
|
|
65
|
+
var getControlsList = useCallback(function (list) {
|
|
66
|
+
return list.map(function (item) {
|
|
67
|
+
if (item.props.children) {
|
|
68
|
+
if (item.props.children instanceof Array) return getControlsList(item.props.children.map(function (e) {
|
|
69
|
+
return /*#__PURE__*/cloneElement(e, _objectSpread(_objectSpread({}, e.props), {}, {
|
|
70
|
+
value: getObjectPathValue(e.props.name, form)
|
|
71
|
+
}));
|
|
72
|
+
}));
|
|
73
|
+
if (item.props.children instanceof Function) {
|
|
74
|
+
var _form$item$props$name;
|
|
75
|
+
var _list = [];
|
|
76
|
+
(_form$item$props$name = form[item.props.name]) === null || _form$item$props$name === void 0 || _form$item$props$name.map(function (e, i) {
|
|
77
|
+
return getProFormListControlsList(item.props.children({}, {}), item.props.name, i, _list);
|
|
78
|
+
});
|
|
79
|
+
return getControlsList([/*#__PURE__*/cloneElement(item, _objectSpread(_objectSpread({}, item.props), {}, {
|
|
80
|
+
children: null,
|
|
81
|
+
value: getObjectPathValue(item.props.name, form)
|
|
82
|
+
}))].concat(_list));
|
|
83
|
+
}
|
|
84
|
+
return getControlsList([/*#__PURE__*/cloneElement(item.props.children, _objectSpread(_objectSpread({}, item.props.children.props), {}, {
|
|
85
|
+
value: getObjectPathValue(item.props.name, form)
|
|
86
|
+
}))]);
|
|
87
|
+
}
|
|
88
|
+
return /*#__PURE__*/cloneElement(item, _objectSpread(_objectSpread({}, item.props), {}, {
|
|
89
|
+
value: [undefined, null].includes(item.props.value) ? getObjectPathValue(item.props.name, form) : item.props.value
|
|
90
|
+
}));
|
|
58
91
|
}).flat();
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return form[item.name] === undefined || form[item.name] instanceof Array && !form[item.name].length;
|
|
67
|
-
};
|
|
68
|
-
if (requiredList.some(condition)) {
|
|
69
|
-
var _requiredList$find, _requiredList$find2;
|
|
70
|
-
return showToast({
|
|
71
|
-
title: ((_requiredList$find = requiredList.find(condition)) === null || _requiredList$find === void 0 || (_requiredList$find = _requiredList$find.rules) === null || _requiredList$find === void 0 || (_requiredList$find = _requiredList$find.find(function (r) {
|
|
92
|
+
}, [form]);
|
|
93
|
+
var validFormRequired = useCallback(function (formList) {
|
|
94
|
+
/* 必填校验 */
|
|
95
|
+
return new Promise(function (resolve, reject) {
|
|
96
|
+
var requiredList = formList.filter(function (item) {
|
|
97
|
+
var _item$rules;
|
|
98
|
+
return (((_item$rules = item.rules) === null || _item$rules === void 0 ? void 0 : _item$rules.some(function (r) {
|
|
72
99
|
return r.required;
|
|
73
|
-
}))
|
|
74
|
-
icon: "error"
|
|
100
|
+
})) || item.required) && !item.hidden && item.name;
|
|
75
101
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
102
|
+
var condition = function condition(item) {
|
|
103
|
+
return [undefined, null, ""].includes(item.value) || item.value instanceof Array && !item.value.length;
|
|
104
|
+
};
|
|
105
|
+
if (requiredList.some(condition)) {
|
|
106
|
+
var _form = requiredList.find(condition);
|
|
107
|
+
if (_form) {
|
|
108
|
+
var _form$rules;
|
|
109
|
+
var message = ((_form$rules = _form.rules) === null || _form$rules === void 0 || (_form$rules = _form$rules.find(function (r) {
|
|
110
|
+
return r.required;
|
|
111
|
+
})) === null || _form$rules === void 0 ? void 0 : _form$rules.message) || _form.label + "必填";
|
|
112
|
+
showToast({
|
|
113
|
+
title: message,
|
|
114
|
+
icon: "none"
|
|
115
|
+
});
|
|
116
|
+
reject(message);
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
resolve();
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}, []);
|
|
123
|
+
var validFormRegExp = useCallback(function (formList) {
|
|
124
|
+
/* 正则校验 */
|
|
125
|
+
return new Promise(function (resolve, reject) {
|
|
126
|
+
var patternList = formList.filter(function (item) {
|
|
127
|
+
var _item$rules2;
|
|
128
|
+
return ((_item$rules2 = item.rules) === null || _item$rules2 === void 0 ? void 0 : _item$rules2.some(function (r) {
|
|
129
|
+
return r.pattern;
|
|
130
|
+
})) && item.name && !item.hidden && item.value;
|
|
131
|
+
});
|
|
132
|
+
var condition = function condition(item) {
|
|
133
|
+
var _item$rules3;
|
|
134
|
+
var list = (_item$rules3 = item.rules) === null || _item$rules3 === void 0 ? void 0 : _item$rules3.filter(function (r) {
|
|
135
|
+
return r.pattern;
|
|
136
|
+
}).map(function (r) {
|
|
137
|
+
r.pattern.lastIndex = 0;
|
|
138
|
+
return r.pattern;
|
|
139
|
+
});
|
|
140
|
+
return list === null || list === void 0 ? void 0 : list.some(function (p) {
|
|
141
|
+
return !(p !== null && p !== void 0 && p.test(item.value));
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
if (patternList.some(condition)) {
|
|
145
|
+
var _form2 = patternList.find(condition);
|
|
146
|
+
if (_form2) {
|
|
147
|
+
var _form2$rules;
|
|
148
|
+
var message = (_form2 === null || _form2 === void 0 || (_form2$rules = _form2.rules) === null || _form2$rules === void 0 || (_form2$rules = _form2$rules.find(function (r) {
|
|
149
|
+
return r.pattern;
|
|
150
|
+
})) === null || _form2$rules === void 0 ? void 0 : _form2$rules.message) || _form2.label + "格式有误";
|
|
151
|
+
showToast({
|
|
152
|
+
title: message,
|
|
153
|
+
icon: "none"
|
|
154
|
+
});
|
|
155
|
+
reject(message);
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
resolve();
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}, []);
|
|
162
|
+
var saveForm = useCallback(function () {
|
|
163
|
+
var formList = getControlsList(children instanceof Array ? children : [children]).map(function (item) {
|
|
164
|
+
return item.props;
|
|
165
|
+
});
|
|
166
|
+
validFormRequired(formList);
|
|
167
|
+
validFormRegExp(formList);
|
|
168
|
+
Promise.all([validFormRequired(formList), validFormRegExp(formList)]).then(function () {
|
|
169
|
+
return onOk === null || onOk === void 0 ? void 0 : onOk(form);
|
|
170
|
+
});
|
|
171
|
+
}, [form]);
|
|
172
|
+
var renderContent = useCallback(function () {
|
|
173
|
+
var elementList = children instanceof Array ? children : [children];
|
|
174
|
+
return elementList.map(function (e, i) {
|
|
175
|
+
return /*#__PURE__*/cloneElement(e, _objectSpread(_objectSpread({}, e.props), {}, {
|
|
176
|
+
key: 'p-pro-form-group-' + i,
|
|
177
|
+
disabled: disabled || e.props.disabled,
|
|
178
|
+
form: form,
|
|
179
|
+
onChange: function onChange(key, value) {
|
|
180
|
+
return setForm(function (form) {
|
|
181
|
+
setObjectPathValue(key, value, form);
|
|
182
|
+
return _objectSpread({}, form);
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}));
|
|
186
|
+
});
|
|
187
|
+
}, [form, children, disabled]);
|
|
79
188
|
return /*#__PURE__*/React.createElement(View, {
|
|
80
189
|
className: "p-pro-form-container ".concat(className)
|
|
81
190
|
}, /*#__PURE__*/React.createElement(ScrollView, {
|
|
@@ -86,24 +195,12 @@ var ProForm = function ProForm(_ref) {
|
|
|
86
195
|
showScrollbar: false
|
|
87
196
|
}, /*#__PURE__*/React.createElement(View, {
|
|
88
197
|
className: "p-pro-form-scroll-view-content"
|
|
89
|
-
},
|
|
90
|
-
return /*#__PURE__*/cloneElement(e, {
|
|
91
|
-
key: 'p-pro-form-group-' + i,
|
|
92
|
-
disabled: disabled || e.props.disabled,
|
|
93
|
-
initialValues: form,
|
|
94
|
-
onChange: function onChange(key, value) {
|
|
95
|
-
return setForm(function (form) {
|
|
96
|
-
form[key] = value;
|
|
97
|
-
return _objectSpread({}, form);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
}))), (onOk || onSave || onDelete) && /*#__PURE__*/React.createElement(View, {
|
|
198
|
+
}, renderContent())), (onOk || onSave || onDelete || footer) && /*#__PURE__*/React.createElement(View, {
|
|
102
199
|
className: "p-pro-form-footer",
|
|
103
200
|
style: {
|
|
104
201
|
paddingBottom: "".concat(bottom - height > 24 ? bottom - height : 24, "rpx")
|
|
105
202
|
}
|
|
106
|
-
}, onSave || onDelete ? /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(View, {
|
|
203
|
+
}, footer ? footer : onSave || onDelete ? /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(View, {
|
|
107
204
|
className: "button-group"
|
|
108
205
|
}, onDelete && /*#__PURE__*/React.createElement(ActionSheet, {
|
|
109
206
|
options: [{
|
|
@@ -142,4 +239,4 @@ var ProForm = function ProForm(_ref) {
|
|
|
142
239
|
onTap: saveForm
|
|
143
240
|
}, "\u4FDD\u5B58")));
|
|
144
241
|
};
|
|
145
|
-
export default ProForm;
|
|
242
|
+
export default /*#__PURE__*/forwardRef(ProForm);
|
|
@@ -4,58 +4,44 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
-
|
|
8
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
-
import React, { cloneElement, useEffect, useState } from "react";
|
|
7
|
+
import React, { cloneElement, useCallback } from "react";
|
|
14
8
|
import { Text, View } from "@tarojs/components";
|
|
15
|
-
import { getListAssignField } from "../..";
|
|
9
|
+
import { getListAssignField, getObjectPathValue } from "../..";
|
|
16
10
|
import "./index.less";
|
|
17
11
|
var ProFormGroup = function ProFormGroup(_ref) {
|
|
18
|
-
var
|
|
19
|
-
|
|
12
|
+
var className = _ref.className,
|
|
13
|
+
hidden = _ref.hidden,
|
|
14
|
+
tag = _ref.tag,
|
|
15
|
+
form = _ref.form,
|
|
20
16
|
children = _ref.children,
|
|
21
17
|
disabled = _ref.disabled,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
18
|
+
_onChange = _ref.onChange;
|
|
19
|
+
var renderContent = useCallback(function () {
|
|
20
|
+
var elementList = children instanceof Array ? children : [children];
|
|
21
|
+
return elementList.map(function (e, i) {
|
|
22
|
+
return /*#__PURE__*/cloneElement(e, _objectSpread(_objectSpread({}, e.props), {}, {
|
|
23
|
+
key: e.props.name,
|
|
24
|
+
className: "".concat(e.props["className"], " ").concat(i === elementList.length - 1 ? 'p-pro-form-item-last' : ""),
|
|
25
|
+
disabled: disabled || e.props.disabled,
|
|
26
|
+
hidden: hidden || e.props.hidden,
|
|
27
|
+
value: form && getObjectPathValue(e.props.name, form),
|
|
28
|
+
onChange: function onChange(value) {
|
|
29
|
+
var _e$props$onChange, _e$props;
|
|
30
|
+
(_e$props$onChange = (_e$props = e.props).onChange) === null || _e$props$onChange === void 0 || _e$props$onChange.call(_e$props, value);
|
|
31
|
+
_onChange === null || _onChange === void 0 || _onChange(e.props.name, value);
|
|
32
|
+
},
|
|
33
|
+
getFormValue: function getFormValue(key) {
|
|
34
|
+
return form === null || form === void 0 ? void 0 : form[key];
|
|
35
|
+
}
|
|
36
|
+
}));
|
|
37
|
+
});
|
|
38
|
+
}, [form, children, disabled, hidden]);
|
|
37
39
|
return /*#__PURE__*/React.createElement(View, {
|
|
38
40
|
className: "p-pro-form-group-container ".concat(className, " ").concat(hidden ? 'hidden' : '')
|
|
39
|
-
},
|
|
40
|
-
return /*#__PURE__*/cloneElement(e, {
|
|
41
|
-
key: e.props.name,
|
|
42
|
-
className: "".concat(e.props["className"], " ").concat(i === elementList.length - 1 ? 'p-pro-form-item-last' : ""),
|
|
43
|
-
disabled: disabled || e.props.disabled,
|
|
44
|
-
hidden: hidden || e.props.hidden,
|
|
45
|
-
value: initialValues === null || initialValues === void 0 ? void 0 : initialValues[e.props.name],
|
|
46
|
-
onChange: function onChange(value) {
|
|
47
|
-
var _e$props$onChange, _e$props;
|
|
48
|
-
(_e$props$onChange = (_e$props = e.props).onChange) === null || _e$props$onChange === void 0 || _e$props$onChange.call(_e$props, value);
|
|
49
|
-
_onChange === null || _onChange === void 0 || _onChange(e.props.name, value);
|
|
50
|
-
},
|
|
51
|
-
getFormValue: function getFormValue(key) {
|
|
52
|
-
return initialValues === null || initialValues === void 0 ? void 0 : initialValues[key];
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}), tag && (initialValues === null || initialValues === void 0 ? void 0 : initialValues[tag.dataIndex]) && /*#__PURE__*/React.createElement(View, {
|
|
41
|
+
}, renderContent(), tag && (form === null || form === void 0 ? void 0 : form[tag.dataIndex]) && /*#__PURE__*/React.createElement(View, {
|
|
56
42
|
className: "p-pro-form-group-tag ".concat(tag.className || ""),
|
|
57
43
|
style: _objectSpread(_objectSpread({}, tag.position), {}, {
|
|
58
|
-
backgroundColor: getListAssignField(
|
|
44
|
+
backgroundColor: getListAssignField(form[tag.dataIndex], tag.map, {
|
|
59
45
|
value: "value",
|
|
60
46
|
label: "background"
|
|
61
47
|
})
|
|
@@ -63,11 +49,11 @@ var ProFormGroup = function ProFormGroup(_ref) {
|
|
|
63
49
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
64
50
|
className: "p-pro-form-group-tag-text",
|
|
65
51
|
style: {
|
|
66
|
-
color: getListAssignField(
|
|
52
|
+
color: getListAssignField(form[tag.dataIndex], tag.map, {
|
|
67
53
|
value: "value",
|
|
68
54
|
label: "color"
|
|
69
55
|
})
|
|
70
56
|
}
|
|
71
|
-
}, getListAssignField(
|
|
57
|
+
}, getListAssignField(form[tag.dataIndex], tag.map))));
|
|
72
58
|
};
|
|
73
59
|
export default ProFormGroup;
|
package/dist/ProForm/index.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import OriginProForm from "./Form";
|
|
2
2
|
import ProFormGroup from "./Group";
|
|
3
|
-
import ProFormField from "./Field";
|
|
4
3
|
type ProFormType = typeof OriginProForm & {
|
|
5
4
|
Group: typeof ProFormGroup;
|
|
6
|
-
Field: typeof ProFormField;
|
|
7
5
|
};
|
|
8
6
|
declare const ProForm: ProFormType;
|
|
9
7
|
export default ProForm;
|
|
@@ -10,10 +10,12 @@ declare namespace ProFormAPI {
|
|
|
10
10
|
onOk?: (result: { [key: string]: any }) => void;
|
|
11
11
|
onDelete?: false | ((result: { [key: string]: any }) => void);
|
|
12
12
|
onSave?: false | ((result: { [key: string]: any }) => void);
|
|
13
|
+
onChange?: (form: { [key: string]: any }) => void;
|
|
14
|
+
onValueChange?: (field: string, value: { [key: string]: any }) => void;
|
|
13
15
|
};
|
|
14
16
|
|
|
15
17
|
type IOptionItem = {
|
|
16
|
-
value: string;
|
|
18
|
+
value: string | boolean | number | null;
|
|
17
19
|
label: string;
|
|
18
20
|
color?: string;
|
|
19
21
|
background?: string;
|
|
@@ -23,7 +25,7 @@ declare namespace ProFormAPI {
|
|
|
23
25
|
onChange?: (key: string, value: any) => void;
|
|
24
26
|
className?: string;
|
|
25
27
|
disabled?: boolean;
|
|
26
|
-
|
|
28
|
+
form?: { [key: string]: any };
|
|
27
29
|
hidden?: boolean;
|
|
28
30
|
tag?: {
|
|
29
31
|
dataIndex: string;
|
|
@@ -77,13 +79,24 @@ declare namespace ProFormAPI {
|
|
|
77
79
|
idcardpad
|
|
78
80
|
}
|
|
79
81
|
|
|
82
|
+
type ProFormItemRule = {
|
|
83
|
+
/* 消息提示 */
|
|
84
|
+
message?: string;
|
|
85
|
+
/* 校验正则 */
|
|
86
|
+
pattern?: RegExp;
|
|
87
|
+
/* 是否必填 */
|
|
88
|
+
required?: boolean;
|
|
89
|
+
}
|
|
90
|
+
|
|
80
91
|
type ProFormItemProps = {
|
|
92
|
+
/* flex占比 */
|
|
93
|
+
flex?: number;
|
|
81
94
|
/* 对齐方式 */
|
|
82
95
|
layout?: "horizontal" | "vertical";
|
|
83
96
|
/* 表单Key */
|
|
84
|
-
name?: string;
|
|
97
|
+
name?: string | string[];
|
|
85
98
|
/* 表单文字 */
|
|
86
|
-
label?:
|
|
99
|
+
label?: any;
|
|
87
100
|
/* 依赖字段 */
|
|
88
101
|
dependencies?: string;
|
|
89
102
|
/* 是否隐藏字段 */
|
|
@@ -93,14 +106,7 @@ declare namespace ProFormAPI {
|
|
|
93
106
|
/* 是否必填 */
|
|
94
107
|
required?: boolean;
|
|
95
108
|
/* 校验规则 */
|
|
96
|
-
rules?:
|
|
97
|
-
/* 消息提示 */
|
|
98
|
-
message?: string;
|
|
99
|
-
/* 校验正则 */
|
|
100
|
-
pattern?: RegExp;
|
|
101
|
-
/* 是否必填 */
|
|
102
|
-
required?: boolean;
|
|
103
|
-
}[];
|
|
109
|
+
rules?: ProFormItemRule[];
|
|
104
110
|
/* 自定义字段更新 */
|
|
105
111
|
shouldUpdate?: boolean | ((prevValue: any, curValue: any) => boolean);
|
|
106
112
|
/* 类名 */
|
|
@@ -157,8 +163,4 @@ declare namespace ProFormAPI {
|
|
|
157
163
|
/* 推荐内容 */
|
|
158
164
|
recommend?: string[];
|
|
159
165
|
}
|
|
160
|
-
|
|
161
|
-
type ProFormListProps = {
|
|
162
|
-
|
|
163
|
-
}
|
|
164
166
|
}
|
package/dist/ProList/index.d.ts
CHANGED
package/dist/ProList/index.js
CHANGED
|
@@ -13,6 +13,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
13
13
|
import React, { forwardRef, Fragment, useCallback, useEffect, useImperativeHandle, useState } from "react";
|
|
14
14
|
import { Image, ScrollView, Swiper, SwiperItem, Text, View } from "@tarojs/components";
|
|
15
15
|
import { getListAssignField, getSimplifyDay, Skeleton } from "./..";
|
|
16
|
+
import { useDebounceEffect } from "ahooks";
|
|
16
17
|
import { useConfig } from "../ConfigProvider";
|
|
17
18
|
import { FileController } from "../services";
|
|
18
19
|
import "./index.less";
|
|
@@ -48,36 +49,57 @@ var ProList = function ProList(_ref, ref) {
|
|
|
48
49
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
49
50
|
loading = _useState4[0],
|
|
50
51
|
setLoading = _useState4[1];
|
|
51
|
-
/*
|
|
52
|
-
var _useState5 = useState(
|
|
52
|
+
/* 过滤条件 */
|
|
53
|
+
var _useState5 = useState({}),
|
|
53
54
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
/*
|
|
57
|
-
var _useState7 = useState(
|
|
55
|
+
filterParams = _useState6[0],
|
|
56
|
+
_setFilterParams = _useState6[1];
|
|
57
|
+
/* 数据列表 */
|
|
58
|
+
var _useState7 = useState([]),
|
|
58
59
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
list = _useState8[0],
|
|
61
|
+
setList = _useState8[1];
|
|
62
|
+
/* 数据总量 */
|
|
63
|
+
var _useState9 = useState(0),
|
|
64
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
65
|
+
total = _useState10[0],
|
|
66
|
+
setTotal = _useState10[1];
|
|
61
67
|
useEffect(function () {
|
|
62
68
|
if (dataSources instanceof Array) {
|
|
63
69
|
setList(dataSources);
|
|
64
70
|
setLoading(false);
|
|
65
|
-
} else {
|
|
66
|
-
getList(1);
|
|
67
71
|
}
|
|
68
72
|
}, [dataSources]);
|
|
69
73
|
useEffect(function () {
|
|
70
74
|
if (refreshing) getList(1);
|
|
71
75
|
}, [refreshing]);
|
|
76
|
+
useEffect(function () {
|
|
77
|
+
if (params) _setFilterParams(_objectSpread({}, params));
|
|
78
|
+
}, [params]);
|
|
79
|
+
useDebounceEffect(function () {
|
|
80
|
+
if (!(dataSources instanceof Array)) {
|
|
81
|
+
setLoading(true);
|
|
82
|
+
getList(1);
|
|
83
|
+
}
|
|
84
|
+
}, [filterParams], {
|
|
85
|
+
wait: 200
|
|
86
|
+
});
|
|
72
87
|
useImperativeHandle(ref, function () {
|
|
73
88
|
return {
|
|
74
89
|
onRefresh: function onRefresh() {
|
|
75
90
|
return setRefreshing(true);
|
|
91
|
+
},
|
|
92
|
+
setFilterParams: function setFilterParams(p) {
|
|
93
|
+
if ("{}" === JSON.stringify(p)) {
|
|
94
|
+
_setFilterParams(params || {});
|
|
95
|
+
} else {
|
|
96
|
+
_setFilterParams(_objectSpread(_objectSpread({}, filterParams), p));
|
|
97
|
+
}
|
|
76
98
|
}
|
|
77
99
|
};
|
|
78
100
|
});
|
|
79
101
|
var getList = useCallback(function (current) {
|
|
80
|
-
request === null || request === void 0 || request(_objectSpread(_objectSpread({},
|
|
102
|
+
request === null || request === void 0 || request(_objectSpread(_objectSpread({}, filterParams), {}, {
|
|
81
103
|
current: current,
|
|
82
104
|
size: size
|
|
83
105
|
})).then(function (result) {
|
|
@@ -100,18 +122,18 @@ var ProList = function ProList(_ref, ref) {
|
|
|
100
122
|
});
|
|
101
123
|
setList(current === 1 ? dataList : list.concat(dataList));
|
|
102
124
|
setTotal(total);
|
|
103
|
-
|
|
125
|
+
setLoading(false);
|
|
104
126
|
if (refreshing) setRefreshing(false);
|
|
105
127
|
}
|
|
106
128
|
});
|
|
107
129
|
} else {
|
|
108
130
|
setList(current === 1 ? dataList : list.concat(dataList));
|
|
109
131
|
setTotal(total);
|
|
110
|
-
|
|
132
|
+
setLoading(false);
|
|
111
133
|
if (refreshing) setRefreshing(false);
|
|
112
134
|
}
|
|
113
135
|
});
|
|
114
|
-
}, [refreshing]);
|
|
136
|
+
}, [refreshing, filterParams, loading, list]);
|
|
115
137
|
var renderSkeleton = useCallback(function () {
|
|
116
138
|
return Array(size).fill(null).map(function (item, index) {
|
|
117
139
|
var _meta$tag, _meta$tag2, _meta$fileList, _meta$fileList2, _meta$title, _meta$title2, _meta$subTitle, _meta$subTitle2, _meta$fileList3, _meta$fileList4;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Input, View } from "@tarojs/components";
|
|
3
|
+
import "./index.less";
|
|
4
|
+
var SearchInput = function SearchInput(_ref) {
|
|
5
|
+
var className = _ref.className,
|
|
6
|
+
placeholder = _ref.placeholder,
|
|
7
|
+
onSearch = _ref.onSearch;
|
|
8
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
9
|
+
className: "p-search-input-container ".concat(className)
|
|
10
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
11
|
+
className: "iconfont icon-icon-psp-sousuo"
|
|
12
|
+
}), /*#__PURE__*/React.createElement(Input, {
|
|
13
|
+
placeholder: placeholder || "搜索",
|
|
14
|
+
confirmType: "search",
|
|
15
|
+
onConfirm: function onConfirm(e) {
|
|
16
|
+
return onSearch(e.detail.value);
|
|
17
|
+
},
|
|
18
|
+
placeholderClass: "p-search-input-placeholder",
|
|
19
|
+
className: "p-search-input"
|
|
20
|
+
}));
|
|
21
|
+
};
|
|
22
|
+
export default SearchInput;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
@import "@power-xa/m-ui/dist/assets/less/mixins.less";
|
|
2
|
+
|
|
3
|
+
.p-search-input-container {
|
|
4
|
+
padding: 18px 32px;
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
background: #fff;
|
|
9
|
+
border-radius: 100px;
|
|
10
|
+
gap: 12px;
|
|
11
|
+
|
|
12
|
+
.iconfont {
|
|
13
|
+
font-size: 24px;
|
|
14
|
+
color: #333437;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.p-search-input {
|
|
18
|
+
flex: 1;
|
|
19
|
+
width: 0;
|
|
20
|
+
height: 40px;
|
|
21
|
+
min-height: 40px;
|
|
22
|
+
.font(28, #333437);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.p-search-input-placeholder {
|
|
26
|
+
display: block;
|
|
27
|
+
.font(28, #999);
|
|
28
|
+
}
|
|
29
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -15,11 +15,14 @@ export { default as ConfigProvider } from './ConfigProvider';
|
|
|
15
15
|
export { default as CreatorEdit } from './CreatorEdit';
|
|
16
16
|
export { default as Empty } from './Empty';
|
|
17
17
|
export { default as ActionSheet } from './ActionSheet';
|
|
18
|
+
export { default as DatePicker } from './DatePicker';
|
|
19
|
+
export { default as Filter } from './Filter';
|
|
20
|
+
export { default as SearchInput } from './SearchInput';
|
|
18
21
|
export { default as ProForm } from './ProForm';
|
|
19
|
-
export { default as ProFormText } from './ProForm/
|
|
20
|
-
export { default as ProFormTextArea } from './ProForm/
|
|
21
|
-
export { default as ProFormDate } from './ProForm/
|
|
22
|
-
export { default as ProFormUpload } from './ProForm/
|
|
23
|
-
export { default as ProFormSelect } from './ProForm/
|
|
24
|
-
export { default as ProFormList } from './ProForm/
|
|
25
|
-
export { getQueryParams, getListAssignField, dateFormat, getSimplifyDay, getUUID, getFileExt, getFileType, clipFileUrl } from "./utils/tools";
|
|
22
|
+
export { default as ProFormText } from './ProForm/Controls/Text';
|
|
23
|
+
export { default as ProFormTextArea } from './ProForm/Controls/TextArea';
|
|
24
|
+
export { default as ProFormDate } from './ProForm/Controls/Date';
|
|
25
|
+
export { default as ProFormUpload } from './ProForm/Controls/Upload';
|
|
26
|
+
export { default as ProFormSelect } from './ProForm/Controls/Select';
|
|
27
|
+
export { default as ProFormList } from './ProForm/Controls/List';
|
|
28
|
+
export { getQueryParams, getListAssignField, dateFormat, getSimplifyDay, getUUID, getFileExt, getFileType, clipFileUrl, getObjectPathValue, setObjectPathValue } from "./utils/tools";
|