@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.
- package/README.md +37 -17
- package/dist/ActionSheet/index.js +5 -3
- package/dist/Breadcrumb/index.js +4 -2
- package/dist/Calendar/Date/index.d.ts +8 -0
- package/dist/Calendar/Date/index.js +246 -0
- package/dist/Calendar/Date/index.less +146 -0
- package/dist/Calendar/Month/index.d.ts +7 -0
- package/dist/Calendar/Month/index.js +199 -0
- package/dist/Calendar/Month/index.less +96 -0
- package/dist/Calendar/Week/index.d.ts +7 -0
- package/dist/Calendar/Week/index.js +200 -0
- package/dist/Calendar/Week/index.less +96 -0
- package/dist/Calendar/index.d.ts +10 -0
- package/dist/Calendar/index.js +9 -0
- package/dist/ConfigProvider/index.d.ts +1 -0
- package/dist/Drawer/index.d.ts +1 -0
- package/dist/Drawer/index.js +38 -20
- package/dist/Drawer/index.less +2 -1
- package/dist/Filter/index.d.ts +3 -0
- package/dist/Filter/index.js +8 -6
- package/dist/ProForm/Controls/Cascader/index.d.ts +28 -0
- package/dist/ProForm/Controls/Cascader/index.js +159 -0
- package/dist/ProForm/Controls/Cascader/index.less +106 -0
- package/dist/ProForm/Controls/Date/index.d.ts +6 -1
- package/dist/ProForm/Controls/Date/index.js +12 -4
- package/dist/ProForm/Controls/Date/index.less +18 -0
- package/dist/ProForm/Controls/List/index.d.ts +2 -8
- package/dist/ProForm/Controls/List/index.js +17 -9
- package/dist/ProForm/Controls/List/index.less +0 -0
- package/dist/ProForm/Controls/Select/index.d.ts +50 -1
- package/dist/ProForm/Controls/Select/index.js +289 -211
- package/dist/ProForm/Controls/Select/index.less +29 -0
- package/dist/ProForm/Controls/Stepper/index.d.ts +10 -0
- package/dist/ProForm/Controls/Stepper/index.js +72 -0
- package/dist/ProForm/Controls/Stepper/index.less +31 -0
- package/dist/ProForm/Controls/Switch/index.d.ts +5 -0
- package/dist/ProForm/Controls/Switch/index.js +21 -0
- package/dist/ProForm/Controls/Switch/index.less +3 -0
- package/dist/ProForm/Controls/Text/index.d.ts +9 -2
- package/dist/ProForm/Controls/Text/index.js +12 -12
- package/dist/ProForm/Controls/Text/index.less +0 -0
- package/dist/ProForm/Controls/TextArea/index.d.ts +6 -1
- package/dist/ProForm/Controls/TextArea/index.js +10 -11
- package/dist/ProForm/Controls/Upload/index.d.ts +32 -9
- package/dist/ProForm/Controls/Upload/index.js +14 -6
- package/dist/ProForm/Controls/Upload/index.less +0 -0
- package/dist/ProForm/Field/index.d.ts +27 -4
- package/dist/ProForm/Field/index.js +12 -13
- package/dist/ProForm/Field/index.less +0 -4
- package/dist/ProForm/Form/index.d.ts +41 -6
- package/dist/ProForm/Form/index.js +294 -172
- package/dist/ProForm/Form/index.less +0 -0
- package/dist/ProForm/Group/index.d.ts +22 -3
- package/dist/ProForm/Group/index.js +8 -30
- package/dist/ProForm/Group/index.less +0 -0
- package/dist/ProForm/index.d.ts +4 -4
- package/dist/ProForm/index.js +5 -5
- package/dist/ProList/index.d.ts +8 -2
- package/dist/ProList/index.js +6 -4
- package/dist/Tabbar/index.d.ts +4 -2
- package/dist/Tabbar/index.js +14 -5
- package/dist/Tabs/index.d.ts +8 -5
- package/dist/Tabs/index.js +6 -6
- package/dist/Tabs/index.less +4 -1
- package/dist/UserView/index.d.ts +15 -0
- package/dist/UserView/index.js +62 -0
- package/dist/UserView/index.less +41 -0
- package/dist/ValidMobilePopup/index.d.ts +9 -0
- package/dist/ValidMobilePopup/index.js +147 -0
- package/dist/ValidMobilePopup/index.less +58 -0
- package/dist/hooks/index.d.ts +22 -0
- package/dist/hooks/index.js +51 -0
- package/dist/index.d.ts +17 -2
- package/dist/index.js +9 -1
- package/dist/services/CommonController/index.d.ts +5 -0
- package/dist/services/CommonController/index.js +21 -0
- package/dist/services/CommonController/typings.d.ts +0 -0
- package/dist/services/index.d.ts +2 -1
- package/dist/services/index.js +2 -1
- package/package.json +6 -3
- package/dist/ProForm/typings.d.ts +0 -164
- package/dist/RefreshList/index.d.ts +0 -17
- package/dist/RefreshList/index.js +0 -43
- package/dist/RefreshList/index.less +0 -19
- package/dist/assets/fonts/PingFangSC-Light.ttf +0 -0
- package/dist/assets/fonts/PingFangSC-Medium.ttf +0 -0
- package/dist/assets/fonts/PingFangSC-Regular.ttf +0 -0
package/dist/Drawer/index.js
CHANGED
|
@@ -5,8 +5,8 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
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
7
|
import React, { useEffect, useState } from "react";
|
|
8
|
-
import { getMenuButtonBoundingClientRect } from "@tarojs/taro";
|
|
9
|
-
import { View } from "@tarojs/components";
|
|
8
|
+
import { getMenuButtonBoundingClientRect, getWindowInfo } from "@tarojs/taro";
|
|
9
|
+
import { RootPortal, View } from "@tarojs/components";
|
|
10
10
|
import "./index.less";
|
|
11
11
|
var Drawer = function Drawer(_ref) {
|
|
12
12
|
var open = _ref.open,
|
|
@@ -14,11 +14,13 @@ var Drawer = function Drawer(_ref) {
|
|
|
14
14
|
rootClassName = _ref.rootClassName,
|
|
15
15
|
header = _ref.header,
|
|
16
16
|
content = _ref.content,
|
|
17
|
-
footer = _ref.footer
|
|
17
|
+
footer = _ref.footer,
|
|
18
|
+
_ref$width = _ref.width,
|
|
19
|
+
width = _ref$width === void 0 ? 65 : _ref$width;
|
|
18
20
|
var _getMenuButtonBoundin = getMenuButtonBoundingClientRect(),
|
|
19
21
|
top = _getMenuButtonBoundin.top,
|
|
20
22
|
height = _getMenuButtonBoundin.height;
|
|
21
|
-
var _useState = useState("translateX(-
|
|
23
|
+
var _useState = useState("translateX(-".concat(width, "vw)")),
|
|
22
24
|
_useState2 = _slicedToArray(_useState, 2),
|
|
23
25
|
transform = _useState2[0],
|
|
24
26
|
setTransform = _useState2[1];
|
|
@@ -26,33 +28,46 @@ var Drawer = function Drawer(_ref) {
|
|
|
26
28
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
27
29
|
show = _useState4[0],
|
|
28
30
|
setShow = _useState4[1];
|
|
31
|
+
var _getWindowInfo = getWindowInfo(),
|
|
32
|
+
safeArea = _getWindowInfo.safeArea;
|
|
33
|
+
var _ref2 = safeArea,
|
|
34
|
+
safeAreaHeight = _ref2.height,
|
|
35
|
+
bottom = _ref2.bottom;
|
|
29
36
|
useEffect(function () {
|
|
30
|
-
|
|
37
|
+
if (open && !show) setShow(true);
|
|
38
|
+
if (!open && show) setTransform("translateX(-".concat(width, "vw)"));
|
|
31
39
|
}, [open]);
|
|
32
40
|
useEffect(function () {
|
|
33
|
-
if (show
|
|
34
|
-
var timer = setTimeout(function () {
|
|
35
|
-
onOpenChange === null || onOpenChange === void 0 || onOpenChange(show);
|
|
36
|
-
clearTimeout(timer);
|
|
37
|
-
}, 300);
|
|
38
|
-
}
|
|
41
|
+
if (show) setTransform("none");
|
|
39
42
|
}, [show]);
|
|
40
43
|
useEffect(function () {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
if (transform === "translateX(-".concat(width, "vw)")) {
|
|
45
|
+
var time = setTimeout(function () {
|
|
46
|
+
setShow(false);
|
|
47
|
+
clearTimeout(time);
|
|
48
|
+
onOpenChange === null || onOpenChange === void 0 || onOpenChange(false);
|
|
49
|
+
}, 300);
|
|
50
|
+
}
|
|
51
|
+
}, [transform]);
|
|
52
|
+
return /*#__PURE__*/React.createElement(RootPortal, {
|
|
53
|
+
style: {
|
|
54
|
+
display: show ? "block" : "none",
|
|
55
|
+
position: "fixed"
|
|
56
|
+
}
|
|
57
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
44
58
|
className: "p-drawer-mask ".concat(rootClassName),
|
|
45
59
|
style: {
|
|
46
|
-
display:
|
|
60
|
+
display: show ? "block" : "none"
|
|
47
61
|
},
|
|
48
62
|
onTap: function onTap() {
|
|
49
|
-
|
|
63
|
+
setTransform("translateX(".concat(-width, "vw)"));
|
|
50
64
|
}
|
|
51
65
|
}, /*#__PURE__*/React.createElement(View, {
|
|
52
66
|
className: "p-drawer-container",
|
|
53
67
|
style: {
|
|
54
68
|
paddingTop: top,
|
|
55
|
-
transform: transform
|
|
69
|
+
transform: transform,
|
|
70
|
+
width: width + "vw"
|
|
56
71
|
},
|
|
57
72
|
onClick: function onClick(e) {
|
|
58
73
|
return e.stopPropagation();
|
|
@@ -64,8 +79,11 @@ var Drawer = function Drawer(_ref) {
|
|
|
64
79
|
}
|
|
65
80
|
}, header), /*#__PURE__*/React.createElement(View, {
|
|
66
81
|
className: "p-drawer-content"
|
|
67
|
-
}, content), /*#__PURE__*/React.createElement(View, {
|
|
68
|
-
className: "p-drawer-footer"
|
|
69
|
-
|
|
82
|
+
}, content), footer && /*#__PURE__*/React.createElement(View, {
|
|
83
|
+
className: "p-drawer-footer",
|
|
84
|
+
style: {
|
|
85
|
+
paddingBottom: "".concat(bottom - safeAreaHeight > 24 ? bottom - safeAreaHeight : 24, "rpx")
|
|
86
|
+
}
|
|
87
|
+
}, footer))));
|
|
70
88
|
};
|
|
71
89
|
export default Drawer;
|
package/dist/Drawer/index.less
CHANGED
package/dist/Filter/index.d.ts
CHANGED
package/dist/Filter/index.js
CHANGED
|
@@ -13,7 +13,8 @@ var Filter = function Filter(_ref) {
|
|
|
13
13
|
extra = _ref.extra,
|
|
14
14
|
onSearch = _ref.onSearch,
|
|
15
15
|
onFilter = _ref.onFilter,
|
|
16
|
-
children = _ref.children
|
|
16
|
+
children = _ref.children,
|
|
17
|
+
initialValues = _ref.initialValues;
|
|
17
18
|
var formRef = useRef(null);
|
|
18
19
|
var _useState = useState(false),
|
|
19
20
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -54,19 +55,20 @@ var Filter = function Filter(_ref) {
|
|
|
54
55
|
})), /*#__PURE__*/React.createElement(View, {
|
|
55
56
|
className: "content"
|
|
56
57
|
}, children && /*#__PURE__*/React.createElement(ProForm, {
|
|
57
|
-
ref: formRef
|
|
58
|
+
ref: formRef,
|
|
59
|
+
initialValues: initialValues
|
|
58
60
|
}, /*#__PURE__*/React.createElement(ProForm.Group, null, children))), /*#__PURE__*/React.createElement(View, {
|
|
59
61
|
className: "footer"
|
|
60
62
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
61
63
|
onTap: function onTap() {
|
|
62
|
-
var _formRef$current;
|
|
63
|
-
(_formRef$current = formRef.current) === null || _formRef$current === void 0 || _formRef$current.
|
|
64
|
+
var _formRef$current, _formRef$current$rese;
|
|
65
|
+
(_formRef$current = formRef.current) === null || _formRef$current === void 0 || (_formRef$current$rese = _formRef$current.resetFields) === null || _formRef$current$rese === void 0 || _formRef$current$rese.call(_formRef$current);
|
|
64
66
|
},
|
|
65
67
|
round: true
|
|
66
68
|
}, "\u91CD\u7F6E"), /*#__PURE__*/React.createElement(Button, {
|
|
67
69
|
onTap: function onTap() {
|
|
68
|
-
var _formRef$current2;
|
|
69
|
-
onFilter((_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : _formRef$current2.
|
|
70
|
+
var _formRef$current2, _formRef$current2$get;
|
|
71
|
+
onFilter((_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 || (_formRef$current2$get = _formRef$current2.getFieldsValue) === null || _formRef$current2$get === void 0 ? void 0 : _formRef$current2$get.call(_formRef$current2, true));
|
|
70
72
|
onOpenChange();
|
|
71
73
|
},
|
|
72
74
|
round: true,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { FC, ReactNode } from "react";
|
|
2
|
+
import type { ProFormFieldProps } from "../../Field";
|
|
3
|
+
import "./index.less";
|
|
4
|
+
type ProFormCascaderProps = ProFormFieldProps & {
|
|
5
|
+
options?: {
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}[];
|
|
8
|
+
multiple?: boolean;
|
|
9
|
+
params?: {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
};
|
|
12
|
+
request?: (params?: {
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
}) => Promise<{
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
}[]>;
|
|
17
|
+
fieldNames?: {
|
|
18
|
+
label: string;
|
|
19
|
+
value: string;
|
|
20
|
+
children?: string;
|
|
21
|
+
};
|
|
22
|
+
popupExtra?: {
|
|
23
|
+
top?: ReactNode;
|
|
24
|
+
bottom?: ReactNode;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
declare const Cascader: FC<ProFormCascaderProps>;
|
|
28
|
+
export default Cascader;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
var _excluded = ["multiple", "params", "request", "fieldNames", "children", "disabled", "placeholder", "onChange", "popupExtra"];
|
|
2
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
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); }
|
|
7
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
8
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
+
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."); }
|
|
10
|
+
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); }
|
|
11
|
+
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; }
|
|
12
|
+
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; } }
|
|
13
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
15
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
16
|
+
import React, { Fragment, useCallback, useMemo, useState } from "react";
|
|
17
|
+
import { ScrollView, Text, View } from "@tarojs/components";
|
|
18
|
+
import { Empty, getListAssignField, Popup, SearchInput } from "../../..";
|
|
19
|
+
import { isArray } from "lodash";
|
|
20
|
+
import ProFormField from "../../Field";
|
|
21
|
+
import "./index.less";
|
|
22
|
+
var Cascader = function Cascader(_ref) {
|
|
23
|
+
var multiple = _ref.multiple,
|
|
24
|
+
params = _ref.params,
|
|
25
|
+
request = _ref.request,
|
|
26
|
+
_ref$fieldNames = _ref.fieldNames,
|
|
27
|
+
fieldNames = _ref$fieldNames === void 0 ? {
|
|
28
|
+
value: "value",
|
|
29
|
+
label: "label",
|
|
30
|
+
children: "children"
|
|
31
|
+
} : _ref$fieldNames,
|
|
32
|
+
children = _ref.children,
|
|
33
|
+
disabled = _ref.disabled,
|
|
34
|
+
_ref$placeholder = _ref.placeholder,
|
|
35
|
+
placeholder = _ref$placeholder === void 0 ? "请选择" : _ref$placeholder,
|
|
36
|
+
onChange = _ref.onChange,
|
|
37
|
+
popupExtra = _ref.popupExtra,
|
|
38
|
+
fieldProps = _objectWithoutProperties(_ref, _excluded);
|
|
39
|
+
var _useState = useState(false),
|
|
40
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
41
|
+
open = _useState2[0],
|
|
42
|
+
setOpen = _useState2[1];
|
|
43
|
+
var _useState3 = useState(),
|
|
44
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
45
|
+
value = _useState4[0],
|
|
46
|
+
setValue = _useState4[1];
|
|
47
|
+
var _useState5 = useState([]),
|
|
48
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
49
|
+
options = _useState6[0],
|
|
50
|
+
setOptions = _useState6[1];
|
|
51
|
+
var _onTap = useCallback(function (e) {
|
|
52
|
+
e.stopPropagation();
|
|
53
|
+
if (disabled) return false;
|
|
54
|
+
setOpen(true);
|
|
55
|
+
}, [value]);
|
|
56
|
+
|
|
57
|
+
/* 渲染选择图标 */
|
|
58
|
+
var renderIcon = useCallback(function (v) {
|
|
59
|
+
if (value === v || value instanceof Array && value.includes(v)) return /*#__PURE__*/React.createElement(View, {
|
|
60
|
+
className: "iconfont ".concat(multiple ? 'icon-icon-checkbox' : 'icon-icon-radio')
|
|
61
|
+
});
|
|
62
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
63
|
+
className: "iconfont icon-icon-circle"
|
|
64
|
+
});
|
|
65
|
+
}, [value]);
|
|
66
|
+
|
|
67
|
+
/* 渲染文字 */
|
|
68
|
+
var renderText = useCallback(function () {
|
|
69
|
+
if (["string", "boolean", "number"].includes(_typeof(value)) || value === null) return getListAssignField(value, options, fieldNames);
|
|
70
|
+
if (isArray(value)) return value.map(function (v) {
|
|
71
|
+
return ["string", "boolean", "number"].includes(_typeof(v)) || v === null ? getListAssignField(v, options, fieldNames) : v[fieldNames.label];
|
|
72
|
+
}).join("、");
|
|
73
|
+
}, [value, options]);
|
|
74
|
+
var renderContent = useCallback(function () {
|
|
75
|
+
return /*#__PURE__*/React.createElement(Fragment, null, children ? /*#__PURE__*/React.createElement(View, {
|
|
76
|
+
className: "p-select-container",
|
|
77
|
+
onTap: function onTap(e) {
|
|
78
|
+
return _onTap(e);
|
|
79
|
+
}
|
|
80
|
+
}, children) : /*#__PURE__*/React.createElement(ProFormField, _extends({
|
|
81
|
+
layout: "horizontal"
|
|
82
|
+
}, fieldProps), /*#__PURE__*/React.createElement(View, {
|
|
83
|
+
className: "p-pro-form-item-select",
|
|
84
|
+
onTap: function onTap(e) {
|
|
85
|
+
return _onTap(e);
|
|
86
|
+
}
|
|
87
|
+
}, disabled ? /*#__PURE__*/React.createElement(Text, {
|
|
88
|
+
className: "p-pro-form-item-control-disabled"
|
|
89
|
+
}, renderText() || "-") : value instanceof Array && value.length || !(value instanceof Array) && value ? /*#__PURE__*/React.createElement(Text, {
|
|
90
|
+
className: "p-pro-form-item-value"
|
|
91
|
+
}, renderText()) : /*#__PURE__*/React.createElement(Text, {
|
|
92
|
+
className: "p-pro-form-item-placeholder"
|
|
93
|
+
}, placeholder))), /*#__PURE__*/React.createElement(Popup, {
|
|
94
|
+
open: open,
|
|
95
|
+
onOpenChange: function onOpenChange(open) {
|
|
96
|
+
return setOpen(open);
|
|
97
|
+
},
|
|
98
|
+
rootClassName: "p-pro-form-item-select-popup-container",
|
|
99
|
+
header: {
|
|
100
|
+
title: fieldProps.label,
|
|
101
|
+
extra: {
|
|
102
|
+
right: multiple && /*#__PURE__*/React.createElement(Text, {
|
|
103
|
+
className: "text",
|
|
104
|
+
onClick: function onClick() {
|
|
105
|
+
return onChange === null || onChange === void 0 ? void 0 : onChange(value);
|
|
106
|
+
}
|
|
107
|
+
}, "\u786E\u5B9A")
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}, function (_ref2) {
|
|
111
|
+
var onOpenChange = _ref2.onOpenChange;
|
|
112
|
+
return /*#__PURE__*/React.createElement(Fragment, null, popupExtra === null || popupExtra === void 0 ? void 0 : popupExtra.top, /*#__PURE__*/React.createElement(SearchInput, {
|
|
113
|
+
placeholder: "\u8BF7\u8F93\u5165\u5173\u952E\u8BCD\u641C\u7D22",
|
|
114
|
+
onSearch: function onSearch(v) {
|
|
115
|
+
return setOptions((options === null || options === void 0 ? void 0 : options.filter(function (o) {
|
|
116
|
+
return o[fieldNames.label].indexOf(v) >= 0;
|
|
117
|
+
})) || []);
|
|
118
|
+
}
|
|
119
|
+
}), options.length ? /*#__PURE__*/React.createElement(ScrollView, {
|
|
120
|
+
className: "p-pro-form-item-select-popup-content",
|
|
121
|
+
showScrollbar: false,
|
|
122
|
+
scrollY: true,
|
|
123
|
+
enableFlex: true,
|
|
124
|
+
enhanced: true
|
|
125
|
+
}, options.map(function (o) {
|
|
126
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
127
|
+
className: "p-pro-form-item-select-option",
|
|
128
|
+
key: 'option-' + o[fieldNames.value],
|
|
129
|
+
onTap: function onTap() {
|
|
130
|
+
if (value instanceof Array) {
|
|
131
|
+
if (value.some(function (v) {
|
|
132
|
+
return v === o[fieldNames.value];
|
|
133
|
+
})) {
|
|
134
|
+
value.splice(value.findIndex(function (v) {
|
|
135
|
+
return v === o[fieldNames.value];
|
|
136
|
+
}), 1);
|
|
137
|
+
} else {
|
|
138
|
+
value.push(o[fieldNames.value]);
|
|
139
|
+
}
|
|
140
|
+
setValue(_toConsumableArray(value));
|
|
141
|
+
} else {
|
|
142
|
+
onOpenChange();
|
|
143
|
+
setValue(o[fieldNames.value]);
|
|
144
|
+
onChange === null || onChange === void 0 || onChange(o[fieldNames.value]);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}, renderIcon(o[fieldNames.value]), /*#__PURE__*/React.createElement(Text, {
|
|
148
|
+
className: "p-pro-form-item-select-option-text"
|
|
149
|
+
}, o[fieldNames.label]));
|
|
150
|
+
})) : /*#__PURE__*/React.createElement(Empty, {
|
|
151
|
+
description: "\u6682\u65E0\u6570\u636E"
|
|
152
|
+
}), popupExtra === null || popupExtra === void 0 ? void 0 : popupExtra.bottom);
|
|
153
|
+
}));
|
|
154
|
+
}, [value, options, open]);
|
|
155
|
+
return useMemo(function () {
|
|
156
|
+
return renderContent();
|
|
157
|
+
}, [value, options, open]);
|
|
158
|
+
};
|
|
159
|
+
export default Cascader;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
@import "@power-xa/m-ui/dist/assets/less/mixins.less";
|
|
2
|
+
|
|
3
|
+
.p-pro-form-item {
|
|
4
|
+
.p-pro-form-item-select {
|
|
5
|
+
min-height: 40px;
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
flex-wrap: wrap;
|
|
9
|
+
gap: 28px;
|
|
10
|
+
|
|
11
|
+
.p-pro-form-item-select-option {
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
gap: 12px;
|
|
15
|
+
|
|
16
|
+
.iconfont {
|
|
17
|
+
font-size: 28px;
|
|
18
|
+
line-height: 40px;
|
|
19
|
+
color: #999;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.icon-icon-checkbox,
|
|
23
|
+
.icon-icon-radio {
|
|
24
|
+
color: #333437;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.p-pro-form-item-select-option-text {
|
|
28
|
+
.font(28, #333437)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&.horizontal {
|
|
34
|
+
.p-pro-form-item-select {
|
|
35
|
+
width: 100%;
|
|
36
|
+
justify-content: flex-end;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.p-select-container {
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: center;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.p-pro-form-item-select-popup-container {
|
|
47
|
+
z-index: 99999;
|
|
48
|
+
|
|
49
|
+
.p-popup-container {
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-direction: column;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.p-popup-header {
|
|
55
|
+
.p-popup-header-extra.right {
|
|
56
|
+
.text {
|
|
57
|
+
.font(28, #333437)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.p-search-input-container {
|
|
63
|
+
margin: 0 32px;
|
|
64
|
+
background: #F6F7F9;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.p-pro-form-item-select-popup-content {
|
|
68
|
+
flex: 1;
|
|
69
|
+
height: 0;
|
|
70
|
+
margin-top: 16px;
|
|
71
|
+
|
|
72
|
+
.p-pro-form-item-select-option {
|
|
73
|
+
display: flex;
|
|
74
|
+
align-items: center;
|
|
75
|
+
gap: 20px;
|
|
76
|
+
padding: 24px 32px;
|
|
77
|
+
box-sizing: border-box;
|
|
78
|
+
|
|
79
|
+
.iconfont {
|
|
80
|
+
font-size: 28px;
|
|
81
|
+
color: #999;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.icon-icon-checkbox,
|
|
85
|
+
.icon-icon-radio {
|
|
86
|
+
color: #333437;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.p-pro-form-item-select-option-text {
|
|
90
|
+
.font(28, #333437)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.error-view {
|
|
95
|
+
width: 100%;
|
|
96
|
+
height: 100%;
|
|
97
|
+
display: flex;
|
|
98
|
+
align-items: center;
|
|
99
|
+
justify-content: center;
|
|
100
|
+
|
|
101
|
+
.text {
|
|
102
|
+
.font(24, #999)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
|
-
|
|
2
|
+
import type { ProFormFieldProps } from "../../Field";
|
|
3
|
+
import "./index.less";
|
|
4
|
+
export type ProFormDateProps = ProFormFieldProps & {
|
|
5
|
+
format?: "YYYY" | "YYYY-MM" | "YYYY-MM-DD" | "YYYY-MM-DD HH:mm" | "HH:mm" | string;
|
|
6
|
+
};
|
|
7
|
+
declare const ProFormDate: FC<ProFormDateProps>;
|
|
3
8
|
export default ProFormDate;
|
|
@@ -1,3 +1,4 @@
|
|
|
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); }
|
|
1
2
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
3
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
4
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
@@ -12,6 +13,7 @@ import React, { useCallback, useEffect, useState } from "react";
|
|
|
12
13
|
import { Picker, Text } from "@tarojs/components";
|
|
13
14
|
import { dateFormat } from "../../..";
|
|
14
15
|
import ProFormField from "../../Field";
|
|
16
|
+
import "./index.less";
|
|
15
17
|
var ProFormDate = function ProFormDate(props) {
|
|
16
18
|
var _props$placeholder = props.placeholder,
|
|
17
19
|
placeholder = _props$placeholder === void 0 ? "请选择" : _props$placeholder,
|
|
@@ -43,7 +45,7 @@ var ProFormDate = function ProFormDate(props) {
|
|
|
43
45
|
setCurrent = _useState10[1];
|
|
44
46
|
useEffect(function () {
|
|
45
47
|
getFormatRange();
|
|
46
|
-
}, []);
|
|
48
|
+
}, [format]);
|
|
47
49
|
useEffect(function () {
|
|
48
50
|
if (range.length && value) {
|
|
49
51
|
var list = value.split(/[\s:-]+/);
|
|
@@ -89,6 +91,10 @@ var ProFormDate = function ProFormDate(props) {
|
|
|
89
91
|
range = [yearList, makeStringArray(12, "月"), makeStringArray(31, "日")];
|
|
90
92
|
currentFormat = "YYYY年-MM月-DD日";
|
|
91
93
|
break;
|
|
94
|
+
case "YYYY-MM-DD FF":
|
|
95
|
+
range = [yearList, makeStringArray(12, "月"), makeStringArray(31, "日"), ["上午", "下午"]];
|
|
96
|
+
currentFormat = "YYYY年-MM月-DD日";
|
|
97
|
+
break;
|
|
92
98
|
case "YYYY-MM-DD HH:mm":
|
|
93
99
|
range = [yearList, makeStringArray(12, "月"), makeStringArray(31, "日"), makeStringArray(24, "时", true), makeStringArray(60, "分", true)];
|
|
94
100
|
currentFormat = "YYYY年-MM月-DD日-HH时-mm分";
|
|
@@ -100,12 +106,12 @@ var ProFormDate = function ProFormDate(props) {
|
|
|
100
106
|
}
|
|
101
107
|
var value = dateFormat(new Date(), currentFormat).split("-");
|
|
102
108
|
range.forEach(function (r, i) {
|
|
103
|
-
current[i] = r.indexOf(value[i]);
|
|
109
|
+
current[i] = r.indexOf(value[i] || "上午");
|
|
104
110
|
});
|
|
105
111
|
setCurrent(_toConsumableArray(current));
|
|
106
112
|
setDefaultValueList(_toConsumableArray(current));
|
|
107
113
|
setRange(range);
|
|
108
|
-
}, []);
|
|
114
|
+
}, [format]);
|
|
109
115
|
var updateRange = useCallback(function (_ref) {
|
|
110
116
|
var column = _ref.column,
|
|
111
117
|
value = _ref.value;
|
|
@@ -135,7 +141,9 @@ var ProFormDate = function ProFormDate(props) {
|
|
|
135
141
|
setDate(value);
|
|
136
142
|
onChange === null || onChange === void 0 || onChange(value);
|
|
137
143
|
}, [range]);
|
|
138
|
-
return /*#__PURE__*/React.createElement(ProFormField,
|
|
144
|
+
return /*#__PURE__*/React.createElement(ProFormField, _extends({}, props, {
|
|
145
|
+
className: "p-pro-form-item-date-container ".concat(props.className)
|
|
146
|
+
}), /*#__PURE__*/React.createElement(Picker, {
|
|
139
147
|
mode: "multiSelector",
|
|
140
148
|
range: range,
|
|
141
149
|
value: current,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.p-pro-form-item-date-container {
|
|
2
|
+
.p-pro-form-item-control {
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
|
|
6
|
+
.p-pro-form-item-control-picker {
|
|
7
|
+
flex: 2;
|
|
8
|
+
width: 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.p-pro-form-item {
|
|
12
|
+
padding: 0;
|
|
13
|
+
margin: 0;
|
|
14
|
+
flex: 1;
|
|
15
|
+
width: 0;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import { FC, ReactElement } from "react";
|
|
2
2
|
import { ProListProps } from "../../../ProList";
|
|
3
|
+
import type { ProFormFieldProps } from "../../Field";
|
|
3
4
|
import "./index.less";
|
|
4
|
-
type
|
|
5
|
-
add?: () => void;
|
|
6
|
-
remove?: () => void;
|
|
7
|
-
};
|
|
8
|
-
type ProFormListProps = ProFormAPI.ProFormItemProps & {
|
|
5
|
+
type ProFormListProps = ProFormFieldProps & {
|
|
9
6
|
extra?: ReactElement;
|
|
10
|
-
children?: (record: {
|
|
11
|
-
[key: string]: any;
|
|
12
|
-
}, option: OptionType, index?: number) => ReactElement;
|
|
13
7
|
record?: {
|
|
14
8
|
[key: string]: any;
|
|
15
9
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
1
|
var _excluded = ["extra", "children", "listProps", "record", "onAdd"];
|
|
3
2
|
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); }
|
|
4
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -6,11 +5,12 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
6
5
|
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; }
|
|
7
6
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
8
7
|
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); }
|
|
8
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
9
9
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
10
10
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
11
11
|
import React, { cloneElement, Fragment, useCallback } from "react";
|
|
12
12
|
import { Text, View } from "@tarojs/components";
|
|
13
|
-
import { getUUID, ProList
|
|
13
|
+
import { getUUID, ProList } from "../../..";
|
|
14
14
|
import ProFormField from "../../Field";
|
|
15
15
|
import "./index.less";
|
|
16
16
|
var ProFormList = function ProFormList(_ref) {
|
|
@@ -24,26 +24,34 @@ var ProFormList = function ProFormList(_ref) {
|
|
|
24
24
|
var disabled = fieldProps.disabled,
|
|
25
25
|
_fieldProps$value = fieldProps.value,
|
|
26
26
|
value = _fieldProps$value === void 0 ? [] : _fieldProps$value,
|
|
27
|
-
onChange = fieldProps.onChange
|
|
27
|
+
onChange = fieldProps.onChange,
|
|
28
|
+
name = fieldProps.name,
|
|
29
|
+
getFieldValue = fieldProps.getFieldValue,
|
|
30
|
+
setFieldValue = fieldProps.setFieldValue;
|
|
28
31
|
var renderListContent = useCallback(function (element, index) {
|
|
29
32
|
var _element$props, _element$props3;
|
|
30
33
|
if (!element) return null;
|
|
31
34
|
if (element !== null && element !== void 0 && (_element$props = element.props) !== null && _element$props !== void 0 && _element$props.name) {
|
|
35
|
+
var elName = ["string", "number"].includes(_typeof(element.props.name)) ? [name, index, element.props.name] : [name, index].concat(element.props.name);
|
|
32
36
|
return /*#__PURE__*/cloneElement(element, _objectSpread(_objectSpread({}, element.props), {}, {
|
|
37
|
+
key: 'p-pro-form-list-field-' + elName.join("-") + index,
|
|
33
38
|
disabled: fieldProps.disabled || element.props.disabled,
|
|
34
|
-
|
|
39
|
+
name: elName,
|
|
40
|
+
value: getFieldValue === null || getFieldValue === void 0 ? void 0 : getFieldValue(elName),
|
|
35
41
|
onChange: function onChange(result) {
|
|
36
|
-
var _element$props$onChan, _element$props2;
|
|
42
|
+
var _element$props$onChan, _element$props2, _fieldProps$onChange;
|
|
37
43
|
(_element$props$onChan = (_element$props2 = element.props).onChange) === null || _element$props$onChan === void 0 || _element$props$onChan.call(_element$props2, result);
|
|
38
|
-
|
|
44
|
+
setFieldValue === null || setFieldValue === void 0 || setFieldValue(elName, result);
|
|
45
|
+
(_fieldProps$onChange = fieldProps.onChange) === null || _fieldProps$onChange === void 0 || _fieldProps$onChange.call(fieldProps, value);
|
|
39
46
|
}
|
|
40
47
|
}));
|
|
41
48
|
}
|
|
42
49
|
if (element !== null && element !== void 0 && (_element$props3 = element.props) !== null && _element$props3 !== void 0 && _element$props3.children) {
|
|
43
50
|
return /*#__PURE__*/cloneElement(element, _objectSpread(_objectSpread({}, element.props), {}, {
|
|
44
|
-
|
|
51
|
+
key: 'p-pro-form-list-field-' + getUUID(),
|
|
52
|
+
children: element.props.children instanceof Array ? Array.from(element.props.children).map(function (item) {
|
|
45
53
|
return renderListContent(item, index);
|
|
46
|
-
})
|
|
54
|
+
}) : element.props.children
|
|
47
55
|
}));
|
|
48
56
|
}
|
|
49
57
|
return element;
|
|
@@ -59,7 +67,7 @@ var ProFormList = function ProFormList(_ref) {
|
|
|
59
67
|
}, []);
|
|
60
68
|
return /*#__PURE__*/React.createElement(ProFormField, _extends({}, fieldProps, {
|
|
61
69
|
layout: "vertical",
|
|
62
|
-
className: "p-pro-form-item-list",
|
|
70
|
+
className: "p-pro-form-item-list ".concat(fieldProps.className || ""),
|
|
63
71
|
extra: !disabled && /*#__PURE__*/React.createElement(View, {
|
|
64
72
|
className: "p-pro-form-item-header-button",
|
|
65
73
|
onTap: function onTap() {
|
|
File without changes
|