@douyinfe/semi-foundation 2.72.2 → 2.73.0-beta.0
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/audioPlayer/audioPlayer.scss +217 -0
- package/audioPlayer/constants.ts +7 -0
- package/audioPlayer/foundation.ts +103 -0
- package/audioPlayer/variables.scss +55 -0
- package/button/iconButton.scss +8 -0
- package/cropper/constants.ts +26 -0
- package/cropper/cropper.scss +116 -0
- package/cropper/foundation.ts +821 -0
- package/cropper/utils.ts +12 -0
- package/cropper/variables.scss +6 -0
- package/dragMove/foundation.ts +12 -0
- package/jsonViewer/foundation.ts +6 -0
- package/jsonViewer/jsonViewer.scss +8 -3
- package/lib/cjs/audioPlayer/audioPlayer.css +188 -0
- package/lib/cjs/audioPlayer/audioPlayer.scss +217 -0
- package/lib/cjs/audioPlayer/constants.d.ts +4 -0
- package/lib/cjs/audioPlayer/constants.js +10 -0
- package/lib/cjs/audioPlayer/foundation.d.ts +41 -0
- package/lib/cjs/audioPlayer/foundation.js +79 -0
- package/lib/cjs/audioPlayer/variables.scss +55 -0
- package/lib/cjs/button/iconButton.css +8 -0
- package/lib/cjs/button/iconButton.scss +8 -0
- package/lib/cjs/cropper/constants.d.ts +17 -0
- package/lib/cjs/cropper/constants.js +24 -0
- package/lib/cjs/cropper/cropper.css +97 -0
- package/lib/cjs/cropper/cropper.scss +116 -0
- package/lib/cjs/cropper/foundation.d.ts +101 -0
- package/lib/cjs/cropper/foundation.js +786 -0
- package/lib/cjs/cropper/utils.d.ts +2 -0
- package/lib/cjs/cropper/utils.js +19 -0
- package/lib/cjs/cropper/variables.scss +6 -0
- package/lib/cjs/dragMove/foundation.d.ts +2 -0
- package/lib/cjs/dragMove/foundation.js +10 -0
- package/lib/cjs/jsonViewer/foundation.js +6 -0
- package/lib/cjs/jsonViewer/jsonViewer.css +8 -2
- package/lib/cjs/jsonViewer/jsonViewer.scss +8 -3
- package/lib/es/audioPlayer/audioPlayer.css +188 -0
- package/lib/es/audioPlayer/audioPlayer.scss +217 -0
- package/lib/es/audioPlayer/constants.d.ts +4 -0
- package/lib/es/audioPlayer/constants.js +5 -0
- package/lib/es/audioPlayer/foundation.d.ts +41 -0
- package/lib/es/audioPlayer/foundation.js +72 -0
- package/lib/es/audioPlayer/variables.scss +55 -0
- package/lib/es/button/iconButton.css +8 -0
- package/lib/es/button/iconButton.scss +8 -0
- package/lib/es/cropper/constants.d.ts +17 -0
- package/lib/es/cropper/constants.js +19 -0
- package/lib/es/cropper/cropper.css +97 -0
- package/lib/es/cropper/cropper.scss +116 -0
- package/lib/es/cropper/foundation.d.ts +101 -0
- package/lib/es/cropper/foundation.js +778 -0
- package/lib/es/cropper/utils.d.ts +2 -0
- package/lib/es/cropper/utils.js +12 -0
- package/lib/es/cropper/variables.scss +6 -0
- package/lib/es/dragMove/foundation.d.ts +2 -0
- package/lib/es/dragMove/foundation.js +10 -0
- package/lib/es/jsonViewer/foundation.js +6 -0
- package/lib/es/jsonViewer/jsonViewer.css +8 -2
- package/lib/es/jsonViewer/jsonViewer.scss +8 -3
- package/package.json +4 -4
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getAspectHW = getAspectHW;
|
|
7
|
+
exports.getMiddle = getMiddle;
|
|
8
|
+
function getMiddle(value, _ref) {
|
|
9
|
+
let [min, max] = _ref;
|
|
10
|
+
return Math.min(Math.max(value, min), max);
|
|
11
|
+
}
|
|
12
|
+
function getAspectHW(width, height, aspect) {
|
|
13
|
+
if (width / height > aspect) {
|
|
14
|
+
width = height * aspect;
|
|
15
|
+
} else {
|
|
16
|
+
height = width / aspect;
|
|
17
|
+
}
|
|
18
|
+
return [width, height];
|
|
19
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
$color-cropper_mask-bg: var(--semi-color-overlay-bg); // 裁切框遮罩背景颜色
|
|
2
|
+
$color-cropper_box-outline: var(--semi-color-primary); // 裁切框边框颜色
|
|
3
|
+
$color-cropper_box_corner-bg: var(--semi-color-primary); // 裁切框调整块背景色
|
|
4
|
+
|
|
5
|
+
$width-cropper_box-outline: 1px; // 裁切框边框宽度
|
|
6
|
+
$width-cropper_box_corner: 10px; // 裁切框调整块宽高
|
|
@@ -24,6 +24,8 @@ export default class DragMoveFoundation<P = Record<string, any>, S = Record<stri
|
|
|
24
24
|
get handler(): HTMLElement;
|
|
25
25
|
constructor(adapter: DragMoveAdapter<P, S>);
|
|
26
26
|
init(): void;
|
|
27
|
+
_registerStartEvent: () => void;
|
|
28
|
+
_unRegisterStartEvent: () => void;
|
|
27
29
|
destroy(): void;
|
|
28
30
|
_registerDocMouseEvent: () => void;
|
|
29
31
|
_unRegisterDocMouseEvent: () => void;
|
|
@@ -19,6 +19,14 @@ class DragMoveFoundation extends _foundation.default {
|
|
|
19
19
|
}
|
|
20
20
|
constructor(adapter) {
|
|
21
21
|
super(Object.assign({}, adapter));
|
|
22
|
+
this._registerStartEvent = () => {
|
|
23
|
+
this.handler.addEventListener('mousedown', this.onMouseDown);
|
|
24
|
+
this.handler.addEventListener('touchstart', this.onTouchStart);
|
|
25
|
+
};
|
|
26
|
+
this._unRegisterStartEvent = () => {
|
|
27
|
+
this.handler.removeEventListener('mousedown', this.onMouseDown);
|
|
28
|
+
this.handler.removeEventListener('touchstart', this.onTouchStart);
|
|
29
|
+
};
|
|
22
30
|
this._registerDocMouseEvent = () => {
|
|
23
31
|
document.addEventListener('mousemove', this._onMouseMove);
|
|
24
32
|
document.addEventListener('mouseup', this._onMouseUp);
|
|
@@ -116,8 +124,10 @@ class DragMoveFoundation extends _foundation.default {
|
|
|
116
124
|
this.element = element;
|
|
117
125
|
this.element.style.position = 'absolute';
|
|
118
126
|
this.handler.style.cursor = 'move';
|
|
127
|
+
this._registerStartEvent();
|
|
119
128
|
}
|
|
120
129
|
destroy() {
|
|
130
|
+
this._unRegisterStartEvent();
|
|
121
131
|
this._unRegisterEvent();
|
|
122
132
|
}
|
|
123
133
|
_unRegisterEvent() {
|
|
@@ -53,10 +53,16 @@ class JsonViewerFoundation extends _foundation.default {
|
|
|
53
53
|
}
|
|
54
54
|
replace(replaceText) {
|
|
55
55
|
var _a;
|
|
56
|
+
if (this.getProps().options.readOnly) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
56
59
|
(_a = this.jsonViewer) === null || _a === void 0 ? void 0 : _a.getSearchWidget().replace(replaceText);
|
|
57
60
|
}
|
|
58
61
|
replaceAll(replaceText) {
|
|
59
62
|
var _a;
|
|
63
|
+
if (this.getProps().options.readOnly) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
60
66
|
(_a = this.jsonViewer) === null || _a === void 0 ? void 0 : _a.getSearchWidget().replaceAll(replaceText);
|
|
61
67
|
}
|
|
62
68
|
setSearchOptions(key) {
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
font-variation-settings: normal;
|
|
57
57
|
letter-spacing: 0px;
|
|
58
58
|
color: #237893;
|
|
59
|
-
word-
|
|
60
|
-
white-space: pre-wrap;
|
|
59
|
+
word-break: break-all !important;
|
|
60
|
+
white-space: pre-wrap !important;
|
|
61
61
|
}
|
|
62
62
|
.semi-json-viewer-line-number {
|
|
63
63
|
font-family: Menlo, Firecode, Monaco, "Courier New", monospace;
|
|
@@ -69,6 +69,7 @@
|
|
|
69
69
|
color: rgba(var(--semi-grey-5), 1);
|
|
70
70
|
text-align: center;
|
|
71
71
|
width: 50px;
|
|
72
|
+
user-select: none;
|
|
72
73
|
}
|
|
73
74
|
.semi-json-viewer-content-container {
|
|
74
75
|
scrollbar-width: none; /* 隐藏滚动条(Firefox) */
|
|
@@ -165,4 +166,9 @@
|
|
|
165
166
|
padding: 8px 16px;
|
|
166
167
|
color: var(--semi-color-text-0);
|
|
167
168
|
cursor: pointer;
|
|
169
|
+
}
|
|
170
|
+
.semi-json-viewer-error {
|
|
171
|
+
text-decoration: underline wavy var(--semi-color-danger);
|
|
172
|
+
text-decoration-thickness: 1px;
|
|
173
|
+
text-underline-position: under;
|
|
168
174
|
}
|
|
@@ -68,8 +68,8 @@ $module: #{$prefix}-json-viewer;
|
|
|
68
68
|
font-variation-settings: normal;
|
|
69
69
|
letter-spacing: 0px;
|
|
70
70
|
color: #237893;
|
|
71
|
-
word-
|
|
72
|
-
white-space: pre-wrap;
|
|
71
|
+
word-break: break-all !important;
|
|
72
|
+
white-space: pre-wrap !important;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
&-line-number {
|
|
@@ -82,6 +82,7 @@ $module: #{$prefix}-json-viewer;
|
|
|
82
82
|
color: $color-json-viewer-line-number;
|
|
83
83
|
text-align: center;
|
|
84
84
|
width: 50px;
|
|
85
|
+
user-select: none;
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
&-content-container {
|
|
@@ -196,5 +197,9 @@ $module: #{$prefix}-json-viewer;
|
|
|
196
197
|
cursor: pointer;
|
|
197
198
|
}
|
|
198
199
|
|
|
199
|
-
|
|
200
|
+
&-error {
|
|
201
|
+
text-decoration: underline wavy var(--semi-color-danger);
|
|
202
|
+
text-decoration-thickness: 1px;
|
|
203
|
+
text-underline-position: under;
|
|
204
|
+
}
|
|
200
205
|
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/* shadow */
|
|
2
|
+
/* sizing */
|
|
3
|
+
/* spacing */
|
|
4
|
+
.semi-audio-player {
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
gap: 24px;
|
|
9
|
+
max-width: 1440px;
|
|
10
|
+
height: 78px;
|
|
11
|
+
background: rgba(var(--semi-grey-9), 0.8);
|
|
12
|
+
}
|
|
13
|
+
.semi-audio-player-control {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
gap: 16px;
|
|
17
|
+
}
|
|
18
|
+
.semi-audio-player-control-button-icon {
|
|
19
|
+
color: var(--semi-color-bg-0);
|
|
20
|
+
}
|
|
21
|
+
.semi-audio-player-control-button-play {
|
|
22
|
+
background: var(--semi-color-bg-0) !important;
|
|
23
|
+
color: var(--semi-color-text-0) !important;
|
|
24
|
+
}
|
|
25
|
+
.semi-audio-player-control-button-play-disabled {
|
|
26
|
+
background: rgba(var(--semi-grey-0), 0.35) !important;
|
|
27
|
+
color: var(--semi-color-grey-7) !important;
|
|
28
|
+
}
|
|
29
|
+
.semi-audio-player-slider-container {
|
|
30
|
+
width: 323px;
|
|
31
|
+
height: 100%;
|
|
32
|
+
}
|
|
33
|
+
.semi-audio-player-info-container {
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
gap: 16px;
|
|
37
|
+
}
|
|
38
|
+
.semi-audio-player-info {
|
|
39
|
+
display: flex;
|
|
40
|
+
flex-direction: column;
|
|
41
|
+
gap: 4px;
|
|
42
|
+
}
|
|
43
|
+
.semi-audio-player-info-title {
|
|
44
|
+
font-size: 14px;
|
|
45
|
+
color: var(--semi-color-bg-0);
|
|
46
|
+
font-weight: 600;
|
|
47
|
+
display: flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
}
|
|
50
|
+
.semi-audio-player-info-time {
|
|
51
|
+
width: 100%;
|
|
52
|
+
height: 22px;
|
|
53
|
+
font-size: 14px;
|
|
54
|
+
color: var(--semi-color-bg-0);
|
|
55
|
+
display: flex;
|
|
56
|
+
align-items: center;
|
|
57
|
+
justify-content: space-between;
|
|
58
|
+
gap: 4px;
|
|
59
|
+
user-select: none;
|
|
60
|
+
}
|
|
61
|
+
.semi-audio-player-control-speed {
|
|
62
|
+
width: 40px;
|
|
63
|
+
height: 24px;
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
justify-content: center;
|
|
67
|
+
gap: 4px;
|
|
68
|
+
background: rgba(var(--semi-grey-8), 1);
|
|
69
|
+
border-radius: 3px;
|
|
70
|
+
font-size: 12px;
|
|
71
|
+
line-height: 16px;
|
|
72
|
+
color: var(--semi-color-default);
|
|
73
|
+
font-weight: 600;
|
|
74
|
+
user-select: none;
|
|
75
|
+
}
|
|
76
|
+
.semi-audio-player-control-speed-menu {
|
|
77
|
+
background: rgba(var(--semi-grey-8), 1);
|
|
78
|
+
width: 65px;
|
|
79
|
+
}
|
|
80
|
+
.semi-audio-player-control-speed-menu-item {
|
|
81
|
+
color: var(--semi-color-default);
|
|
82
|
+
}
|
|
83
|
+
.semi-audio-player-control-speed-menu-item:hover {
|
|
84
|
+
background: var(--semi-color-tertiary-active) !important;
|
|
85
|
+
}
|
|
86
|
+
.semi-audio-player-control-volume {
|
|
87
|
+
width: 43px;
|
|
88
|
+
height: 164px;
|
|
89
|
+
background: rgba(var(--semi-grey-8), 1);
|
|
90
|
+
border-radius: 4px;
|
|
91
|
+
padding: 4px 0;
|
|
92
|
+
display: flex;
|
|
93
|
+
align-items: center;
|
|
94
|
+
justify-content: center;
|
|
95
|
+
flex-direction: column;
|
|
96
|
+
gap: 8px;
|
|
97
|
+
}
|
|
98
|
+
.semi-audio-player-control-volume-title {
|
|
99
|
+
font-size: 12px;
|
|
100
|
+
line-height: 16px;
|
|
101
|
+
color: var(--semi-color-default);
|
|
102
|
+
font-weight: 600;
|
|
103
|
+
user-select: none;
|
|
104
|
+
}
|
|
105
|
+
.semi-audio-player-error {
|
|
106
|
+
display: flex;
|
|
107
|
+
align-items: center;
|
|
108
|
+
gap: 4px;
|
|
109
|
+
margin-left: 4px;
|
|
110
|
+
color: var(--semi-color-danger);
|
|
111
|
+
}
|
|
112
|
+
.semi-audio-player-light {
|
|
113
|
+
background: var(--semi-color-bg-0);
|
|
114
|
+
border: 1px solid var(--semi-color-border);
|
|
115
|
+
}
|
|
116
|
+
.semi-audio-player-light .semi-audio-player-control-button-icon {
|
|
117
|
+
color: rgba(var(--semi-grey-9), 1);
|
|
118
|
+
}
|
|
119
|
+
.semi-audio-player-light .semi-audio-player-control-button-play {
|
|
120
|
+
background: rgba(var(--semi-grey-9), 1) !important;
|
|
121
|
+
color: var(--semi-color-bg-0) !important;
|
|
122
|
+
}
|
|
123
|
+
.semi-audio-player-light .semi-audio-player-control-button-play-disabled {
|
|
124
|
+
background: var(--semi-color-disabled-text) !important;
|
|
125
|
+
color: rgba(var(--semi-white), 1) !important;
|
|
126
|
+
}
|
|
127
|
+
.semi-audio-player-light .semi-audio-player-info-title,
|
|
128
|
+
.semi-audio-player-light .semi-audio-player-info-time {
|
|
129
|
+
color: rgba(var(--semi-grey-9), 1);
|
|
130
|
+
}
|
|
131
|
+
.semi-audio-player-light .semi-audio-player-control-speed-menu-item,
|
|
132
|
+
.semi-audio-player-light .semi-audio-player-control-volume-title {
|
|
133
|
+
color: rgba(var(--semi-grey-9), 1);
|
|
134
|
+
}
|
|
135
|
+
.semi-audio-player-light .semi-audio-player-control-speed-menu-item:hover {
|
|
136
|
+
background: rgba(var(--semi-grey-1), 1) !important;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.semi-audio-player-slider {
|
|
140
|
+
background: rgba(var(--semi-grey-5), 1);
|
|
141
|
+
border-radius: 9999px;
|
|
142
|
+
position: relative;
|
|
143
|
+
}
|
|
144
|
+
.semi-audio-player-slider-light {
|
|
145
|
+
background: rgba(var(--semi-grey-2), 1);
|
|
146
|
+
}
|
|
147
|
+
.semi-audio-player-slider-wrapper {
|
|
148
|
+
position: relative;
|
|
149
|
+
cursor: pointer;
|
|
150
|
+
display: flex;
|
|
151
|
+
align-items: center;
|
|
152
|
+
justify-content: center;
|
|
153
|
+
}
|
|
154
|
+
.semi-audio-player-slider-wrapper-vertical {
|
|
155
|
+
width: 100%;
|
|
156
|
+
}
|
|
157
|
+
.semi-audio-player-slider-wrapper-horizontal {
|
|
158
|
+
height: 100%;
|
|
159
|
+
}
|
|
160
|
+
.semi-audio-player-slider-vertical {
|
|
161
|
+
width: 4px;
|
|
162
|
+
height: 100%;
|
|
163
|
+
}
|
|
164
|
+
.semi-audio-player-slider-horizontal {
|
|
165
|
+
width: 100%;
|
|
166
|
+
height: 4px;
|
|
167
|
+
}
|
|
168
|
+
.semi-audio-player-slider-progress {
|
|
169
|
+
position: absolute;
|
|
170
|
+
background: rgba(var(--semi-blue-4), 1);
|
|
171
|
+
border-radius: 9999px;
|
|
172
|
+
}
|
|
173
|
+
.semi-audio-player-slider-progress-vertical {
|
|
174
|
+
bottom: 0;
|
|
175
|
+
}
|
|
176
|
+
.semi-audio-player-slider-progress-horizontal {
|
|
177
|
+
left: 0;
|
|
178
|
+
}
|
|
179
|
+
.semi-audio-player-slider-dot {
|
|
180
|
+
position: absolute;
|
|
181
|
+
width: 16px;
|
|
182
|
+
height: 16px;
|
|
183
|
+
background: rgba(var(--semi-white), 1);
|
|
184
|
+
border: 1px solid var(--semi-color-primary);
|
|
185
|
+
box-shadow: 0px 0px 4px 0px var(--semi-color-shadow);
|
|
186
|
+
border-radius: 50%;
|
|
187
|
+
transition: opacity 0.2s;
|
|
188
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
@import './variables.scss';
|
|
2
|
+
|
|
3
|
+
$module: #{$prefix}-audio-player;
|
|
4
|
+
|
|
5
|
+
.#{$module} {
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
justify-content: center;
|
|
9
|
+
gap: $gap-audio-player-large;
|
|
10
|
+
max-width: $width-audio-player-max;
|
|
11
|
+
height: $height-audio-player;
|
|
12
|
+
background: $color-audio-player-background;
|
|
13
|
+
&-control {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
gap: $gap-audio-player-medium;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&-control-button-icon {
|
|
20
|
+
color: $color-audio-player-control-icon;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&-control-button-play {
|
|
24
|
+
background: $color-audio-player-control-icon !important;
|
|
25
|
+
color: $color-audio-player-control-icon-play !important;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&-control-button-play-disabled {
|
|
29
|
+
background: $color-audio-player-disabled-bg !important;
|
|
30
|
+
color: $color-audio-player-disabled-text !important;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&-slider-container {
|
|
34
|
+
width: $width-audio-player-slider;
|
|
35
|
+
height: 100%;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&-info-container {
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
gap: $gap-audio-player-medium;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&-info {
|
|
45
|
+
display: flex;
|
|
46
|
+
flex-direction: column;
|
|
47
|
+
gap: $gap-audio-player-small;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&-info-title {
|
|
51
|
+
font-size: $font-size-audio-player-text;
|
|
52
|
+
color: $color-audio-player-font-color;
|
|
53
|
+
font-weight: 600;
|
|
54
|
+
display: flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
}
|
|
57
|
+
&-info-time {
|
|
58
|
+
width: 100%;
|
|
59
|
+
height: $height-audio-player-time;
|
|
60
|
+
font-size: $font-size-audio-player-text;
|
|
61
|
+
color: $color-audio-player-font-color;
|
|
62
|
+
display: flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
justify-content: space-between;
|
|
65
|
+
gap: $gap-audio-player-small;
|
|
66
|
+
user-select: none;
|
|
67
|
+
}
|
|
68
|
+
&-control-speed {
|
|
69
|
+
width: $width-audio-player-speed;
|
|
70
|
+
height: $height-audio-player-speed;
|
|
71
|
+
display: flex;
|
|
72
|
+
align-items: center;
|
|
73
|
+
justify-content: center;
|
|
74
|
+
gap: $gap-audio-player-small;
|
|
75
|
+
background: $color-audio-player-font-color-speed;
|
|
76
|
+
border-radius: $border-radius-audio-player-speed;
|
|
77
|
+
font-size: $font-size-audio-player-small;
|
|
78
|
+
line-height: $line-height-audio-player-small;
|
|
79
|
+
color: var(--semi-color-default);
|
|
80
|
+
font-weight: 600;
|
|
81
|
+
user-select: none;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&-control-speed-menu {
|
|
85
|
+
background: $color-audio-player-font-color-speed;
|
|
86
|
+
width: $width-audio-player-speed-menu;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&-control-speed-menu-item {
|
|
90
|
+
color: $color-audio-player-text-default;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
&-control-speed-menu-item:hover {
|
|
94
|
+
background: var(--semi-color-tertiary-active) !important;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
&-control-volume {
|
|
98
|
+
width: $width-audio-player-volume;
|
|
99
|
+
height: $height-audio-player-volume;
|
|
100
|
+
background: $color-audio-player-font-color-speed;
|
|
101
|
+
border-radius: $border-radius-audio-player-volume;
|
|
102
|
+
padding: 4px 0;
|
|
103
|
+
display: flex;
|
|
104
|
+
align-items: center;
|
|
105
|
+
justify-content: center;
|
|
106
|
+
flex-direction: column;
|
|
107
|
+
gap: $gap-audio-player-small * 2;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
&-control-volume-title {
|
|
111
|
+
font-size: $font-size-audio-player-small;
|
|
112
|
+
line-height: $line-height-audio-player-small;
|
|
113
|
+
color: $color-audio-player-text-default;
|
|
114
|
+
font-weight: 600;
|
|
115
|
+
user-select: none;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
&-error {
|
|
119
|
+
display: flex;
|
|
120
|
+
align-items: center;
|
|
121
|
+
gap: $gap-audio-player-small;
|
|
122
|
+
margin-left: 4px;
|
|
123
|
+
color: var(--semi-color-danger);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
&-light {
|
|
127
|
+
background: $color-audio-player-background-light;
|
|
128
|
+
border: 1px solid var(--semi-color-border);
|
|
129
|
+
|
|
130
|
+
.#{$module}-control-button-icon {
|
|
131
|
+
color: $color-audio-player-control-icon-light;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.#{$module}-control-button-play {
|
|
135
|
+
background: $color-audio-player-control-icon-light !important;
|
|
136
|
+
color: $color-audio-player-control-icon-play-light !important;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.#{$module}-control-button-play-disabled {
|
|
140
|
+
background: $color-audio-player-light-disabled-bg !important;
|
|
141
|
+
color: $color-audio-player-light-disabled-text !important;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.#{$module}-info-title,
|
|
145
|
+
.#{$module}-info-time {
|
|
146
|
+
color: $color-audio-player-font-color-light;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.#{$module}-control-speed-menu-item,
|
|
150
|
+
.#{$module}-control-volume-title {
|
|
151
|
+
color: $color-audio-player-light-text;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.#{$module}-control-speed-menu-item:hover {
|
|
155
|
+
background: $color-audio-player-light-hover-bg !important;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.#{$module}-slider {
|
|
161
|
+
background: $color-audio-player-slider-bg;
|
|
162
|
+
border-radius: $border-radius-audio-player-slider;
|
|
163
|
+
position: relative;
|
|
164
|
+
|
|
165
|
+
&-light {
|
|
166
|
+
background: $color-audio-player-slider-bg-light;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
&-wrapper {
|
|
170
|
+
position: relative;
|
|
171
|
+
cursor: pointer;
|
|
172
|
+
display: flex;
|
|
173
|
+
align-items: center;
|
|
174
|
+
justify-content: center;
|
|
175
|
+
&-vertical {
|
|
176
|
+
width: 100%;
|
|
177
|
+
}
|
|
178
|
+
&-horizontal {
|
|
179
|
+
height: 100%;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
&-vertical {
|
|
184
|
+
width: $width-audio-player-slider-bar;
|
|
185
|
+
height: 100%;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
&-horizontal {
|
|
189
|
+
width: 100%;
|
|
190
|
+
height: $width-audio-player-slider-bar;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
&-progress {
|
|
194
|
+
position: absolute;
|
|
195
|
+
background: $color-audio-player-slider-progress;
|
|
196
|
+
border-radius: $border-radius-audio-player-slider;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
&-progress-vertical {
|
|
200
|
+
bottom: 0;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
&-progress-horizontal {
|
|
204
|
+
left: 0;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
&-dot {
|
|
208
|
+
position: absolute;
|
|
209
|
+
width: $size-audio-player-slider-dot;
|
|
210
|
+
height: $size-audio-player-slider-dot;
|
|
211
|
+
background: $color-audio-player-slider-dot-bg;
|
|
212
|
+
border: 1px solid var(--semi-color-primary);
|
|
213
|
+
box-shadow: 0px 0px 4px 0px var(--semi-color-shadow);
|
|
214
|
+
border-radius: 50%;
|
|
215
|
+
transition: opacity 0.2s;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
3
|
+
export interface AudioPlayerAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
4
|
+
init: () => void;
|
|
5
|
+
resetAudioState: () => void;
|
|
6
|
+
handleStatusClick: () => void;
|
|
7
|
+
handleTimeUpdate: () => void;
|
|
8
|
+
handleTrackChange: (direction: 'next' | 'prev') => void;
|
|
9
|
+
getAudioRef: () => React.RefObject<HTMLAudioElement>;
|
|
10
|
+
handleTimeChange: (value: number) => void;
|
|
11
|
+
handleSpeedChange: (value: {
|
|
12
|
+
label: string;
|
|
13
|
+
value: number;
|
|
14
|
+
}) => void;
|
|
15
|
+
handleSeek: (direction: number) => void;
|
|
16
|
+
handleRefresh: () => void;
|
|
17
|
+
handleVolumeChange: (value: number) => void;
|
|
18
|
+
destroy: () => void;
|
|
19
|
+
}
|
|
20
|
+
declare class AudioPlayerFoundation extends BaseFoundation<AudioPlayerAdapter> {
|
|
21
|
+
constructor(adapter: AudioPlayerAdapter);
|
|
22
|
+
initAudioState(): void;
|
|
23
|
+
endHandler(): void;
|
|
24
|
+
errorHandler(): void;
|
|
25
|
+
init(): void;
|
|
26
|
+
destroy(): void;
|
|
27
|
+
resetAudioState(): void;
|
|
28
|
+
handleStatusClick(): void;
|
|
29
|
+
handleTimeUpdate(): void;
|
|
30
|
+
handleTrackChange(direction: 'next' | 'prev'): void;
|
|
31
|
+
getAudioRef(): import("react").RefObject<HTMLAudioElement>;
|
|
32
|
+
handleTimeChange(value: number): void;
|
|
33
|
+
handleSpeedChange(value: {
|
|
34
|
+
label: string;
|
|
35
|
+
value: number;
|
|
36
|
+
}): void;
|
|
37
|
+
handleSeek(direction: number): void;
|
|
38
|
+
handleRefresh(): void;
|
|
39
|
+
handleVolumeChange(value: number): void;
|
|
40
|
+
}
|
|
41
|
+
export default AudioPlayerFoundation;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import BaseFoundation from '../base/foundation';
|
|
2
|
+
class AudioPlayerFoundation extends BaseFoundation {
|
|
3
|
+
constructor(adapter) {
|
|
4
|
+
super(Object.assign(Object.assign({}, AudioPlayerFoundation), adapter));
|
|
5
|
+
}
|
|
6
|
+
initAudioState() {
|
|
7
|
+
var _a, _b, _c;
|
|
8
|
+
const audioRef = this.getAudioRef();
|
|
9
|
+
const props = this.getProps();
|
|
10
|
+
this.setState({
|
|
11
|
+
totalTime: ((_a = audioRef.current) === null || _a === void 0 ? void 0 : _a.duration) || 0,
|
|
12
|
+
isPlaying: props.autoPlay,
|
|
13
|
+
volume: ((_b = audioRef.current) === null || _b === void 0 ? void 0 : _b.volume) * 100 || 100,
|
|
14
|
+
currentRate: {
|
|
15
|
+
label: '1.0x',
|
|
16
|
+
value: ((_c = audioRef.current) === null || _c === void 0 ? void 0 : _c.playbackRate) || 1
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
endHandler() {
|
|
21
|
+
const props = this.getProps();
|
|
22
|
+
if (Array.isArray(props.audioUrl)) {
|
|
23
|
+
this.handleTrackChange('next');
|
|
24
|
+
} else {
|
|
25
|
+
this.setState({
|
|
26
|
+
isPlaying: false
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
errorHandler() {
|
|
31
|
+
this.setState({
|
|
32
|
+
error: true
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
init() {
|
|
36
|
+
this._adapter.init();
|
|
37
|
+
}
|
|
38
|
+
destroy() {
|
|
39
|
+
this._adapter.destroy();
|
|
40
|
+
}
|
|
41
|
+
resetAudioState() {
|
|
42
|
+
this._adapter.resetAudioState();
|
|
43
|
+
}
|
|
44
|
+
handleStatusClick() {
|
|
45
|
+
this._adapter.handleStatusClick();
|
|
46
|
+
}
|
|
47
|
+
handleTimeUpdate() {
|
|
48
|
+
this._adapter.handleTimeUpdate();
|
|
49
|
+
}
|
|
50
|
+
handleTrackChange(direction) {
|
|
51
|
+
this._adapter.handleTrackChange(direction);
|
|
52
|
+
}
|
|
53
|
+
getAudioRef() {
|
|
54
|
+
return this._adapter.getAudioRef();
|
|
55
|
+
}
|
|
56
|
+
handleTimeChange(value) {
|
|
57
|
+
this._adapter.handleTimeChange(value);
|
|
58
|
+
}
|
|
59
|
+
handleSpeedChange(value) {
|
|
60
|
+
this._adapter.handleSpeedChange(value);
|
|
61
|
+
}
|
|
62
|
+
handleSeek(direction) {
|
|
63
|
+
this._adapter.handleSeek(direction);
|
|
64
|
+
}
|
|
65
|
+
handleRefresh() {
|
|
66
|
+
this._adapter.handleRefresh();
|
|
67
|
+
}
|
|
68
|
+
handleVolumeChange(value) {
|
|
69
|
+
this._adapter.handleVolumeChange(value);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export default AudioPlayerFoundation;
|