@trionesdev/antd-mobile-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.
@@ -1,3 +1,3 @@
1
- import { Progress, ProgressProps } from "./Progress";
1
+ import { Progress, ProgressProps } from "@trionesdev/antd-mobile-base-react";
2
2
  export type { ProgressProps };
3
3
  export default Progress;
@@ -1,2 +1,2 @@
1
- import { Progress } from "./Progress";
1
+ import { Progress } from "@trionesdev/antd-mobile-base-react";
2
2
  export default Progress;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trionesdev/antd-mobile-react",
3
- "version": "0.0.2-beta.6",
3
+ "version": "0.0.2-beta.7",
4
4
  "description": "antd mobile react ",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -89,7 +89,7 @@
89
89
  "stylelint": "^16.12.0"
90
90
  },
91
91
  "dependencies": {
92
- "@trionesdev/antd-mobile-base-react": "^0.0.2-beta.6",
92
+ "@trionesdev/antd-mobile-base-react": "^0.0.2-beta.7",
93
93
  "ahooks": "^3.8.4",
94
94
  "crypto-js": "^4.2.0",
95
95
  "rc-field-form": "^2.7.0",
@@ -98,7 +98,7 @@
98
98
  },
99
99
  "optionalDependencies": {
100
100
  "@trionesdev/antd-mobile-base-react": "workspace:*",
101
- "@trionesdev/antd-mobile-icons-react": "0.0.2-beta.6"
101
+ "@trionesdev/antd-mobile-icons-react": "0.0.2-beta.7"
102
102
  },
103
- "gitHead": "67e8a0eb804b24ce8aeeb8c2c7aac8046da5be5d"
103
+ "gitHead": "dda211e5c6e5ddc80ba9045b0cdec0b4b5297e4e"
104
104
  }
@@ -1,37 +0,0 @@
1
- import { FC } from "react";
2
- import "./style.scss";
3
- import { PercentPositionAlign, ProgressStatus } from "./types";
4
- import { SizeType } from "@trionesdev/antd-mobile-base-react";
5
- export type ProgressProps = {
6
- /**
7
- * @description 内容的模板函数
8
- * @default percent => `${percent}%`
9
- */
10
- format?: (percent: number) => string;
11
- type?: 'line' | 'circle';
12
- /**
13
- * @description 百分比
14
- * @default 0
15
- */
16
- percent?: number;
17
- size?: SizeType | number;
18
- /**
19
- * @description 是否显示进度数值或状态图标
20
- * @default true
21
- */
22
- showInfo?: boolean;
23
- /**
24
- * @description 未完成的分段的颜色
25
- */
26
- railColor?: string;
27
- /**
28
- * @description 进度条的色彩
29
- */
30
- strokeColor?: string;
31
- status?: ProgressStatus;
32
- /**
33
- * @description 进度数值位置
34
- */
35
- percentPositionAlign?: PercentPositionAlign;
36
- };
37
- export declare const Progress: FC<ProgressProps>;
@@ -1,52 +0,0 @@
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
- export var Progress = function Progress(_ref) {
7
- var format = _ref.format,
8
- _ref$type = _ref.type,
9
- type = _ref$type === void 0 ? 'line' : _ref$type,
10
- _ref$percent = _ref.percent,
11
- percent = _ref$percent === void 0 ? 0 : _ref$percent,
12
- _ref$size = _ref.size,
13
- size = _ref$size === void 0 ? 'middle' : _ref$size,
14
- _ref$showInfo = _ref.showInfo,
15
- showInfo = _ref$showInfo === void 0 ? true : _ref$showInfo,
16
- _ref$railColor = _ref.railColor,
17
- railColor = _ref$railColor === void 0 ? '#E5E5E5' : _ref$railColor,
18
- _ref$strokeColor = _ref.strokeColor,
19
- strokeColor = _ref$strokeColor === void 0 ? '#1777FF' : _ref$strokeColor,
20
- status = _ref.status,
21
- percentPositionAlign = _ref.percentPositionAlign;
22
- var handleComputedStrokeColor = function handleComputedStrokeColor() {
23
- if (status === 'exception') {
24
- return exceptionColor;
25
- }
26
- if (percent >= 100) {
27
- return successColor;
28
- }
29
- return strokeColor;
30
- };
31
- if (type === 'line') {
32
- return /*#__PURE__*/React.createElement(ProgressLine, {
33
- format: format,
34
- percent: percent,
35
- size: size,
36
- railColor: railColor,
37
- strokeColor: handleComputedStrokeColor(),
38
- status: status,
39
- showInfo: showInfo,
40
- percentPositionAlign: percentPositionAlign
41
- });
42
- }
43
- return /*#__PURE__*/React.createElement(ProgressCircle, {
44
- format: format,
45
- percent: percent,
46
- size: size,
47
- railColor: railColor,
48
- strokeColor: handleComputedStrokeColor(),
49
- showInfo: showInfo,
50
- status: status
51
- });
52
- };
@@ -1,17 +0,0 @@
1
- import { FC } from "react";
2
- import { SizeType } from "@trionesdev/antd-mobile-base-react";
3
- import './style.scss';
4
- import { ProgressStatus } from "./types";
5
- type ProcessCircleProps = {
6
- format?: (percent: number) => string;
7
- percent?: number;
8
- strokeWidth?: number;
9
- size?: SizeType | number;
10
- showInfo?: boolean;
11
- railColor?: string;
12
- strokeColor?: string;
13
- strokeLineCap?: 'butt' | 'round' | 'square';
14
- status?: ProgressStatus;
15
- };
16
- export declare const ProgressCircle: FC<ProcessCircleProps>;
17
- export {};
@@ -1,148 +0,0 @@
1
- import React, { memo, useEffect, useMemo, useRef } from "react";
2
- import classNames from "classnames";
3
- import "./style.scss";
4
- import { CheckOutline, CloseOutline } from "@trionesdev/antd-mobile-icons-react";
5
- import { exceptionColor, successColor } from "./types";
6
- export var ProgressCircle = /*#__PURE__*/memo(function (_ref) {
7
- var format = _ref.format,
8
- _ref$percent = _ref.percent,
9
- percent = _ref$percent === void 0 ? 0 : _ref$percent,
10
- _ref$strokeWidth = _ref.strokeWidth,
11
- strokeWidth = _ref$strokeWidth === void 0 ? 6 : _ref$strokeWidth,
12
- _ref$size = _ref.size,
13
- size = _ref$size === void 0 ? 'middle' : _ref$size,
14
- _ref$showInfo = _ref.showInfo,
15
- showInfo = _ref$showInfo === void 0 ? true : _ref$showInfo,
16
- _ref$railColor = _ref.railColor,
17
- railColor = _ref$railColor === void 0 ? '#E5E5E5' : _ref$railColor,
18
- _ref$strokeColor = _ref.strokeColor,
19
- strokeColor = _ref$strokeColor === void 0 ? '#1777FF' : _ref$strokeColor,
20
- _ref$strokeLineCap = _ref.strokeLineCap,
21
- strokeLineCap = _ref$strokeLineCap === void 0 ? 'round' : _ref$strokeLineCap,
22
- status = _ref.status;
23
- var clsPrefix = 'triones-antm-progress-circle';
24
- var canvasRef = useRef();
25
- var computedWidth = useMemo(function () {
26
- switch (size) {
27
- case 'small':
28
- return 50;
29
- case 'middle':
30
- return 100;
31
- case 'large':
32
- return 150;
33
- default:
34
- return size || 50;
35
- }
36
- }, [size]);
37
- var computedHeight = useMemo(function () {
38
- switch (size) {
39
- case 'small':
40
- return 50;
41
- case 'middle':
42
- return 100;
43
- case 'large':
44
- return 150;
45
- default:
46
- return 50;
47
- }
48
- }, [size]);
49
- var style = {
50
- width: computedWidth,
51
- height: computedHeight
52
- };
53
- var computedSize = function computedSize() {
54
- var iconSize = (computedWidth - strokeWidth) / 2 / 3;
55
- if (iconSize < 24) {
56
- return 24;
57
- }
58
- return iconSize;
59
- };
60
- var handleIndicator = function handleIndicator() {
61
- var iconSize = computedSize();
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: iconSize
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: iconSize
97
- }
98
- }, percent, "%");
99
- };
100
- var handleDraw = function handleDraw() {
101
- var width = computedWidth;
102
- var height = computedHeight;
103
- var centerX = width / 2;
104
- var centerY = height / 2;
105
- var radius = (Math.min(width, height) - strokeWidth) / 2;
106
- console.log(centerX, centerY, radius);
107
- var sweepAngle = (percent ? percent / 100 : 0) * 2 * Math.PI;
108
- var startAngle = -Math.PI / 2; // 从顶部开始
109
-
110
- var ctx = canvasRef.current.getContext('2d');
111
- ctx.width = width;
112
- ctx.height = height;
113
- ctx.clearRect(0, 0, computedWidth, computedHeight);
114
-
115
- //region 画背景圈
116
- ctx.beginPath();
117
- ctx.arc(centerX, centerY, radius, 0, 2 * Math.PI);
118
- ctx.strokeStyle = railColor;
119
- ctx.lineWidth = strokeWidth;
120
- ctx.stroke();
121
- //endregion
122
-
123
- //region 画进度圈
124
- ctx.beginPath();
125
- ctx.arc(centerX, centerY, radius, startAngle, startAngle + sweepAngle);
126
- ctx.strokeStyle = strokeColor;
127
- ctx.lineWidth = strokeWidth;
128
- ctx.lineCap = strokeLineCap;
129
- ctx.stroke();
130
- //endregion
131
- };
132
- useEffect(function () {
133
- console.log(canvasRef.current);
134
- if (canvasRef.current) {
135
- handleDraw();
136
- }
137
- }, [percent, canvasRef.current]);
138
- return /*#__PURE__*/React.createElement("div", {
139
- className: classNames("".concat(clsPrefix)),
140
- style: style
141
- }, /*#__PURE__*/React.createElement("canvas", {
142
- ref: canvasRef,
143
- width: computedWidth,
144
- height: computedHeight
145
- }), showInfo && computedWidth > 20 && /*#__PURE__*/React.createElement("div", {
146
- className: "".concat(clsPrefix, "-indicator")
147
- }, handleIndicator()));
148
- });
@@ -1,15 +0,0 @@
1
- import { SizeType } from "@trionesdev/antd-mobile-base-react";
2
- import { FC } from "react";
3
- import { PercentPositionAlign, ProgressStatus } from "./types";
4
- type ProgressLineProps = {
5
- format?: (percent: number) => string;
6
- percent?: number;
7
- size?: SizeType | number;
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 {};
@@ -1,87 +0,0 @@
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
- };
@@ -1,33 +0,0 @@
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
- }
@@ -1,4 +0,0 @@
1
- export type ProgressStatus = 'normal' | 'active' | 'success' | 'exception';
2
- export type PercentPositionAlign = 'start' | 'end';
3
- export declare const successColor = "#53C31B";
4
- export declare const exceptionColor = "#FF4D4F";
@@ -1,2 +0,0 @@
1
- export var successColor = "#53C31B";
2
- export var exceptionColor = "#FF4D4F";