@power-xa/m-ui 0.0.6 → 0.0.8

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 (87) hide show
  1. package/README.md +37 -17
  2. package/dist/ActionSheet/index.js +5 -3
  3. package/dist/Breadcrumb/index.js +4 -2
  4. package/dist/Calendar/Date/index.d.ts +8 -0
  5. package/dist/Calendar/Date/index.js +246 -0
  6. package/dist/Calendar/Date/index.less +146 -0
  7. package/dist/Calendar/Month/index.d.ts +7 -0
  8. package/dist/Calendar/Month/index.js +199 -0
  9. package/dist/Calendar/Month/index.less +96 -0
  10. package/dist/Calendar/Week/index.d.ts +7 -0
  11. package/dist/Calendar/Week/index.js +200 -0
  12. package/dist/Calendar/Week/index.less +96 -0
  13. package/dist/Calendar/index.d.ts +10 -0
  14. package/dist/Calendar/index.js +9 -0
  15. package/dist/ConfigProvider/index.d.ts +1 -0
  16. package/dist/Drawer/index.d.ts +1 -0
  17. package/dist/Drawer/index.js +38 -20
  18. package/dist/Drawer/index.less +2 -1
  19. package/dist/Filter/index.d.ts +3 -0
  20. package/dist/Filter/index.js +8 -6
  21. package/dist/ProForm/Controls/Cascader/index.d.ts +28 -0
  22. package/dist/ProForm/Controls/Cascader/index.js +159 -0
  23. package/dist/ProForm/Controls/Cascader/index.less +106 -0
  24. package/dist/ProForm/Controls/Date/index.d.ts +6 -1
  25. package/dist/ProForm/Controls/Date/index.js +12 -4
  26. package/dist/ProForm/Controls/Date/index.less +18 -0
  27. package/dist/ProForm/Controls/List/index.d.ts +2 -8
  28. package/dist/ProForm/Controls/List/index.js +17 -9
  29. package/dist/ProForm/Controls/List/index.less +0 -0
  30. package/dist/ProForm/Controls/Select/index.d.ts +50 -1
  31. package/dist/ProForm/Controls/Select/index.js +289 -211
  32. package/dist/ProForm/Controls/Select/index.less +29 -0
  33. package/dist/ProForm/Controls/Stepper/index.d.ts +10 -0
  34. package/dist/ProForm/Controls/Stepper/index.js +72 -0
  35. package/dist/ProForm/Controls/Stepper/index.less +31 -0
  36. package/dist/ProForm/Controls/Switch/index.d.ts +5 -0
  37. package/dist/ProForm/Controls/Switch/index.js +21 -0
  38. package/dist/ProForm/Controls/Switch/index.less +3 -0
  39. package/dist/ProForm/Controls/Text/index.d.ts +9 -2
  40. package/dist/ProForm/Controls/Text/index.js +12 -12
  41. package/dist/ProForm/Controls/Text/index.less +0 -0
  42. package/dist/ProForm/Controls/TextArea/index.d.ts +6 -1
  43. package/dist/ProForm/Controls/TextArea/index.js +10 -11
  44. package/dist/ProForm/Controls/Upload/index.d.ts +32 -9
  45. package/dist/ProForm/Controls/Upload/index.js +14 -6
  46. package/dist/ProForm/Controls/Upload/index.less +0 -0
  47. package/dist/ProForm/Field/index.d.ts +27 -4
  48. package/dist/ProForm/Field/index.js +12 -13
  49. package/dist/ProForm/Field/index.less +0 -4
  50. package/dist/ProForm/Form/index.d.ts +41 -6
  51. package/dist/ProForm/Form/index.js +294 -172
  52. package/dist/ProForm/Form/index.less +0 -0
  53. package/dist/ProForm/Group/index.d.ts +22 -3
  54. package/dist/ProForm/Group/index.js +8 -30
  55. package/dist/ProForm/Group/index.less +0 -0
  56. package/dist/ProForm/index.d.ts +4 -4
  57. package/dist/ProForm/index.js +5 -5
  58. package/dist/ProList/index.d.ts +8 -2
  59. package/dist/ProList/index.js +6 -4
  60. package/dist/Tabbar/index.d.ts +4 -2
  61. package/dist/Tabbar/index.js +14 -5
  62. package/dist/Tabs/index.d.ts +8 -5
  63. package/dist/Tabs/index.js +6 -6
  64. package/dist/Tabs/index.less +4 -1
  65. package/dist/UserView/index.d.ts +15 -0
  66. package/dist/UserView/index.js +62 -0
  67. package/dist/UserView/index.less +41 -0
  68. package/dist/ValidMobilePopup/index.d.ts +9 -0
  69. package/dist/ValidMobilePopup/index.js +147 -0
  70. package/dist/ValidMobilePopup/index.less +58 -0
  71. package/dist/hooks/index.d.ts +22 -0
  72. package/dist/hooks/index.js +51 -0
  73. package/dist/index.d.ts +17 -2
  74. package/dist/index.js +9 -1
  75. package/dist/services/CommonController/index.d.ts +5 -0
  76. package/dist/services/CommonController/index.js +21 -0
  77. package/dist/services/CommonController/typings.d.ts +0 -0
  78. package/dist/services/index.d.ts +2 -1
  79. package/dist/services/index.js +2 -1
  80. package/package.json +6 -3
  81. package/dist/ProForm/typings.d.ts +0 -164
  82. package/dist/RefreshList/index.d.ts +0 -17
  83. package/dist/RefreshList/index.js +0 -43
  84. package/dist/RefreshList/index.less +0 -19
  85. package/dist/assets/fonts/PingFangSC-Light.ttf +0 -0
  86. package/dist/assets/fonts/PingFangSC-Medium.ttf +0 -0
  87. package/dist/assets/fonts/PingFangSC-Regular.ttf +0 -0
@@ -2,6 +2,7 @@
2
2
 
3
3
  .p-pro-form-item {
4
4
  .p-pro-form-item-select {
5
+ min-height: 40px;
5
6
  display: flex;
6
7
  align-items: center;
7
8
  flex-wrap: wrap;
@@ -14,6 +15,7 @@
14
15
 
15
16
  .iconfont {
16
17
  font-size: 28px;
18
+ line-height: 40px;
17
19
  color: #999;
18
20
  }
19
21
 
@@ -28,6 +30,28 @@
28
30
  }
29
31
  }
30
32
 
33
+ .p-pro-form-select-location-container {
34
+ .p-pro-form-select-location-button {
35
+ display: flex;
36
+ align-items: center;
37
+ padding: 12px 24px;
38
+ border-radius: 12px;
39
+ border: 1px solid #E5E5E5;
40
+ box-sizing: border-box;
41
+ width: max-content;
42
+ gap: 8px;
43
+
44
+ .iconfont {
45
+ font-size: 24px;
46
+ color: #333437;
47
+ }
48
+
49
+ .text {
50
+ .font(28)
51
+ }
52
+ }
53
+ }
54
+
31
55
  &.horizontal {
32
56
  .p-pro-form-item-select {
33
57
  width: 100%;
@@ -36,6 +60,11 @@
36
60
  }
37
61
  }
38
62
 
63
+ .p-select-container {
64
+ display: flex;
65
+ align-items: center;
66
+ }
67
+
39
68
  .p-pro-form-item-select-popup-container {
40
69
  z-index: 99999;
41
70
 
@@ -0,0 +1,10 @@
1
+ import { FC } from "react";
2
+ import type { ProFormFieldProps } from "../../Field";
3
+ import "./index.less";
4
+ type ProFormStepperProps = ProFormFieldProps & {
5
+ max?: number;
6
+ min?: number;
7
+ step?: number;
8
+ };
9
+ declare const ProFormStepper: FC<ProFormStepperProps>;
10
+ export default ProFormStepper;
@@ -0,0 +1,72 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
+ 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."); }
4
+ 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); }
5
+ 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; }
6
+ 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; } }
7
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
+ import React, { useEffect, useState } from "react";
9
+ import { Input, Text, View } from "@tarojs/components";
10
+ import ProFormField from "../../Field";
11
+ import "./index.less";
12
+ var ProFormStepper = function ProFormStepper(props) {
13
+ var _props$placeholder = props.placeholder,
14
+ placeholder = _props$placeholder === void 0 ? "请输入" : _props$placeholder,
15
+ onChange = props.onChange,
16
+ disabled = props.disabled,
17
+ value = props.value,
18
+ max = props.max,
19
+ min = props.min,
20
+ _props$step = props.step,
21
+ step = _props$step === void 0 ? 1 : _props$step;
22
+ var _useState = useState(value),
23
+ _useState2 = _slicedToArray(_useState, 2),
24
+ inputValue = _useState2[0],
25
+ setInputValue = _useState2[1];
26
+ useEffect(function () {
27
+ if (value !== inputValue) setInputValue(value);
28
+ }, [value]);
29
+ return /*#__PURE__*/React.createElement(ProFormField, _extends({}, props, {
30
+ className: "p-pro-form-stepper-container ".concat(props.className)
31
+ }), disabled ? /*#__PURE__*/React.createElement(Text, {
32
+ className: "p-pro-form-item-control-disabled"
33
+ }, value || "-") : /*#__PURE__*/React.createElement(View, {
34
+ className: "stepper-input"
35
+ }, /*#__PURE__*/React.createElement(View, {
36
+ className: "button",
37
+ onTap: function onTap(e) {
38
+ e.stopPropagation();
39
+ var value = inputValue || 0;
40
+ var v = typeof min === "number" ? value - step < min ? min : value - step : value - step;
41
+ setInputValue(v);
42
+ onChange === null || onChange === void 0 || onChange(v);
43
+ }
44
+ }, /*#__PURE__*/React.createElement(View, {
45
+ className: "iconfont icon-icon-psp-shanchu"
46
+ })), /*#__PURE__*/React.createElement(Input, {
47
+ placeholder: placeholder,
48
+ className: "p-pro-form-item-input",
49
+ placeholderClass: "p-pro-form-item-placeholder",
50
+ onInput: function onInput(e) {
51
+ setInputValue(parseFloat(e.detail.value || "0"));
52
+ onChange === null || onChange === void 0 || onChange(parseFloat(e.detail.value || "0"));
53
+ },
54
+ onClick: function onClick(e) {
55
+ return e.stopPropagation();
56
+ },
57
+ type: "digit",
58
+ value: inputValue === null || inputValue === void 0 ? void 0 : inputValue.toString()
59
+ }), /*#__PURE__*/React.createElement(View, {
60
+ className: "button",
61
+ onTap: function onTap(e) {
62
+ e.stopPropagation();
63
+ var value = inputValue || 0;
64
+ var v = typeof max === "number" ? value + step > max ? max : value + step : value + step;
65
+ setInputValue(v);
66
+ onChange === null || onChange === void 0 || onChange(v);
67
+ }
68
+ }, /*#__PURE__*/React.createElement(View, {
69
+ className: "iconfont icon-icon-psp-xinjian"
70
+ }))));
71
+ };
72
+ export default ProFormStepper;
@@ -0,0 +1,31 @@
1
+ @import "@power-xa/m-ui/dist/assets/less/mixins.less";
2
+
3
+ .p-pro-form-stepper-container {
4
+
5
+ .stepper-input {
6
+ display: flex;
7
+ align-items: center;
8
+ gap: 24rpx;
9
+
10
+ .button {
11
+ background: #F6F7F9;
12
+ width: 42px;
13
+ height: 42px;
14
+ display: flex;
15
+ align-items: center;
16
+ justify-content: center;
17
+ border-radius: 8px;
18
+ flex-shrink: 0;
19
+
20
+ .iconfont {
21
+ font-size: 24px !important;
22
+ color: #333437;
23
+ }
24
+ }
25
+
26
+ .p-pro-form-item-input,
27
+ .p-pro-form-item-placeholder {
28
+ text-align: left;
29
+ }
30
+ }
31
+ }
@@ -0,0 +1,5 @@
1
+ import { FC } from "react";
2
+ import type { ProFormFieldProps } from "../../Field";
3
+ import "./index.less";
4
+ declare const ProFormSwitch: FC<ProFormFieldProps>;
5
+ export default ProFormSwitch;
@@ -0,0 +1,21 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+ import React from "react";
3
+ import { Switch } from "@tarojs/components";
4
+ import ProFormField from "../../Field";
5
+ import "./index.less";
6
+ var ProFormSwitch = function ProFormSwitch(props) {
7
+ var _onChange = props.onChange,
8
+ disabled = props.disabled,
9
+ value = props.value;
10
+ return /*#__PURE__*/React.createElement(ProFormField, _extends({}, props, {
11
+ className: "p-pro-form-item-switch ".concat(props.className)
12
+ }), /*#__PURE__*/React.createElement(Switch, {
13
+ color: "#333437",
14
+ disabled: disabled,
15
+ checked: value,
16
+ onChange: function onChange(e) {
17
+ return _onChange === null || _onChange === void 0 ? void 0 : _onChange(e.detail.value);
18
+ }
19
+ }));
20
+ };
21
+ export default ProFormSwitch;
@@ -0,0 +1,3 @@
1
+ .p-pro-form-item-switch {
2
+ padding: 24px 0 !important;
3
+ }
@@ -1,4 +1,11 @@
1
- import { FC } from "react";
1
+ import { FC, ReactNode } from "react";
2
+ import type { ProFormFieldProps } from "../../Field";
2
3
  import "./index.less";
3
- declare const ProFormText: FC<ProFormAPI.ProFormItemProps>;
4
+ export type ProFormTextProps = ProFormFieldProps & {
5
+ maxLength?: number;
6
+ inputType?: "text" | "number" | "idcard" | "digit" | "safe-password" | "nickname" | "numberpad" | "digitpad" | "idcardpad";
7
+ prefix?: ReactNode;
8
+ suffix?: ReactNode;
9
+ };
10
+ declare const ProFormText: FC<ProFormTextProps>;
4
11
  export default ProFormText;
@@ -4,12 +4,13 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
4
4
  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; }
5
5
  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; } }
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import React, { useEffect, useState } from "react";
8
- import { Input, Text } from "@tarojs/components";
7
+ import React, { Fragment, useEffect, useState } from "react";
8
+ import { Text, Input } from "@tarojs/components";
9
9
  import ProFormField from "../../Field";
10
10
  import "./index.less";
11
11
  var ProFormText = function ProFormText(props) {
12
- var _props$placeholder = props.placeholder,
12
+ var value = props.value,
13
+ _props$placeholder = props.placeholder,
13
14
  placeholder = _props$placeholder === void 0 ? "请输入" : _props$placeholder,
14
15
  onChange = props.onChange,
15
16
  _props$maxLength = props.maxLength,
@@ -17,7 +18,8 @@ var ProFormText = function ProFormText(props) {
17
18
  _props$inputType = props.inputType,
18
19
  inputType = _props$inputType === void 0 ? "text" : _props$inputType,
19
20
  disabled = props.disabled,
20
- value = props.value;
21
+ prefix = props.prefix,
22
+ suffix = props.suffix;
21
23
  var _useState = useState(value),
22
24
  _useState2 = _slicedToArray(_useState, 2),
23
25
  inputValue = _useState2[0],
@@ -25,21 +27,19 @@ var ProFormText = function ProFormText(props) {
25
27
  useEffect(function () {
26
28
  if (value !== inputValue) setInputValue(value);
27
29
  }, [value]);
28
- return /*#__PURE__*/React.createElement(ProFormField, props, disabled ? /*#__PURE__*/React.createElement(Text, {
30
+ return /*#__PURE__*/React.createElement(ProFormField, props, disabled ? /*#__PURE__*/React.createElement(Fragment, null, prefix, /*#__PURE__*/React.createElement(Text, {
29
31
  className: "p-pro-form-item-control-disabled"
30
- }, value || "-") : /*#__PURE__*/React.createElement(Input, {
32
+ }, value || "-"), suffix) : /*#__PURE__*/React.createElement(Fragment, null, prefix, /*#__PURE__*/React.createElement(Input, {
31
33
  placeholder: placeholder,
32
34
  className: "p-pro-form-item-input",
33
35
  placeholderClass: "p-pro-form-item-placeholder",
34
36
  onInput: function onInput(e) {
35
- return setInputValue(e.detail.value);
37
+ setInputValue(e.detail.value);
38
+ onChange === null || onChange === void 0 || onChange(e.detail.value);
36
39
  },
37
40
  maxlength: maxLength,
38
41
  type: inputType,
39
- value: inputValue,
40
- onBlur: function onBlur() {
41
- return onChange === null || onChange === void 0 ? void 0 : onChange(inputValue);
42
- }
43
- }));
42
+ value: inputValue
43
+ }), suffix));
44
44
  };
45
45
  export default ProFormText;
File without changes
@@ -1,4 +1,9 @@
1
1
  import { FC } from "react";
2
+ import type { ProFormFieldProps } from "../../Field";
2
3
  import "./index.less";
3
- declare const ProFormTextArea: FC<ProFormAPI.ProFormItemProps>;
4
+ type ProFormTextAreaProps = ProFormFieldProps & {
5
+ maxLength?: number;
6
+ recommend?: string[];
7
+ };
8
+ declare const ProFormTextArea: FC<ProFormTextAreaProps>;
4
9
  export default ProFormTextArea;
@@ -22,12 +22,12 @@ var ProFormTextArea = function ProFormTextArea(props) {
22
22
  _useState2 = _slicedToArray(_useState, 2),
23
23
  show = _useState2[0],
24
24
  setShow = _useState2[1];
25
- var _useState3 = useState(value),
25
+ var _useState3 = useState(value || ""),
26
26
  _useState4 = _slicedToArray(_useState3, 2),
27
27
  inputValue = _useState4[0],
28
28
  setInputValue = _useState4[1];
29
29
  useEffect(function () {
30
- if (value !== inputValue) setInputValue(value);
30
+ if (value !== inputValue) setInputValue(value || "");
31
31
  }, [value]);
32
32
  return /*#__PURE__*/React.createElement(ProFormField, _extends({}, props, {
33
33
  layout: "vertical"
@@ -39,12 +39,10 @@ var ProFormTextArea = function ProFormTextArea(props) {
39
39
  className: "p-pro-form-item-textarea",
40
40
  placeholderClass: "p-pro-form-item-placeholder",
41
41
  onInput: function onInput(e) {
42
- return setInputValue(e.detail.value);
42
+ setInputValue(e.detail.value);
43
+ onChange === null || onChange === void 0 || onChange(e.detail.value);
43
44
  },
44
- maxlength: maxLength,
45
- onBlur: function onBlur() {
46
- return onChange === null || onChange === void 0 ? void 0 : onChange(inputValue);
47
- }
45
+ maxlength: maxLength
48
46
  }), recommend && /*#__PURE__*/React.createElement(View, {
49
47
  className: "p-pro-form-item-textarea-recommend-container"
50
48
  }, /*#__PURE__*/React.createElement(View, {
@@ -58,16 +56,17 @@ var ProFormTextArea = function ProFormTextArea(props) {
58
56
  className: "iconfont ".concat(show ? 'icon-icon-xianshi' : 'icon-icon-yincang')
59
57
  })), show && /*#__PURE__*/React.createElement(View, {
60
58
  className: "recommend-content"
61
- }, recommend.map(function (item, index) {
59
+ }, recommend.map(function (r, ri) {
62
60
  return /*#__PURE__*/React.createElement(View, {
63
61
  className: "recommend-tag",
64
- key: 'recommend-tag-' + index,
62
+ key: 'recommend-tag-' + ri,
65
63
  onTap: function onTap() {
66
- return onChange === null || onChange === void 0 ? void 0 : onChange((value || "") + item);
64
+ setInputValue(inputValue + r);
65
+ onChange === null || onChange === void 0 || onChange(inputValue + r);
67
66
  }
68
67
  }, /*#__PURE__*/React.createElement(Text, {
69
68
  className: "text"
70
- }, item));
69
+ }, r));
71
70
  })))));
72
71
  };
73
72
  export default ProFormTextArea;
@@ -1,10 +1,33 @@
1
- import { FC } from "react";
1
+ import React from "react";
2
2
  import "./index.less";
3
- type ProFormUploadProps = ProFormAPI.ProFormItemProps & {
4
- module?: string;
5
- userId?: string;
6
- userName?: string;
7
- readonly?: boolean;
8
- };
9
- declare const ProFormUpload: FC<ProFormUploadProps>;
10
- export default ProFormUpload;
3
+ declare const _default: React.ForwardRefExoticComponent<import("../../..").ProFormInstance & {
4
+ flex?: number | undefined;
5
+ layout?: "horizontal" | "vertical" | undefined;
6
+ name?: import("../../Form").NamePath | undefined;
7
+ dependencies?: import("../../Form").NamePath | undefined;
8
+ hidden?: boolean | ((form: {
9
+ [key: string]: any;
10
+ }) => boolean) | undefined;
11
+ initialValue?: any;
12
+ required?: boolean | undefined;
13
+ rules?: import("../../..").ProFormItemRule[] | undefined;
14
+ className?: string | undefined;
15
+ placeholder?: string | undefined;
16
+ value?: any;
17
+ onChange?: ((value: any, key?: string | string[] | undefined) => void) | undefined;
18
+ disabled?: boolean | undefined;
19
+ children?: import("../../Form").Children | undefined;
20
+ hiddenBorder?: boolean | undefined;
21
+ label?: React.ReactNode;
22
+ extra?: React.ReactNode;
23
+ shouldUpdate?: boolean | undefined;
24
+ } & {
25
+ listType?: "card" | "list" | undefined;
26
+ maxLength?: number | undefined;
27
+ module?: string | undefined;
28
+ userId?: string | undefined;
29
+ userName?: string | undefined;
30
+ readonly?: boolean | undefined;
31
+ takeonly?: boolean | undefined;
32
+ } & React.RefAttributes<unknown>>;
33
+ export default _default;
@@ -15,7 +15,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
15
15
  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; }
16
16
  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; } }
17
17
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
- import React, { Fragment, useCallback, useEffect, useRef, useState } from "react";
18
+ import React, { forwardRef, Fragment, useCallback, useEffect, useImperativeHandle, useRef, useState } from "react";
19
19
  import { chooseImage, chooseVideo, chooseMessageFile, uploadFile, previewImage, navigateTo } from "@tarojs/taro";
20
20
  import { Image, Text, View } from "@tarojs/components";
21
21
  import { clipFileUrl, getFileType, getUUID, Grid, Popup } from "../../..";
@@ -23,14 +23,15 @@ import { useConfig } from "../../../ConfigProvider";
23
23
  import ProFormField from "../../Field";
24
24
  import { FileController } from "../../../services";
25
25
  import "./index.less";
26
- var ProFormUpload = function ProFormUpload(props) {
26
+ var ProFormUpload = function ProFormUpload(props, ref) {
27
27
  var _props$listType = props.listType,
28
28
  listType = _props$listType === void 0 ? "list" : _props$listType,
29
29
  disabled = props.disabled,
30
30
  _props$value = props.value,
31
31
  value = _props$value === void 0 ? [] : _props$value,
32
32
  onChange = props.onChange,
33
- maxLength = props.maxLength;
33
+ maxLength = props.maxLength,
34
+ takeonly = props.takeonly;
34
35
  var _useConfig = useConfig(),
35
36
  src = _useConfig.src;
36
37
  var _useState = useState(false),
@@ -79,6 +80,11 @@ var ProFormUpload = function ProFormUpload(props) {
79
80
  }));
80
81
  }
81
82
  }, [value]);
83
+ useImperativeHandle(ref, function () {
84
+ return {
85
+ takePhoto: takePhoto
86
+ };
87
+ });
82
88
  var getUploadConfig = useCallback(function () {
83
89
  FileController.getUploadConfig().then(function (result) {
84
90
  if (result.code === 200) {
@@ -262,14 +268,16 @@ var ProFormUpload = function ProFormUpload(props) {
262
268
  }, !disabled && (listType === "card" ? /*#__PURE__*/React.createElement(View, {
263
269
  className: "p-pro-form-item-upload-button",
264
270
  onTap: function onTap() {
265
- return setOpen(true);
271
+ if (takeonly) return takePhoto();
272
+ setOpen(true);
266
273
  }
267
274
  }, /*#__PURE__*/React.createElement(View, {
268
275
  className: "iconfont icon-icon-psp-xinjian"
269
276
  })) : /*#__PURE__*/React.createElement(View, {
270
277
  className: "p-pro-form-item-upload-button",
271
278
  onTap: function onTap() {
272
- return setOpen(true);
279
+ if (takeonly) return takePhoto();
280
+ setOpen(true);
273
281
  }
274
282
  }, /*#__PURE__*/React.createElement(View, {
275
283
  className: "iconfont icon-icon-psp-xinjian"
@@ -414,4 +422,4 @@ var ProFormUpload = function ProFormUpload(props) {
414
422
  })));
415
423
  }));
416
424
  };
417
- export default ProFormUpload;
425
+ export default /*#__PURE__*/forwardRef(ProFormUpload);
File without changes
@@ -1,9 +1,32 @@
1
- import { FC, ReactElement, ReactNode } from "react";
1
+ import { FC, ReactNode } from "react";
2
+ import type { Children, ProFormInstance, NamePath } from "../Form";
2
3
  import "./index.less";
3
- type ProFormFieldProps = ProFormAPI.ProFormItemProps & {
4
+ export type ProFormItemRule = {
5
+ message?: string;
6
+ pattern?: RegExp;
7
+ required?: boolean;
8
+ };
9
+ export type ProFormFieldProps = ProFormInstance & {
10
+ flex?: number;
11
+ layout?: "horizontal" | "vertical";
12
+ name?: NamePath;
13
+ dependencies?: NamePath;
14
+ hidden?: boolean | ((form: {
15
+ [key: string]: any;
16
+ }) => boolean);
17
+ initialValue?: any;
18
+ required?: boolean;
19
+ rules?: ProFormItemRule[];
20
+ className?: string;
21
+ placeholder?: string;
22
+ value?: any;
23
+ onChange?: (value: any, key?: string[] | string) => void;
24
+ disabled?: boolean;
25
+ children?: Children;
26
+ hiddenBorder?: boolean;
4
27
  label?: string | ReactNode;
5
- extra?: ReactElement | false;
6
- children: ReactElement;
28
+ extra?: ReactNode | false;
29
+ shouldUpdate?: boolean;
7
30
  };
8
31
  declare const ProFormField: FC<ProFormFieldProps>;
9
32
  export default ProFormField;
@@ -1,19 +1,18 @@
1
1
  import React from "react";
2
2
  import { Text, View } from "@tarojs/components";
3
3
  import "./index.less";
4
- var ProFormField = function ProFormField(props) {
5
- var _props$className = props.className,
6
- className = _props$className === void 0 ? "" : _props$className,
7
- label = props.label,
8
- extra = props.extra,
9
- required = props.required,
10
- _props$rules = props.rules,
11
- rules = _props$rules === void 0 ? [] : _props$rules,
12
- _props$layout = props.layout,
13
- layout = _props$layout === void 0 ? "horizontal" : _props$layout,
14
- children = props.children,
15
- hiddenBorder = props.hiddenBorder,
16
- hidden = props.hidden;
4
+ var ProFormField = function ProFormField(_ref) {
5
+ var className = _ref.className,
6
+ _ref$layout = _ref.layout,
7
+ layout = _ref$layout === void 0 ? "horizontal" : _ref$layout,
8
+ hiddenBorder = _ref.hiddenBorder,
9
+ label = _ref.label,
10
+ required = _ref.required,
11
+ _ref$rules = _ref.rules,
12
+ rules = _ref$rules === void 0 ? [] : _ref$rules,
13
+ extra = _ref.extra,
14
+ children = _ref.children,
15
+ hidden = _ref.hidden;
17
16
  return /*#__PURE__*/React.createElement(View, {
18
17
  className: "p-pro-form-item ".concat(className, " ").concat(layout, " ").concat(hiddenBorder ? 'p-pro-form-item-hidden-border' : '', " ").concat(hidden ? 'hidden' : '')
19
18
  }, label && /*#__PURE__*/React.createElement(View, {
@@ -60,10 +60,6 @@
60
60
  display: flex;
61
61
  align-items: center;
62
62
  justify-content: flex-end;
63
-
64
- .p-pro-form-item-control-picker {
65
- width: 100%;
66
- }
67
63
  }
68
64
  }
69
65
 
@@ -1,7 +1,42 @@
1
- import React from "react";
1
+ import React, { ReactElement, ReactNode } from "react";
2
2
  import "./index.less";
3
- declare const _default: React.ForwardRefExoticComponent<ProFormAPI.ProFormProps & {
4
- children: React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
5
- footer?: React.ReactNode;
6
- } & React.RefAttributes<unknown>>;
7
- export default _default;
3
+ type Form = {
4
+ [key: string]: any;
5
+ };
6
+ type FieldData = {
7
+ name: NamePath;
8
+ value: any;
9
+ };
10
+ type OptionType = {
11
+ add?: () => void;
12
+ remove?: () => void;
13
+ };
14
+ export type NamePath = string | number | (string | number)[];
15
+ export type Children = boolean | ReactElement | null | (boolean | ReactElement | null)[] | ((record: Form, option: OptionType, index?: number) => ReactElement);
16
+ export type ProFormInstance = {
17
+ resetFields?: () => void;
18
+ setFields?: (fields: FieldData[]) => void;
19
+ setFieldValue?: (name: NamePath, value: any) => void;
20
+ submit?: () => Promise<Form>;
21
+ getFieldValue?: (name: NamePath) => any;
22
+ getFieldsValue?: (name: NamePath[] | true) => Form;
23
+ validRequiredValue?: () => Promise<boolean>;
24
+ };
25
+ export type ProFormProps = {
26
+ disabled?: boolean;
27
+ initialValues?: Form;
28
+ className?: string;
29
+ scroll?: boolean;
30
+ onChange?: (form: Form) => void;
31
+ onValueChange?: (field: string, value: Form) => void;
32
+ children?: Children;
33
+ footer?: {
34
+ onOk?: ((form: Form) => void) | false;
35
+ onDelete?: ((form: Form) => void) | false;
36
+ onSave?: ((form: Form) => void) | false;
37
+ children?: ReactNode;
38
+ deleteDescription?: string;
39
+ } | false;
40
+ };
41
+ declare const ProForm: React.ForwardRefExoticComponent<ProFormProps & React.RefAttributes<ProFormInstance>>;
42
+ export default ProForm;