@trionesdev/antd-mobile-base-react 0.0.2-beta.6 → 0.0.2-beta.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/dist/Avatar/avatar.d.ts +2 -0
- package/dist/Avatar/avatar.js +5 -2
- package/dist/Cell/CellGroup.js +19 -5
- package/dist/Cell/cell.js +24 -8
- package/dist/Cell/context.d.ts +6 -0
- package/dist/Cell/styles.scss +3 -0
- package/dist/Cell/types.d.ts +13 -0
- package/dist/IndexedStack/IndexedStack.d.ts +9 -0
- package/dist/IndexedStack/IndexedStack.js +27 -0
- package/dist/IndexedStack/index.d.ts +3 -0
- package/dist/IndexedStack/index.js +2 -0
- package/dist/Progress/Progress.d.ts +39 -0
- package/dist/Progress/Progress.js +56 -0
- package/dist/Progress/ProgressCircle.d.ts +15 -0
- package/dist/Progress/ProgressCircle.js +114 -0
- package/dist/Progress/ProgressLine.d.ts +15 -0
- package/dist/Progress/ProgressLine.js +87 -0
- package/dist/Progress/index.d.ts +3 -0
- package/dist/Progress/index.js +2 -0
- package/dist/Progress/style.scss +33 -0
- package/dist/Progress/types.d.ts +6 -0
- package/dist/Progress/types.js +2 -0
- package/dist/Skeleton/Skeleton.d.ts +27 -0
- package/dist/Skeleton/Skeleton.js +72 -0
- package/dist/Skeleton/index.d.ts +1 -0
- package/dist/Skeleton/index.js +1 -0
- package/dist/Skeleton/style.scss +48 -0
- package/dist/index.d.ts +4 -18
- package/dist/index.js +2 -9
- package/package.json +3 -3
- package/dist/ActionSheet/ActionSheet.d.ts +0 -25
- package/dist/ActionSheet/ActionSheet.js +0 -77
- package/dist/ActionSheet/index.d.ts +0 -3
- package/dist/ActionSheet/index.js +0 -2
- package/dist/ActionSheet/style.scss +0 -52
- package/dist/CascaderPicker/cascader-picker.d.ts +0 -27
- package/dist/CascaderPicker/cascader-picker.js +0 -88
- package/dist/CascaderPicker/index.d.ts +0 -3
- package/dist/CascaderPicker/index.js +0 -2
- package/dist/CascaderPicker/style.scss +0 -42
- package/dist/Mask/index.d.ts +0 -3
- package/dist/Mask/index.js +0 -2
- package/dist/Mask/mask-modal.d.ts +0 -45
- package/dist/Mask/mask-modal.js +0 -32
- package/dist/Mask/mask.d.ts +0 -5
- package/dist/Mask/mask.js +0 -19
- package/dist/Mask/style.scss +0 -20
- package/dist/Picker/index.d.ts +0 -3
- package/dist/Picker/index.js +0 -2
- package/dist/Picker/picker.d.ts +0 -19
- package/dist/Picker/picker.js +0 -97
- package/dist/Picker/style.scss +0 -41
- package/dist/PickerView/index.d.ts +0 -4
- package/dist/PickerView/index.js +0 -2
- package/dist/PickerView/picker-view-column-item.d.ts +0 -7
- package/dist/PickerView/picker-view-column-item.js +0 -11
- package/dist/PickerView/picker-view-column.d.ts +0 -10
- package/dist/PickerView/picker-view-column.js +0 -117
- package/dist/PickerView/picker-view.d.ts +0 -12
- package/dist/PickerView/picker-view.js +0 -60
- package/dist/PickerView/style.scss +0 -72
- package/dist/PickerView/types.d.ts +0 -4
- package/dist/PickerView/types.js +0 -1
- package/dist/Popup/index.d.ts +0 -5
- package/dist/Popup/index.js +0 -4
- package/dist/Popup/popup-modal.d.ts +0 -52
- package/dist/Popup/popup-modal.js +0 -74
- package/dist/Popup/popup.d.ts +0 -4
- package/dist/Popup/popup.js +0 -56
- package/dist/Popup/style.scss +0 -53
- package/dist/ScrollView/index.d.ts +0 -4
- package/dist/ScrollView/index.js +0 -2
- package/dist/ScrollView/scroll-view.d.ts +0 -4
- package/dist/ScrollView/scroll-view.js +0 -55
- package/dist/ScrollView/style.scss +0 -19
- package/dist/ScrollView/types.d.ts +0 -26
- package/dist/ScrollView/types.js +0 -1
- package/dist/SideBar/SideBarContext.d.ts +0 -18
- package/dist/SideBar/SideBarContext.js +0 -2
- package/dist/SideBar/index.d.ts +0 -3
- package/dist/SideBar/index.js +0 -2
- package/dist/SideBar/side-bar.d.ts +0 -25
- package/dist/SideBar/side-bar.js +0 -351
- package/dist/SideBar/style.scss +0 -85
- package/dist/SideBar/types.d.ts +0 -7
- package/dist/SideBar/types.js +0 -1
- package/dist/Toast/index.d.ts +0 -5
- package/dist/Toast/index.js +0 -3
- package/dist/Toast/style.scss +0 -63
- package/dist/Toast/toast-modal.d.ts +0 -18
- package/dist/Toast/toast-modal.js +0 -112
- package/dist/Toast/toast.d.ts +0 -7
- package/dist/Toast/toast.js +0 -78
package/dist/Avatar/avatar.d.ts
CHANGED
package/dist/Avatar/avatar.js
CHANGED
|
@@ -16,6 +16,8 @@ export var Avatar = function Avatar(_ref) {
|
|
|
16
16
|
size = _ref$size === void 0 ? 32 : _ref$size,
|
|
17
17
|
src = _ref.src,
|
|
18
18
|
srcSet = _ref.srcSet,
|
|
19
|
+
onClick = _ref.onClick,
|
|
20
|
+
className = _ref.className,
|
|
19
21
|
style = _ref.style,
|
|
20
22
|
children = _ref.children;
|
|
21
23
|
var clsPrefix = 'triones-antm-avatar';
|
|
@@ -30,12 +32,13 @@ export var Avatar = function Avatar(_ref) {
|
|
|
30
32
|
}[size];
|
|
31
33
|
}, [size]);
|
|
32
34
|
return /*#__PURE__*/React.createElement("div", {
|
|
33
|
-
className: classNames(clsPrefix, _defineProperty({}, "".concat(clsPrefix, "-").concat(shape !== 'square' ? 'circle' : 'square'), true)),
|
|
35
|
+
className: classNames(clsPrefix, _defineProperty({}, "".concat(clsPrefix, "-").concat(shape !== 'square' ? 'circle' : 'square'), true), className),
|
|
34
36
|
style: _objectSpread({
|
|
35
37
|
width: avatarSize,
|
|
36
38
|
height: avatarSize,
|
|
37
39
|
backgroundColor: src ? undefined : '#ccc'
|
|
38
|
-
}, style)
|
|
40
|
+
}, style),
|
|
41
|
+
onClick: onClick
|
|
39
42
|
}, src ? typeof src === 'string' ? /*#__PURE__*/React.createElement("img", {
|
|
40
43
|
src: src,
|
|
41
44
|
srcSet: srcSet,
|
package/dist/Cell/CellGroup.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
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
|
+
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; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
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
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
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); }
|
|
1
7
|
import classNames from 'classnames';
|
|
2
8
|
import React from 'react';
|
|
3
9
|
import { cls } from "./types";
|
|
@@ -13,7 +19,8 @@ export var CellGroup = function CellGroup(_ref) {
|
|
|
13
19
|
labelCol = _ref.labelCol,
|
|
14
20
|
labelAlign = _ref.labelAlign,
|
|
15
21
|
wrapperAlign = _ref.wrapperAlign,
|
|
16
|
-
divider = _ref.divider
|
|
22
|
+
divider = _ref.divider,
|
|
23
|
+
styles = _ref.styles;
|
|
17
24
|
var handleRender = function handleRender() {
|
|
18
25
|
if (children) {
|
|
19
26
|
if (Array.isArray(children)) {
|
|
@@ -38,12 +45,19 @@ export var CellGroup = function CellGroup(_ref) {
|
|
|
38
45
|
labelCol: labelCol,
|
|
39
46
|
labelAlign: labelAlign,
|
|
40
47
|
wrapperAlign: wrapperAlign,
|
|
41
|
-
extra: extra
|
|
48
|
+
extra: extra,
|
|
49
|
+
styles: {
|
|
50
|
+
cell: styles === null || styles === void 0 ? void 0 : styles.cell,
|
|
51
|
+
label: styles === null || styles === void 0 ? void 0 : styles.label,
|
|
52
|
+
content: styles === null || styles === void 0 ? void 0 : styles.content,
|
|
53
|
+
extra: styles === null || styles === void 0 ? void 0 : styles.extra
|
|
54
|
+
}
|
|
42
55
|
}
|
|
43
56
|
}, /*#__PURE__*/React.createElement("div", {
|
|
44
57
|
className: classNames("".concat(cls, "-group"), className),
|
|
45
|
-
style: style
|
|
58
|
+
style: _objectSpread(_objectSpread({}, style), styles === null || styles === void 0 ? void 0 : styles.container)
|
|
46
59
|
}, title && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
47
|
-
className: classNames("".concat(cls, "-group-title"))
|
|
48
|
-
|
|
60
|
+
className: classNames("".concat(cls, "-group-title")),
|
|
61
|
+
style: styles === null || styles === void 0 ? void 0 : styles.title
|
|
62
|
+
}, title)), handleRender()));
|
|
49
63
|
};
|
package/dist/Cell/cell.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
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
|
+
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; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
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
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
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); }
|
|
1
7
|
import classNames from 'classnames';
|
|
2
8
|
import React, { useContext, useMemo } from 'react';
|
|
3
9
|
import "./styles.scss";
|
|
4
10
|
import { CellGroupContext } from "./context";
|
|
11
|
+
import { assign } from "lodash-es";
|
|
5
12
|
var cls = 'triones-antm-cell';
|
|
6
13
|
export var Cell = function Cell(_ref) {
|
|
7
14
|
var className = _ref.className,
|
|
@@ -13,12 +20,14 @@ export var Cell = function Cell(_ref) {
|
|
|
13
20
|
labelCol = _ref.labelCol,
|
|
14
21
|
labelAlign = _ref.labelAlign,
|
|
15
22
|
wrapperAlign = _ref.wrapperAlign,
|
|
16
|
-
onClick = _ref.onClick
|
|
23
|
+
onClick = _ref.onClick,
|
|
24
|
+
styles = _ref.styles;
|
|
17
25
|
var _useContext = useContext(CellGroupContext),
|
|
18
26
|
ctxLabelCol = _useContext.labelCol,
|
|
19
27
|
ctxLabelAlign = _useContext.labelAlign,
|
|
20
28
|
ctxWrapperAlign = _useContext.wrapperAlign,
|
|
21
|
-
ctxExtra = _useContext.extra
|
|
29
|
+
ctxExtra = _useContext.extra,
|
|
30
|
+
ctxStyles = _useContext.styles;
|
|
22
31
|
var labelWidth = useMemo(function () {
|
|
23
32
|
return (labelCol === null || labelCol === void 0 ? void 0 : labelCol.flex) || (ctxLabelCol === null || ctxLabelCol === void 0 ? void 0 : ctxLabelCol.flex) || 'auto';
|
|
24
33
|
}, [labelCol, ctxLabelCol]);
|
|
@@ -48,22 +57,29 @@ export var Cell = function Cell(_ref) {
|
|
|
48
57
|
return 'start';
|
|
49
58
|
}
|
|
50
59
|
}, [wrapperAlign, ctxWrapperAlign]);
|
|
60
|
+
var mergedStyles = assign({}, ctxStyles, styles);
|
|
61
|
+
if (style) {
|
|
62
|
+
mergedStyles.cell = assign(mergedStyles.cell, style);
|
|
63
|
+
}
|
|
51
64
|
return /*#__PURE__*/React.createElement("div", {
|
|
52
65
|
className: classNames(cls, className),
|
|
53
|
-
style:
|
|
66
|
+
style: _objectSpread({}, mergedStyles.cell),
|
|
54
67
|
onClick: onClick
|
|
55
68
|
}, label && /*#__PURE__*/React.createElement("div", {
|
|
56
69
|
className: classNames("".concat(cls, "-label")),
|
|
57
|
-
style: {
|
|
70
|
+
style: _objectSpread({
|
|
58
71
|
width: labelWidth,
|
|
59
72
|
justifyContent: labelAlignStyle
|
|
60
|
-
}
|
|
73
|
+
}, mergedStyles === null || mergedStyles === void 0 ? void 0 : mergedStyles.label)
|
|
61
74
|
}, label), /*#__PURE__*/React.createElement("div", {
|
|
62
75
|
className: classNames("".concat(cls, "-content")),
|
|
63
|
-
style: {
|
|
76
|
+
style: _objectSpread({
|
|
64
77
|
justifyContent: wrapperAlignStyle
|
|
65
|
-
}
|
|
78
|
+
}, mergedStyles === null || mergedStyles === void 0 ? void 0 : mergedStyles.content)
|
|
66
79
|
}, children || placeholder && /*#__PURE__*/React.createElement("div", {
|
|
67
80
|
className: classNames("".concat(cls, "-placeholder"))
|
|
68
|
-
}, placeholder)), extra || ctxExtra)
|
|
81
|
+
}, placeholder)), (extra || ctxExtra) && /*#__PURE__*/React.createElement("div", {
|
|
82
|
+
className: classNames("".concat(cls, "-extra")),
|
|
83
|
+
style: mergedStyles === null || mergedStyles === void 0 ? void 0 : mergedStyles.extra
|
|
84
|
+
}, extra || ctxExtra));
|
|
69
85
|
};
|
package/dist/Cell/context.d.ts
CHANGED
|
@@ -6,6 +6,12 @@ type CellGroupContextType = {
|
|
|
6
6
|
labelAlign?: align;
|
|
7
7
|
wrapperAlign?: align;
|
|
8
8
|
extra?: React.ReactNode;
|
|
9
|
+
styles?: {
|
|
10
|
+
cell?: React.CSSProperties;
|
|
11
|
+
label?: React.CSSProperties;
|
|
12
|
+
content?: React.CSSProperties;
|
|
13
|
+
extra?: React.CSSProperties;
|
|
14
|
+
};
|
|
9
15
|
};
|
|
10
16
|
export declare const CellGroupContext: React.Context<CellGroupContextType>;
|
|
11
17
|
export {};
|
package/dist/Cell/styles.scss
CHANGED
|
@@ -6,6 +6,7 @@ $cellCls: 'triones-antm-cell';
|
|
|
6
6
|
padding-block: 4Px;
|
|
7
7
|
display: flex;
|
|
8
8
|
gap: 4Px;
|
|
9
|
+
align-items: center;
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
&-label {
|
|
@@ -20,6 +21,8 @@ $cellCls: 'triones-antm-cell';
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
&-extra {
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
|
package/dist/Cell/types.d.ts
CHANGED
|
@@ -28,6 +28,11 @@ export type CellProps = {
|
|
|
28
28
|
labelCol?: Col;
|
|
29
29
|
labelAlign?: align;
|
|
30
30
|
wrapperAlign?: align;
|
|
31
|
+
styles?: {
|
|
32
|
+
label?: React.CSSProperties;
|
|
33
|
+
content?: React.CSSProperties;
|
|
34
|
+
extra?: React.CSSProperties;
|
|
35
|
+
};
|
|
31
36
|
};
|
|
32
37
|
export type CellGroupProps = {
|
|
33
38
|
className?: string;
|
|
@@ -46,4 +51,12 @@ export type CellGroupProps = {
|
|
|
46
51
|
labelAlign?: align;
|
|
47
52
|
wrapperAlign?: align;
|
|
48
53
|
divider?: ReactNode;
|
|
54
|
+
styles?: {
|
|
55
|
+
container?: React.CSSProperties;
|
|
56
|
+
title?: React.CSSProperties;
|
|
57
|
+
cell?: React.CSSProperties;
|
|
58
|
+
label?: React.CSSProperties;
|
|
59
|
+
content?: React.CSSProperties;
|
|
60
|
+
extra?: React.CSSProperties;
|
|
61
|
+
};
|
|
49
62
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
export interface IndexedStackProps {
|
|
3
|
+
children: ReactNode[];
|
|
4
|
+
activeIndex: number;
|
|
5
|
+
className?: string;
|
|
6
|
+
style?: React.CSSProperties;
|
|
7
|
+
}
|
|
8
|
+
declare const IndexedStack: React.FC<IndexedStackProps>;
|
|
9
|
+
export { IndexedStack };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
var IndexedStack = function IndexedStack(_ref) {
|
|
3
|
+
var children = _ref.children,
|
|
4
|
+
_ref$activeIndex = _ref.activeIndex,
|
|
5
|
+
activeIndex = _ref$activeIndex === void 0 ? 0 : _ref$activeIndex,
|
|
6
|
+
className = _ref.className,
|
|
7
|
+
style = _ref.style;
|
|
8
|
+
// 确保 activeIndex 在有效范围内
|
|
9
|
+
var validActiveIndex = Math.max(0, Math.min(activeIndex, children.length - 1));
|
|
10
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
11
|
+
className: className,
|
|
12
|
+
style: style
|
|
13
|
+
}, React.Children.map(children, function (child, index) {
|
|
14
|
+
if (! /*#__PURE__*/React.isValidElement(child)) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
18
|
+
key: index,
|
|
19
|
+
style: {
|
|
20
|
+
display: index === validActiveIndex ? 'block' : 'none',
|
|
21
|
+
width: '100%',
|
|
22
|
+
height: '100%'
|
|
23
|
+
}
|
|
24
|
+
}, child);
|
|
25
|
+
}));
|
|
26
|
+
};
|
|
27
|
+
export { IndexedStack };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { Size } from "./types";
|
|
3
|
+
import "./style.scss";
|
|
4
|
+
import { PercentPositionAlign, ProgressStatus } from "./types";
|
|
5
|
+
import "./style.scss";
|
|
6
|
+
export type ProgressProps = {
|
|
7
|
+
/**
|
|
8
|
+
* @description 内容的模板函数
|
|
9
|
+
* @default percent => `${percent}%`
|
|
10
|
+
*/
|
|
11
|
+
format?: (percent: number) => string;
|
|
12
|
+
type?: 'line' | 'circle';
|
|
13
|
+
/**
|
|
14
|
+
* @description 百分比
|
|
15
|
+
* @default 0
|
|
16
|
+
*/
|
|
17
|
+
percent?: number;
|
|
18
|
+
size?: Size;
|
|
19
|
+
/**
|
|
20
|
+
* @description 是否显示进度数值或状态图标
|
|
21
|
+
* @default true
|
|
22
|
+
*/
|
|
23
|
+
showInfo?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* @description 未完成的分段的颜色
|
|
26
|
+
*/
|
|
27
|
+
railColor?: string;
|
|
28
|
+
/**
|
|
29
|
+
* @description 进度条的色彩
|
|
30
|
+
*/
|
|
31
|
+
strokeColor?: string;
|
|
32
|
+
strokeWidth?: number;
|
|
33
|
+
status?: ProgressStatus;
|
|
34
|
+
/**
|
|
35
|
+
* @description 进度数值位置
|
|
36
|
+
*/
|
|
37
|
+
percentPositionAlign?: PercentPositionAlign;
|
|
38
|
+
};
|
|
39
|
+
export declare const Progress: FC<ProgressProps>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ProgressCircle } from "./ProgressCircle";
|
|
3
|
+
import "./style.scss";
|
|
4
|
+
import { ProgressLine } from "./ProgressLine";
|
|
5
|
+
import { exceptionColor, successColor } from "./types";
|
|
6
|
+
import "./style.scss";
|
|
7
|
+
export var Progress = function Progress(_ref) {
|
|
8
|
+
var format = _ref.format,
|
|
9
|
+
_ref$type = _ref.type,
|
|
10
|
+
type = _ref$type === void 0 ? 'line' : _ref$type,
|
|
11
|
+
_ref$percent = _ref.percent,
|
|
12
|
+
percent = _ref$percent === void 0 ? 0 : _ref$percent,
|
|
13
|
+
_ref$size = _ref.size,
|
|
14
|
+
size = _ref$size === void 0 ? 'middle' : _ref$size,
|
|
15
|
+
_ref$showInfo = _ref.showInfo,
|
|
16
|
+
showInfo = _ref$showInfo === void 0 ? true : _ref$showInfo,
|
|
17
|
+
_ref$railColor = _ref.railColor,
|
|
18
|
+
railColor = _ref$railColor === void 0 ? '#E5E5E5' : _ref$railColor,
|
|
19
|
+
_ref$strokeColor = _ref.strokeColor,
|
|
20
|
+
strokeColor = _ref$strokeColor === void 0 ? '#1777FF' : _ref$strokeColor,
|
|
21
|
+
_ref$strokeWidth = _ref.strokeWidth,
|
|
22
|
+
strokeWidth = _ref$strokeWidth === void 0 ? 6 : _ref$strokeWidth,
|
|
23
|
+
status = _ref.status,
|
|
24
|
+
percentPositionAlign = _ref.percentPositionAlign;
|
|
25
|
+
var handleComputedStrokeColor = function handleComputedStrokeColor() {
|
|
26
|
+
if (status === 'exception') {
|
|
27
|
+
return exceptionColor;
|
|
28
|
+
}
|
|
29
|
+
if (percent >= 100) {
|
|
30
|
+
return successColor;
|
|
31
|
+
}
|
|
32
|
+
return strokeColor;
|
|
33
|
+
};
|
|
34
|
+
if (type === 'line') {
|
|
35
|
+
return /*#__PURE__*/React.createElement(ProgressLine, {
|
|
36
|
+
format: format,
|
|
37
|
+
percent: percent,
|
|
38
|
+
size: size,
|
|
39
|
+
railColor: railColor,
|
|
40
|
+
strokeColor: handleComputedStrokeColor(),
|
|
41
|
+
status: status,
|
|
42
|
+
showInfo: showInfo,
|
|
43
|
+
percentPositionAlign: percentPositionAlign
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return /*#__PURE__*/React.createElement(ProgressCircle, {
|
|
47
|
+
format: format,
|
|
48
|
+
percent: percent,
|
|
49
|
+
size: size,
|
|
50
|
+
railColor: railColor,
|
|
51
|
+
strokeColor: handleComputedStrokeColor(),
|
|
52
|
+
strokeWidth: strokeWidth,
|
|
53
|
+
showInfo: showInfo,
|
|
54
|
+
status: status
|
|
55
|
+
});
|
|
56
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { ProgressStatus, Size } from "./types";
|
|
3
|
+
type ProcessCircleProps = {
|
|
4
|
+
format?: (percent: number) => string;
|
|
5
|
+
percent?: number;
|
|
6
|
+
strokeWidth?: number;
|
|
7
|
+
size?: Size;
|
|
8
|
+
showInfo?: boolean;
|
|
9
|
+
railColor?: string;
|
|
10
|
+
strokeColor?: string;
|
|
11
|
+
strokeLineCap?: 'butt' | 'round' | 'square';
|
|
12
|
+
status?: ProgressStatus;
|
|
13
|
+
};
|
|
14
|
+
export declare const ProgressCircle: FC<ProcessCircleProps>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,114 @@
|
|
|
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
|
+
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; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
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
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
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
|
+
import React, { memo, useMemo } from "react";
|
|
8
|
+
import { exceptionColor, successColor } from "./types";
|
|
9
|
+
import classNames from "classnames";
|
|
10
|
+
import { CheckOutline, CloseOutline } from "@trionesdev/antd-mobile-icons-react";
|
|
11
|
+
export var ProgressCircle = /*#__PURE__*/memo(function (_ref) {
|
|
12
|
+
var format = _ref.format,
|
|
13
|
+
_ref$percent = _ref.percent,
|
|
14
|
+
percent = _ref$percent === void 0 ? 0 : _ref$percent,
|
|
15
|
+
_ref$strokeWidth = _ref.strokeWidth,
|
|
16
|
+
strokeWidth = _ref$strokeWidth === void 0 ? 6 : _ref$strokeWidth,
|
|
17
|
+
_ref$size = _ref.size,
|
|
18
|
+
size = _ref$size === void 0 ? 'middle' : _ref$size,
|
|
19
|
+
_ref$showInfo = _ref.showInfo,
|
|
20
|
+
showInfo = _ref$showInfo === void 0 ? true : _ref$showInfo,
|
|
21
|
+
_ref$railColor = _ref.railColor,
|
|
22
|
+
railColor = _ref$railColor === void 0 ? '#E5E5E5' : _ref$railColor,
|
|
23
|
+
_ref$strokeColor = _ref.strokeColor,
|
|
24
|
+
strokeColor = _ref$strokeColor === void 0 ? '#1777FF' : _ref$strokeColor,
|
|
25
|
+
_ref$strokeLineCap = _ref.strokeLineCap,
|
|
26
|
+
strokeLineCap = _ref$strokeLineCap === void 0 ? 'round' : _ref$strokeLineCap,
|
|
27
|
+
status = _ref.status;
|
|
28
|
+
var clsPrefix = 'triones-antm-progress-circle';
|
|
29
|
+
var computedDiameter = useMemo(function () {
|
|
30
|
+
switch (size) {
|
|
31
|
+
case 'small':
|
|
32
|
+
return 50;
|
|
33
|
+
case 'middle':
|
|
34
|
+
return 100;
|
|
35
|
+
case 'large':
|
|
36
|
+
return 150;
|
|
37
|
+
default:
|
|
38
|
+
return size || 50;
|
|
39
|
+
}
|
|
40
|
+
}, [size]);
|
|
41
|
+
var style = {
|
|
42
|
+
width: computedDiameter,
|
|
43
|
+
height: computedDiameter
|
|
44
|
+
};
|
|
45
|
+
var computedIconSize = function computedIconSize() {
|
|
46
|
+
var iconSize = (computedDiameter - strokeWidth) / 2 / 3;
|
|
47
|
+
if (iconSize < 24) {
|
|
48
|
+
return 24;
|
|
49
|
+
}
|
|
50
|
+
return iconSize;
|
|
51
|
+
};
|
|
52
|
+
var computePercentSize = function computePercentSize() {
|
|
53
|
+
var percentSize = (computedDiameter - strokeWidth) / 2 / 3;
|
|
54
|
+
if (percentSize < 10) {
|
|
55
|
+
return 10;
|
|
56
|
+
}
|
|
57
|
+
return percentSize || 10;
|
|
58
|
+
};
|
|
59
|
+
var handleIndicator = function handleIndicator() {
|
|
60
|
+
var iconSize = computedIconSize();
|
|
61
|
+
var percentSize = computePercentSize();
|
|
62
|
+
var indicatorColor = '#333';
|
|
63
|
+
if (status === 'exception') {
|
|
64
|
+
indicatorColor = exceptionColor;
|
|
65
|
+
}
|
|
66
|
+
if (percent >= 100) {
|
|
67
|
+
indicatorColor = successColor;
|
|
68
|
+
}
|
|
69
|
+
if (format) {
|
|
70
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
71
|
+
style: {
|
|
72
|
+
color: indicatorColor,
|
|
73
|
+
fontSize: percentSize
|
|
74
|
+
}
|
|
75
|
+
}, format(percent));
|
|
76
|
+
}
|
|
77
|
+
if (status === 'exception') {
|
|
78
|
+
return /*#__PURE__*/React.createElement(CloseOutline, {
|
|
79
|
+
style: {
|
|
80
|
+
color: indicatorColor,
|
|
81
|
+
fontSize: iconSize
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
if (percent >= 100) {
|
|
86
|
+
return /*#__PURE__*/React.createElement(CheckOutline, {
|
|
87
|
+
style: {
|
|
88
|
+
color: indicatorColor,
|
|
89
|
+
fontSize: iconSize
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
94
|
+
style: {
|
|
95
|
+
color: indicatorColor,
|
|
96
|
+
fontSize: percentSize
|
|
97
|
+
}
|
|
98
|
+
}, percent, "%");
|
|
99
|
+
};
|
|
100
|
+
var radius = (computedDiameter - strokeWidth) / 2;
|
|
101
|
+
var circumference = 2 * Math.PI * radius; // 圆周长
|
|
102
|
+
|
|
103
|
+
// 计算偏移量:(1 - 比例) * 周长
|
|
104
|
+
var offset = circumference - percent / 100 * circumference;
|
|
105
|
+
var svg = "<svg xmlns='http://www.w3.org/2000/svg' width=\"".concat(computedDiameter, "\" height=\"").concat(computedDiameter, "\">\n <circle\n cx=\"").concat(computedDiameter / 2, "\"\n cy=\"").concat(computedDiameter / 2, "\"\n r=\"").concat(radius, "\"\n stroke=\"#e5e7eb\"\n stroke-width=\"").concat(strokeWidth, "\"\n fill=\"transparent\"\n />\n <circle\n cx=\"").concat(computedDiameter / 2, "\"\n cy=\"").concat(computedDiameter / 2, "\"\n r=\"").concat(radius, "\"\n stroke=\"").concat(strokeColor, "\"\n stroke-width=\"").concat(strokeWidth, "\"\n fill=\"transparent\"\n stroke-dasharray=\"").concat(circumference, "\"\n stroke-dashoffset=\"").concat(offset, "\"\n stroke-linecap=\"").concat(strokeLineCap, "\"\n transform=\"rotate(-90, ").concat(computedDiameter / 2, ", ").concat(computedDiameter / 2, ")\"\n />\n</svg>");
|
|
106
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
107
|
+
className: classNames("".concat(clsPrefix)),
|
|
108
|
+
style: _objectSpread(_objectSpread({}, style), {}, {
|
|
109
|
+
backgroundImage: "url(\"data:image/svg+xml,".concat(encodeURIComponent(svg), "\")")
|
|
110
|
+
})
|
|
111
|
+
}, showInfo && computedDiameter > 20 && /*#__PURE__*/React.createElement("div", {
|
|
112
|
+
className: "".concat(clsPrefix, "-indicator")
|
|
113
|
+
}, handleIndicator()));
|
|
114
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Size } from "./types";
|
|
2
|
+
import { FC } from "react";
|
|
3
|
+
import { PercentPositionAlign, ProgressStatus } from "./types";
|
|
4
|
+
type ProgressLineProps = {
|
|
5
|
+
format?: (percent: number) => string;
|
|
6
|
+
percent?: number;
|
|
7
|
+
size?: Size;
|
|
8
|
+
showInfo?: boolean;
|
|
9
|
+
railColor?: string;
|
|
10
|
+
strokeColor?: string;
|
|
11
|
+
status?: ProgressStatus;
|
|
12
|
+
percentPositionAlign?: PercentPositionAlign;
|
|
13
|
+
};
|
|
14
|
+
export declare const ProgressLine: FC<ProgressLineProps>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import { exceptionColor, successColor } from "./types";
|
|
4
|
+
import { CloseCircleFill, CheckCircleFill } from "@trionesdev/antd-mobile-icons-react";
|
|
5
|
+
export var ProgressLine = function ProgressLine(_ref) {
|
|
6
|
+
var format = _ref.format,
|
|
7
|
+
_ref$percent = _ref.percent,
|
|
8
|
+
percent = _ref$percent === void 0 ? 0 : _ref$percent,
|
|
9
|
+
_ref$size = _ref.size,
|
|
10
|
+
size = _ref$size === void 0 ? 'middle' : _ref$size,
|
|
11
|
+
_ref$showInfo = _ref.showInfo,
|
|
12
|
+
showInfo = _ref$showInfo === void 0 ? true : _ref$showInfo,
|
|
13
|
+
_ref$railColor = _ref.railColor,
|
|
14
|
+
railColor = _ref$railColor === void 0 ? '#E5E5E5' : _ref$railColor,
|
|
15
|
+
_ref$strokeColor = _ref.strokeColor,
|
|
16
|
+
strokeColor = _ref$strokeColor === void 0 ? '#1777FF' : _ref$strokeColor,
|
|
17
|
+
status = _ref.status,
|
|
18
|
+
_ref$percentPositionA = _ref.percentPositionAlign,
|
|
19
|
+
percentPositionAlign = _ref$percentPositionA === void 0 ? 'end' : _ref$percentPositionA;
|
|
20
|
+
var clsPrefix = 'triones-antm-progress-line';
|
|
21
|
+
var handleComputeLineHeight = function handleComputeLineHeight() {
|
|
22
|
+
switch (size) {
|
|
23
|
+
case 'small':
|
|
24
|
+
return 6;
|
|
25
|
+
case 'middle':
|
|
26
|
+
return 8;
|
|
27
|
+
case 'large':
|
|
28
|
+
return 12;
|
|
29
|
+
default:
|
|
30
|
+
return size || 8;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var handleComputeInfoHeight = function handleComputeInfoHeight() {
|
|
34
|
+
var lineHeight = handleComputeLineHeight();
|
|
35
|
+
if (lineHeight <= 8) {
|
|
36
|
+
return 12;
|
|
37
|
+
} else if (lineHeight <= 12) {
|
|
38
|
+
return 14;
|
|
39
|
+
} else {
|
|
40
|
+
return 16;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var handleIndicator = function handleIndicator() {
|
|
44
|
+
if (format) {
|
|
45
|
+
return /*#__PURE__*/React.createElement("div", null, format(percent));
|
|
46
|
+
}
|
|
47
|
+
if (status === 'exception') {
|
|
48
|
+
return /*#__PURE__*/React.createElement(CloseCircleFill, {
|
|
49
|
+
style: {
|
|
50
|
+
color: exceptionColor,
|
|
51
|
+
fontSize: handleComputeInfoHeight()
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (percent >= 100) {
|
|
56
|
+
return /*#__PURE__*/React.createElement(CheckCircleFill, {
|
|
57
|
+
style: {
|
|
58
|
+
color: successColor,
|
|
59
|
+
fontSize: handleComputeInfoHeight()
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
64
|
+
style: {
|
|
65
|
+
fontSize: handleComputeInfoHeight()
|
|
66
|
+
}
|
|
67
|
+
}, percent, "%");
|
|
68
|
+
};
|
|
69
|
+
var info = /*#__PURE__*/React.createElement("div", {
|
|
70
|
+
className: classNames("".concat(clsPrefix, "-indicator"))
|
|
71
|
+
}, handleIndicator());
|
|
72
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
73
|
+
className: classNames(clsPrefix)
|
|
74
|
+
}, showInfo && percentPositionAlign === 'start' && info, /*#__PURE__*/React.createElement("div", {
|
|
75
|
+
className: classNames("".concat(clsPrefix, "-rail")),
|
|
76
|
+
style: {
|
|
77
|
+
backgroundColor: railColor
|
|
78
|
+
}
|
|
79
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
80
|
+
className: classNames("".concat(clsPrefix, "-track")),
|
|
81
|
+
style: {
|
|
82
|
+
width: "".concat(percent, "%"),
|
|
83
|
+
backgroundColor: strokeColor,
|
|
84
|
+
height: handleComputeLineHeight()
|
|
85
|
+
}
|
|
86
|
+
})), showInfo && percentPositionAlign === 'end' && info);
|
|
87
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
$progressLineCls: 'triones-antm-progress-line';
|
|
2
|
+
$progressCircleCls: 'triones-antm-progress-circle';
|
|
3
|
+
|
|
4
|
+
.#{$progressLineCls}{
|
|
5
|
+
width: 100%;
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
gap: 4Px;
|
|
9
|
+
&-rail{
|
|
10
|
+
flex: 1 auto;
|
|
11
|
+
border-radius: 90Px;
|
|
12
|
+
}
|
|
13
|
+
&-track{
|
|
14
|
+
border-radius: 90Px;
|
|
15
|
+
}
|
|
16
|
+
&-indicator{}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.#{$progressCircleCls} {
|
|
20
|
+
position: relative;
|
|
21
|
+
&-indicator {
|
|
22
|
+
position: absolute;
|
|
23
|
+
inset-block-start: 50%;
|
|
24
|
+
inset-inline-start: 0;
|
|
25
|
+
width: 100%;
|
|
26
|
+
margin: 0;
|
|
27
|
+
padding: 0;
|
|
28
|
+
line-height: 1;
|
|
29
|
+
white-space: normal;
|
|
30
|
+
text-align: center;
|
|
31
|
+
transform: translatey(-50%);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SizeType } from "..";
|
|
2
|
+
export type Size = SizeType | number;
|
|
3
|
+
export type ProgressStatus = 'normal' | 'active' | 'success' | 'exception';
|
|
4
|
+
export type PercentPositionAlign = 'start' | 'end';
|
|
5
|
+
export declare const successColor = "#53C31B";
|
|
6
|
+
export declare const exceptionColor = "#FF4D4F";
|