@power-xa/m-ui 0.0.1 → 0.0.2

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.
Files changed (51) hide show
  1. package/dist/ActionSheet/index.less +2 -1
  2. package/dist/Button/index.js +1 -1
  3. package/dist/CreatorEdit/index.js +2 -1
  4. package/dist/DatePicker/index.d.ts +13 -0
  5. package/dist/DatePicker/index.js +150 -0
  6. package/dist/DatePicker/index.less +35 -0
  7. package/dist/Filter/index.d.ts +13 -0
  8. package/dist/Filter/index.js +77 -0
  9. package/dist/Filter/index.less +78 -0
  10. package/dist/FloatButton/index.js +24 -19
  11. package/dist/Popup/index.js +8 -1
  12. package/dist/Popup/index.less +1 -0
  13. package/dist/ProForm/{controls → Controls}/Date/index.js +23 -8
  14. package/dist/ProForm/Controls/List/index.d.ts +30 -0
  15. package/dist/ProForm/Controls/List/index.js +130 -0
  16. package/dist/ProForm/{controls → Controls}/List/index.less +31 -0
  17. package/dist/ProForm/{controls → Controls}/Select/index.js +23 -13
  18. package/dist/ProForm/{controls → Controls}/Select/index.less +6 -0
  19. package/dist/ProForm/Controls/Text/index.js +45 -0
  20. package/dist/ProForm/{controls → Controls}/TextArea/index.js +14 -4
  21. package/dist/ProForm/{controls → Controls}/Upload/index.js +5 -1
  22. package/dist/ProForm/Field/index.d.ts +2 -1
  23. package/dist/ProForm/Field/index.js +1 -1
  24. package/dist/ProForm/Field/index.less +2 -0
  25. package/dist/ProForm/Form/index.d.ts +6 -6
  26. package/dist/ProForm/Form/index.js +123 -49
  27. package/dist/ProForm/Group/index.js +31 -45
  28. package/dist/ProForm/index.d.ts +0 -2
  29. package/dist/ProForm/typings.d.ts +18 -16
  30. package/dist/ProList/index.d.ts +1 -1
  31. package/dist/ProList/index.js +36 -14
  32. package/dist/SearchInput/index.d.ts +9 -0
  33. package/dist/SearchInput/index.js +22 -0
  34. package/dist/SearchInput/index.less +29 -0
  35. package/dist/index.d.ts +10 -7
  36. package/dist/index.js +10 -7
  37. package/dist/request/index.js +1 -1
  38. package/dist/utils/tools.d.ts +11 -1
  39. package/dist/utils/tools.js +43 -9
  40. package/package.json +1 -1
  41. package/dist/ProForm/controls/List/index.d.ts +0 -23
  42. package/dist/ProForm/controls/List/index.js +0 -77
  43. package/dist/ProForm/controls/Text/index.js +0 -29
  44. /package/dist/ProForm/{controls → Controls}/Date/index.d.ts +0 -0
  45. /package/dist/ProForm/{controls → Controls}/Select/index.d.ts +0 -0
  46. /package/dist/ProForm/{controls → Controls}/Text/index.d.ts +0 -0
  47. /package/dist/ProForm/{controls → Controls}/Text/index.less +0 -0
  48. /package/dist/ProForm/{controls → Controls}/TextArea/index.d.ts +0 -0
  49. /package/dist/ProForm/{controls → Controls}/TextArea/index.less +0 -0
  50. /package/dist/ProForm/{controls → Controls}/Upload/index.d.ts +0 -0
  51. /package/dist/ProForm/{controls → Controls}/Upload/index.less +0 -0
@@ -10,72 +10,158 @@ 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";
14
- import { getWindowInfo, showToast } from "@tarojs/taro";
13
+ import React, { cloneElement, forwardRef, Fragment, useCallback, useEffect, useImperativeHandle, useState } from "react";
14
+ import { getWindowInfo, showToast, showLoading } 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 children = _ref.children,
20
- _ref$className = _ref.className,
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
- elementList = _useState2[0],
36
- setElementList = _useState2[1];
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
- useEffect(function () {
47
- if (children instanceof Array) {
48
- setElementList(children);
49
- } else {
50
- setElementList([children]);
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
- }, [children]);
53
- var saveForm = useCallback(function () {
54
- var controlList = elementList.map(function (e) {
55
- return e.props.children instanceof Array ? e.props.children.map(function (c) {
56
- return c.props;
57
- }) : [e.props.children];
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();
92
+ }, [form]);
93
+ var saveForm = useCallback(function () {
94
+ var controlList = getControlsList(children instanceof Array ? children : [children]);
95
+ /* 必填校验 */
59
96
  var requiredList = controlList.filter(function (item) {
60
- var _item$rules;
61
- return item.name && !item.hidden && (item.required || ((_item$rules = item.rules) === null || _item$rules === void 0 ? void 0 : _item$rules.some(function (r) {
97
+ var _item$props$rules;
98
+ return item.props.name && !item.props.hidden && (item.props.required || ((_item$props$rules = item.props.rules) === null || _item$props$rules === void 0 ? void 0 : _item$props$rules.some(function (r) {
62
99
  return r.required;
63
100
  })));
64
101
  });
65
- var condition = function condition(item) {
66
- return form[item.name] === undefined || form[item.name] instanceof Array && !form[item.name].length;
102
+ var condition = function condition(e) {
103
+ return [undefined, null, ""].includes(e.props.value) || e.props.value instanceof Array && !e.props.value.length;
67
104
  };
68
105
  if (requiredList.some(condition)) {
69
- var _requiredList$find, _requiredList$find2;
106
+ var _e$props$rules;
107
+ var e = requiredList.find(condition);
70
108
  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) {
109
+ title: (e === null || e === void 0 || (_e$props$rules = e.props.rules) === null || _e$props$rules === void 0 || (_e$props$rules = _e$props$rules.find(function (r) {
72
110
  return r.required;
73
- })) === null || _requiredList$find === void 0 ? void 0 : _requiredList$find.message) || ((_requiredList$find2 = requiredList.find(condition)) === null || _requiredList$find2 === void 0 ? void 0 : _requiredList$find2.label) + "必填",
74
- icon: "error"
111
+ })) === null || _e$props$rules === void 0 ? void 0 : _e$props$rules.message) || (e === null || e === void 0 ? void 0 : e.props.label) + "必填",
112
+ icon: "none"
75
113
  });
76
114
  }
115
+ /* 正则校验 */
116
+ var patternControlList = controlList.filter(function (item) {
117
+ var _item$props$rules2;
118
+ return item.props.name && item.props.value && !item.props.hidden && ((_item$props$rules2 = item.props.rules) === null || _item$props$rules2 === void 0 ? void 0 : _item$props$rules2.some(function (r) {
119
+ return r.pattern;
120
+ }));
121
+ });
122
+ var patternCondition = function patternCondition(e) {
123
+ var patternList = e.props.rules.filter(function (r) {
124
+ return r.pattern;
125
+ }).map(function (p) {
126
+ return p.pattern;
127
+ });
128
+ if (patternList.some(function (p) {
129
+ return !p.test(e.props.value);
130
+ })) return true;
131
+ return false;
132
+ };
133
+ if (patternControlList.some(patternCondition)) {
134
+ var _e$props$rules2;
135
+ var _e = patternControlList.find(patternCondition);
136
+ if (_e) return showToast({
137
+ title: (_e === null || _e === void 0 || (_e$props$rules2 = _e.props.rules) === null || _e$props$rules2 === void 0 || (_e$props$rules2 = _e$props$rules2.find(function (r) {
138
+ return r.pattern;
139
+ })) === null || _e$props$rules2 === void 0 ? void 0 : _e$props$rules2.message) || (_e === null || _e === void 0 ? void 0 : _e.props.label) + "格式有误",
140
+ icon: "none"
141
+ });
142
+ }
143
+ showLoading({
144
+ title: "保存中",
145
+ mask: true
146
+ });
77
147
  onOk === null || onOk === void 0 || onOk(form);
78
- }, [elementList, form]);
148
+ }, [form]);
149
+ var renderContent = useCallback(function () {
150
+ var elementList = children instanceof Array ? children : [children];
151
+ return elementList.map(function (e, i) {
152
+ return /*#__PURE__*/cloneElement(e, _objectSpread(_objectSpread({}, e.props), {}, {
153
+ key: 'p-pro-form-group-' + i,
154
+ disabled: disabled || e.props.disabled,
155
+ form: form,
156
+ onChange: function onChange(key, value) {
157
+ return setForm(function (form) {
158
+ setObjectPathValue(key, value, form);
159
+ return _objectSpread({}, form);
160
+ });
161
+ }
162
+ }));
163
+ });
164
+ }, [form, children, disabled]);
79
165
  return /*#__PURE__*/React.createElement(View, {
80
166
  className: "p-pro-form-container ".concat(className)
81
167
  }, /*#__PURE__*/React.createElement(ScrollView, {
@@ -86,24 +172,12 @@ var ProForm = function ProForm(_ref) {
86
172
  showScrollbar: false
87
173
  }, /*#__PURE__*/React.createElement(View, {
88
174
  className: "p-pro-form-scroll-view-content"
89
- }, elementList.map(function (e, i) {
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, {
175
+ }, renderContent())), (onOk || onSave || onDelete || footer) && /*#__PURE__*/React.createElement(View, {
102
176
  className: "p-pro-form-footer",
103
177
  style: {
104
178
  paddingBottom: "".concat(bottom - height > 24 ? bottom - height : 24, "rpx")
105
179
  }
106
- }, onSave || onDelete ? /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(View, {
180
+ }, footer ? footer : onSave || onDelete ? /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(View, {
107
181
  className: "button-group"
108
182
  }, onDelete && /*#__PURE__*/React.createElement(ActionSheet, {
109
183
  options: [{
@@ -142,4 +216,4 @@ var ProForm = function ProForm(_ref) {
142
216
  onTap: saveForm
143
217
  }, "\u4FDD\u5B58")));
144
218
  };
145
- export default ProForm;
219
+ 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
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
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 _ref$className = _ref.className,
19
- className = _ref$className === void 0 ? "" : _ref$className,
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
- initialValues = _ref.initialValues,
23
- _onChange = _ref.onChange,
24
- hidden = _ref.hidden,
25
- tag = _ref.tag;
26
- var _useState = useState([]),
27
- _useState2 = _slicedToArray(_useState, 2),
28
- elementList = _useState2[0],
29
- setElementList = _useState2[1];
30
- useEffect(function () {
31
- if (children instanceof Array) {
32
- setElementList(children);
33
- } else {
34
- setElementList([children]);
35
- }
36
- }, [children]);
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
- }, elementList.map(function (e, i) {
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(initialValues[tag.dataIndex], tag.map, {
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(initialValues[tag.dataIndex], tag.map, {
52
+ color: getListAssignField(form[tag.dataIndex], tag.map, {
67
53
  value: "value",
68
54
  label: "color"
69
55
  })
70
56
  }
71
- }, getListAssignField(initialValues[tag.dataIndex], tag.map))));
57
+ }, getListAssignField(form[tag.dataIndex], tag.map))));
72
58
  };
73
59
  export default ProFormGroup;
@@ -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
- initialValues?: { [key: string]: any };
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?: string;
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
  }
@@ -58,7 +58,7 @@ export type ProListProps = {
58
58
  tag?: MetaProps & {
59
59
  map?: {
60
60
  label: string;
61
- value: string;
61
+ value: string | boolean | number | null;
62
62
  color?: string;
63
63
  background?: string;
64
64
  }[];
@@ -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
- list = _useState6[0],
55
- setList = _useState6[1];
56
- /* 数据总量 */
57
- var _useState7 = useState(0),
55
+ filterParams = _useState6[0],
56
+ _setFilterParams = _useState6[1];
57
+ /* 数据列表 */
58
+ var _useState7 = useState([]),
58
59
  _useState8 = _slicedToArray(_useState7, 2),
59
- total = _useState8[0],
60
- setTotal = _useState8[1];
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({}, params), {}, {
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
- if (loading) setLoading(false);
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
- if (loading) setLoading(false);
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,9 @@
1
+ import { FC } from "react";
2
+ import "./index.less";
3
+ type SearchInputProps = {
4
+ className?: string;
5
+ placeholder?: string;
6
+ onSearch: (value: string) => void;
7
+ };
8
+ declare const SearchInput: FC<SearchInputProps>;
9
+ export default SearchInput;
@@ -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/controls/Text';
20
- export { default as ProFormTextArea } from './ProForm/controls/TextArea';
21
- export { default as ProFormDate } from './ProForm/controls/Date';
22
- export { default as ProFormUpload } from './ProForm/controls/Upload';
23
- export { default as ProFormSelect } from './ProForm/controls/Select';
24
- export { default as ProFormList } from './ProForm/controls/List';
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";
package/dist/index.js CHANGED
@@ -15,13 +15,16 @@ 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
 
19
22
  /* Form相关 */
20
23
  export { default as ProForm } from "./ProForm";
21
- export { default as ProFormText } from "./ProForm/controls/Text";
22
- export { default as ProFormTextArea } from "./ProForm/controls/TextArea";
23
- export { default as ProFormDate } from "./ProForm/controls/Date";
24
- export { default as ProFormUpload } from "./ProForm/controls/Upload";
25
- export { default as ProFormSelect } from "./ProForm/controls/Select";
26
- export { default as ProFormList } from "./ProForm/controls/List";
27
- export { getQueryParams, getListAssignField, dateFormat, getSimplifyDay, getUUID, getFileExt, getFileType, clipFileUrl } from "./utils/tools";
24
+ export { default as ProFormText } from "./ProForm/Controls/Text";
25
+ export { default as ProFormTextArea } from "./ProForm/Controls/TextArea";
26
+ export { default as ProFormDate } from "./ProForm/Controls/Date";
27
+ export { default as ProFormUpload } from "./ProForm/Controls/Upload";
28
+ export { default as ProFormSelect } from "./ProForm/Controls/Select";
29
+ export { default as ProFormList } from "./ProForm/Controls/List";
30
+ export { getQueryParams, getListAssignField, dateFormat, getSimplifyDay, getUUID, getFileExt, getFileType, clipFileUrl, getObjectPathValue, setObjectPathValue } from "./utils/tools";
@@ -41,7 +41,7 @@ var request = function request(url, body) {
41
41
  /* 接口报错,仅提示错误信息 */
42
42
  showToast({
43
43
  title: data.msg,
44
- icon: "error"
44
+ icon: "none"
45
45
  });
46
46
  return reject(data);
47
47
  break;