@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.
Files changed (60) hide show
  1. package/audioPlayer/audioPlayer.scss +217 -0
  2. package/audioPlayer/constants.ts +7 -0
  3. package/audioPlayer/foundation.ts +103 -0
  4. package/audioPlayer/variables.scss +55 -0
  5. package/button/iconButton.scss +8 -0
  6. package/cropper/constants.ts +26 -0
  7. package/cropper/cropper.scss +116 -0
  8. package/cropper/foundation.ts +821 -0
  9. package/cropper/utils.ts +12 -0
  10. package/cropper/variables.scss +6 -0
  11. package/dragMove/foundation.ts +12 -0
  12. package/jsonViewer/foundation.ts +6 -0
  13. package/jsonViewer/jsonViewer.scss +8 -3
  14. package/lib/cjs/audioPlayer/audioPlayer.css +188 -0
  15. package/lib/cjs/audioPlayer/audioPlayer.scss +217 -0
  16. package/lib/cjs/audioPlayer/constants.d.ts +4 -0
  17. package/lib/cjs/audioPlayer/constants.js +10 -0
  18. package/lib/cjs/audioPlayer/foundation.d.ts +41 -0
  19. package/lib/cjs/audioPlayer/foundation.js +79 -0
  20. package/lib/cjs/audioPlayer/variables.scss +55 -0
  21. package/lib/cjs/button/iconButton.css +8 -0
  22. package/lib/cjs/button/iconButton.scss +8 -0
  23. package/lib/cjs/cropper/constants.d.ts +17 -0
  24. package/lib/cjs/cropper/constants.js +24 -0
  25. package/lib/cjs/cropper/cropper.css +97 -0
  26. package/lib/cjs/cropper/cropper.scss +116 -0
  27. package/lib/cjs/cropper/foundation.d.ts +101 -0
  28. package/lib/cjs/cropper/foundation.js +786 -0
  29. package/lib/cjs/cropper/utils.d.ts +2 -0
  30. package/lib/cjs/cropper/utils.js +19 -0
  31. package/lib/cjs/cropper/variables.scss +6 -0
  32. package/lib/cjs/dragMove/foundation.d.ts +2 -0
  33. package/lib/cjs/dragMove/foundation.js +10 -0
  34. package/lib/cjs/jsonViewer/foundation.js +6 -0
  35. package/lib/cjs/jsonViewer/jsonViewer.css +8 -2
  36. package/lib/cjs/jsonViewer/jsonViewer.scss +8 -3
  37. package/lib/es/audioPlayer/audioPlayer.css +188 -0
  38. package/lib/es/audioPlayer/audioPlayer.scss +217 -0
  39. package/lib/es/audioPlayer/constants.d.ts +4 -0
  40. package/lib/es/audioPlayer/constants.js +5 -0
  41. package/lib/es/audioPlayer/foundation.d.ts +41 -0
  42. package/lib/es/audioPlayer/foundation.js +72 -0
  43. package/lib/es/audioPlayer/variables.scss +55 -0
  44. package/lib/es/button/iconButton.css +8 -0
  45. package/lib/es/button/iconButton.scss +8 -0
  46. package/lib/es/cropper/constants.d.ts +17 -0
  47. package/lib/es/cropper/constants.js +19 -0
  48. package/lib/es/cropper/cropper.css +97 -0
  49. package/lib/es/cropper/cropper.scss +116 -0
  50. package/lib/es/cropper/foundation.d.ts +101 -0
  51. package/lib/es/cropper/foundation.js +778 -0
  52. package/lib/es/cropper/utils.d.ts +2 -0
  53. package/lib/es/cropper/utils.js +12 -0
  54. package/lib/es/cropper/variables.scss +6 -0
  55. package/lib/es/dragMove/foundation.d.ts +2 -0
  56. package/lib/es/dragMove/foundation.js +10 -0
  57. package/lib/es/jsonViewer/foundation.js +6 -0
  58. package/lib/es/jsonViewer/jsonViewer.css +8 -2
  59. package/lib/es/jsonViewer/jsonViewer.scss +8 -3
  60. package/package.json +4 -4
@@ -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,7 @@
1
+ import { BASE_CLASS_PREFIX } from '../base/constants';
2
+
3
+ const cssClasses = {
4
+ PREFIX: `${BASE_CLASS_PREFIX}-audio-player`,
5
+ };
6
+
7
+ export { cssClasses };
@@ -0,0 +1,103 @@
1
+
2
+
3
+ import BaseFoundation, { DefaultAdapter } from '../base/foundation';
4
+
5
+ export interface AudioPlayerAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
6
+ init: () => void;
7
+ resetAudioState: () => void;
8
+ handleStatusClick: () => void;
9
+ handleTimeUpdate: () => void;
10
+ handleTrackChange: (direction: 'next' | 'prev') => void;
11
+ getAudioRef: () => React.RefObject<HTMLAudioElement>;
12
+ handleTimeChange: (value: number) => void;
13
+ handleSpeedChange: (value: { label: string; value: number }) => void;
14
+ handleSeek: (direction: number) => void;
15
+ handleRefresh: () => void;
16
+ handleVolumeChange: (value: number) => void;
17
+ destroy: () => void
18
+ }
19
+
20
+ class AudioPlayerFoundation extends BaseFoundation<AudioPlayerAdapter> {
21
+ constructor(adapter: AudioPlayerAdapter) {
22
+ super({ ...AudioPlayerFoundation, ...adapter });
23
+ }
24
+
25
+ initAudioState() {
26
+ const audioRef = this.getAudioRef();
27
+ const props = this.getProps();
28
+
29
+ this.setState({
30
+ totalTime: audioRef.current?.duration || 0,
31
+ isPlaying: props.autoPlay,
32
+ volume: audioRef.current?.volume * 100 || 100,
33
+ currentRate: { label: '1.0x', value: audioRef.current?.playbackRate || 1 },
34
+ });
35
+ }
36
+
37
+ endHandler() {
38
+ const props = this.getProps();
39
+ if (Array.isArray(props.audioUrl)) {
40
+ this.handleTrackChange('next');
41
+ } else {
42
+ this.setState({
43
+ isPlaying: false,
44
+ });
45
+ }
46
+ }
47
+
48
+ errorHandler() {
49
+ this.setState({
50
+ error: true,
51
+ });
52
+ }
53
+
54
+ init() {
55
+ this._adapter.init();
56
+ }
57
+
58
+ destroy() {
59
+ this._adapter.destroy();
60
+ }
61
+
62
+ resetAudioState() {
63
+ this._adapter.resetAudioState();
64
+ }
65
+
66
+ handleStatusClick() {
67
+ this._adapter.handleStatusClick();
68
+ }
69
+
70
+ handleTimeUpdate() {
71
+ this._adapter.handleTimeUpdate();
72
+ }
73
+
74
+ handleTrackChange(direction: 'next' | 'prev') {
75
+ this._adapter.handleTrackChange(direction);
76
+ }
77
+
78
+ getAudioRef() {
79
+ return this._adapter.getAudioRef();
80
+ }
81
+
82
+ handleTimeChange(value: number) {
83
+ this._adapter.handleTimeChange(value);
84
+ }
85
+
86
+ handleSpeedChange(value: { label: string; value: number }) {
87
+ this._adapter.handleSpeedChange(value);
88
+ }
89
+
90
+ handleSeek(direction: number) {
91
+ this._adapter.handleSeek(direction);
92
+ }
93
+
94
+ handleRefresh() {
95
+ this._adapter.handleRefresh();
96
+ }
97
+
98
+ handleVolumeChange(value: number) {
99
+ this._adapter.handleVolumeChange(value);
100
+ }
101
+ }
102
+
103
+ export default AudioPlayerFoundation;
@@ -0,0 +1,55 @@
1
+ $color-audio-player-background: rgba(var(--semi-grey-9), .8);
2
+ $color-audio-player-control-icon: var(--semi-color-bg-0);
3
+ $color-audio-player-control-icon-play: var(--semi-color-text-0);
4
+ $color-audio-player-font-color: var(--semi-color-bg-0);
5
+ $color-audio-player-font-color-speed: rgba(var(--semi-grey-8), 1);
6
+
7
+
8
+ $color-audio-player-background-light: var(--semi-color-bg-0);
9
+ $color-audio-player-control-icon-light: rgba(var(--semi-grey-9), 1);
10
+ $color-audio-player-control-icon-play-light: var(--semi-color-bg-0);
11
+ $color-audio-player-font-color-light: rgba(var(--semi-grey-9), 1);
12
+
13
+ $font-size-audio-player-text: 14px;
14
+
15
+ $gap-audio-player-small: 4px;
16
+ $gap-audio-player-medium: 16px;
17
+ $gap-audio-player-large: 24px;
18
+
19
+ // Size variables
20
+ $width-audio-player-max: 1440px;
21
+ $height-audio-player: 78px;
22
+ $width-audio-player-slider: 323px;
23
+ $width-audio-player-speed: 40px;
24
+ $height-audio-player-speed: 24px;
25
+ $width-audio-player-speed-menu: 65px;
26
+ $width-audio-player-volume: 43px;
27
+ $height-audio-player-volume: 164px;
28
+ $height-audio-player-time: 22px;
29
+
30
+ // Border radius
31
+ $border-radius-audio-player-speed: 3px;
32
+ $border-radius-audio-player-volume: 4px;
33
+ $border-radius-audio-player-slider: 9999px;
34
+
35
+ // Font sizes
36
+ $font-size-audio-player-small: 12px;
37
+ $line-height-audio-player-small: 16px;
38
+
39
+ // Slider dimensions
40
+ $width-audio-player-slider-bar: 4px;
41
+ $size-audio-player-slider-dot: 16px;
42
+
43
+ // Colors
44
+ $color-audio-player-disabled-bg: rgba(var(--semi-grey-0), .35);
45
+ $color-audio-player-slider-bg: rgba(var(--semi-grey-5), 1);
46
+ $color-audio-player-slider-bg-light: rgba(var(--semi-grey-2), 1);
47
+ $color-audio-player-slider-progress: rgba(var(--semi-blue-4), 1);
48
+ $color-audio-player-slider-dot-bg: rgba(var(--semi-white), 1);
49
+
50
+ $color-audio-player-disabled-text: var(--semi-color-grey-7);
51
+ $color-audio-player-text-default: var(--semi-color-default);
52
+ $color-audio-player-light-disabled-bg: var(--semi-color-disabled-text);
53
+ $color-audio-player-light-disabled-text: rgba(var(--semi-white), 1);
54
+ $color-audio-player-light-text: rgba(var(--semi-grey-9), 1);
55
+ $color-audio-player-light-hover-bg: rgba(var(--semi-grey-1), 1);
@@ -4,6 +4,14 @@
4
4
  $module: #{$prefix}-button;
5
5
 
6
6
  .#{$module} {
7
+ @keyframes #{$prefix}-animation-rotate {
8
+ from {
9
+ transform: rotate(0);
10
+ }
11
+ to {
12
+ transform: rotate(360deg);
13
+ }
14
+ }
7
15
  &.#{$module}-with-icon {
8
16
  display: inline-flex;
9
17
  align-items: center;
@@ -0,0 +1,26 @@
1
+ import { BASE_CLASS_PREFIX } from '../base/constants';
2
+
3
+ const moduleName = `${BASE_CLASS_PREFIX}-cropper`;
4
+
5
+ const cssClasses = {
6
+ PREFIX: `${moduleName}`,
7
+ IMG: `${moduleName}-img`,
8
+ IMG_WRAPPER: `${moduleName}-img-wrapper`,
9
+ CROPPER_BOX: `${moduleName}-box`,
10
+ CROPPER_VIEW_BOX: `${moduleName}-view-box`,
11
+ CROPPER_VIEW_BOX_ROUND: `${moduleName}-view-box-round`,
12
+ CROPPER_IMG: `${moduleName}-view-img`,
13
+ MASK: `${moduleName}-mask`,
14
+ CORNER: `${moduleName}-box-corner`,
15
+ };
16
+
17
+ const strings = {
18
+ shape: ['rect', 'round', 'roundRect'],
19
+ corner: ['tl', 'tm', 'tr',
20
+ 'ml', 'mr',
21
+ 'bl', 'bm', 'br'],
22
+ roundCorner: ['tm', 'ml', 'mr', 'bm'],
23
+
24
+ };
25
+
26
+ export { cssClasses, strings };
@@ -0,0 +1,116 @@
1
+ @import "./variables.scss";
2
+ $module: #{$prefix}-cropper;
3
+
4
+ $half_corner_width: calc($width-cropper_box_corner / 2);
5
+
6
+ .#{$module} {
7
+ position: relative;
8
+
9
+ &-img {
10
+ position: absolute;
11
+ user-select: none;
12
+ }
13
+
14
+ &-img-wrapper {
15
+ position: absolute;
16
+ top: 0;
17
+ left: 0;
18
+ right: 0;
19
+ bottom: 0;
20
+ overflow: hidden;
21
+ }
22
+
23
+ &-mask {
24
+ position: absolute;
25
+ top: 0;
26
+ left: 0;
27
+ width: 100%;
28
+ height: 100%;
29
+ background: $color-cropper_mask-bg;
30
+ cursor: move;;
31
+ }
32
+
33
+ &-box {
34
+ position: absolute;
35
+ outline: $width-cropper_box-outline solid $color-cropper_box-outline;
36
+
37
+ &-corner {
38
+ position: absolute;
39
+ background: $color-cropper_box_corner-bg;
40
+ width: $width-cropper_box_corner;
41
+ height: $width-cropper_box_corner;
42
+ z-index: 1;
43
+
44
+ &-tl {
45
+ top: -$half_corner_width;
46
+ left: -$half_corner_width;
47
+ cursor: nwse-resize;
48
+ }
49
+
50
+ &-tr {
51
+ top: -$half_corner_width;
52
+ right: -$half_corner_width;
53
+ cursor: nesw-resize;
54
+ }
55
+
56
+ &-tm {
57
+ top: -$half_corner_width;
58
+ left: 50%;
59
+ margin-left: -$half_corner_width;
60
+ cursor: ns-resize;
61
+ }
62
+
63
+ &-ml {
64
+ top: 50%;
65
+ left: -$half_corner_width;
66
+ margin-top: -$half_corner_width;
67
+ cursor: ew-resize;
68
+ }
69
+
70
+ &-mr {
71
+ top: 50%;
72
+ right: -$half_corner_width;
73
+ margin-top: -$half_corner_width;
74
+ cursor: ew-resize;
75
+ }
76
+
77
+ &-bl {
78
+ bottom: -$half_corner_width;
79
+ left: -$half_corner_width;
80
+ cursor: nesw-resize;
81
+ }
82
+
83
+ &-bm {
84
+ bottom: -$half_corner_width;
85
+ left: 50%;
86
+ margin-left: -$half_corner_width;
87
+ cursor: ns-resize;
88
+ }
89
+
90
+ &-br {
91
+ bottom: -$half_corner_width;
92
+ right: -$half_corner_width;
93
+ cursor: nwse-resize
94
+ }
95
+ }
96
+ }
97
+
98
+ &-view-box {
99
+ position: absolute;
100
+ overflow: hidden;
101
+ cursor: move;
102
+ top: 0;
103
+ left: 0;
104
+ right: 0;
105
+ bottom: 0;
106
+
107
+ &-round {
108
+ border-radius: 50%;
109
+ }
110
+ }
111
+
112
+ &-view-img {
113
+ // position: absolute;
114
+ user-select: none;
115
+ }
116
+ }