@trionesdev/antd-mobile-base-react 0.0.2-beta.6 → 0.0.2-beta.7

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.
@@ -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,3 @@
1
+ import { Progress, ProgressProps } from "./Progress";
2
+ export type { ProgressProps };
3
+ export default Progress;
@@ -0,0 +1,2 @@
1
+ import { Progress } from "./Progress";
2
+ export default Progress;
@@ -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";
@@ -0,0 +1,2 @@
1
+ export var successColor = "#53C31B";
2
+ export var exceptionColor = "#FF4D4F";
package/dist/index.d.ts CHANGED
@@ -51,6 +51,8 @@ export { default as PickerView } from './PickerView';
51
51
  export type { PickerViewProps, PickerColumnOption } from './PickerView';
52
52
  export { default as Popup, PopupModal } from './Popup';
53
53
  export type { PopupProps } from './Popup';
54
+ export { default as Progress } from './Progress';
55
+ export type { ProgressProps } from './Progress';
54
56
  export { default as Radio } from './Radio';
55
57
  export type { RadioGroupProps, RadioProps } from './Radio';
56
58
  export { default as Rate } from './Rate';
package/dist/index.js CHANGED
@@ -25,6 +25,7 @@ export { default as PageIndicator } from "./PageIndicator";
25
25
  export { default as Picker } from "./Picker";
26
26
  export { default as PickerView } from "./PickerView";
27
27
  export { default as Popup, PopupModal } from "./Popup";
28
+ export { default as Progress } from "./Progress";
28
29
  export { default as Radio } from "./Radio";
29
30
  export { default as Rate } from "./Rate";
30
31
  export { default as Result } from "./Result";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trionesdev/antd-mobile-base-react",
3
- "version": "0.0.2-beta.6",
3
+ "version": "0.0.2-beta.7",
4
4
  "description": "antd mobile base react",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -48,7 +48,7 @@
48
48
  "runes2": "^1.1.4"
49
49
  },
50
50
  "optionalDependencies": {
51
- "@trionesdev/antd-mobile-icons-react": "0.0.2-beta.6"
51
+ "@trionesdev/antd-mobile-icons-react": "0.0.2-beta.7"
52
52
  },
53
- "gitHead": "67e8a0eb804b24ce8aeeb8c2c7aac8046da5be5d"
53
+ "gitHead": "dda211e5c6e5ddc80ba9045b0cdec0b4b5297e4e"
54
54
  }