@easy-editor/materials-dashboard-audio 0.0.2 → 0.0.4

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/src/configure.ts CHANGED
@@ -1,247 +1,165 @@
1
- /**
2
- * Audio Configure
3
- * 音频组件配置
4
- */
5
-
6
- import type { Configure } from '@easy-editor/core'
7
- import type { UploadValue } from '@easy-editor/materials-shared'
8
-
9
- export const configure: Configure = {
10
- props: [
11
- {
12
- type: 'group',
13
- title: '属性',
14
- setter: 'TabSetter',
15
- items: [
16
- {
17
- type: 'group',
18
- key: 'config',
19
- title: '配置',
20
- setter: {
21
- componentName: 'CollapseSetter',
22
- props: {
23
- icon: false,
24
- },
25
- },
26
- items: [
27
- // 基础配置
28
- {
29
- name: 'id',
30
- title: 'ID',
31
- setter: 'NodeIdSetter',
32
- extraProps: {
33
- // @ts-expect-error label is not a valid extra prop
34
- label: false,
35
- },
36
- },
37
- {
38
- name: 'title',
39
- title: '标题',
40
- setter: 'StringSetter',
41
- extraProps: {
42
- getValue(target) {
43
- return target.getExtraPropValue('title')
44
- },
45
- setValue(target, value) {
46
- target.setExtraPropValue('title', value)
47
- },
48
- },
49
- },
50
- {
51
- type: 'group',
52
- title: '基础属性',
53
- setter: {
54
- componentName: 'CollapseSetter',
55
- props: {
56
- icon: false,
57
- },
58
- },
59
- items: [
60
- {
61
- name: 'rect',
62
- title: '位置尺寸',
63
- setter: 'RectSetter',
64
- extraProps: {
65
- getValue(target) {
66
- return target.getExtraPropValue('$dashboard.rect')
67
- },
68
- setValue(target, value) {
69
- target.setExtraPropValue('$dashboard.rect', value)
70
- },
71
- },
72
- },
73
- ],
74
- },
75
- // 组件配置
76
- {
77
- type: 'group',
78
- title: '内容',
79
- setter: {
80
- componentName: 'CollapseSetter',
81
- props: {
82
- icon: false,
83
- },
84
- },
85
- items: [
86
- {
87
- name: '__upload',
88
- title: '上传',
89
- setter: {
90
- componentName: 'UploadSetter',
91
- props: {
92
- accept: '.mp3,.wav,.ogg',
93
- },
94
- },
95
- extraProps: {
96
- setValue(target, value: UploadValue) {
97
- if (value) {
98
- const { base64, raw } = value
99
- if (base64) {
100
- target.parent.setPropValue('src', base64)
101
- }
102
- if (raw?.width) {
103
- target.parent.setExtraPropValue('$dashboard.rect.width', raw.width)
104
- }
105
- if (raw?.height) {
106
- target.parent.setExtraPropValue('$dashboard.rect.height', raw.height)
107
- }
108
- } else {
109
- target.parent.clearPropValue('src')
110
- }
111
- },
112
- },
113
- },
114
- {
115
- name: 'src',
116
- title: '音频地址',
117
- setter: 'StringSetter',
118
- },
119
- {
120
- name: 'title',
121
- title: '标题',
122
- setter: 'StringSetter',
123
- extraProps: {
124
- defaultValue: '音频文件',
125
- },
126
- },
127
- ],
128
- },
129
- {
130
- type: 'group',
131
- title: '播放',
132
- setter: {
133
- componentName: 'CollapseSetter',
134
- props: {
135
- icon: false,
136
- },
137
- },
138
- items: [
139
- {
140
- name: 'autoPlay',
141
- title: '自动播放',
142
- setter: 'SwitchSetter',
143
- extraProps: {
144
- defaultValue: false,
145
- },
146
- },
147
- {
148
- name: 'loop',
149
- title: '循环播放',
150
- setter: 'SwitchSetter',
151
- extraProps: {
152
- defaultValue: false,
153
- },
154
- },
155
- {
156
- name: 'audioStyle',
157
- title: '样式类型',
158
- setter: {
159
- componentName: 'SelectSetter',
160
- props: {
161
- options: [
162
- { label: '自定义', value: 'custom' },
163
- { label: '原生', value: 'native' },
164
- ],
165
- },
166
- },
167
- extraProps: {
168
- defaultValue: 'custom',
169
- },
170
- },
171
- {
172
- name: 'playbackRate',
173
- title: '播放速度',
174
- setter: {
175
- componentName: 'SelectSetter',
176
- props: {
177
- options: [
178
- { label: '0.5x', value: 0.5 },
179
- { label: '0.75x', value: 0.75 },
180
- { label: '1x (正常)', value: 1 },
181
- { label: '1.25x', value: 1.25 },
182
- { label: '1.5x', value: 1.5 },
183
- { label: '2x', value: 2 },
184
- ],
185
- },
186
- },
187
- extraProps: {
188
- defaultValue: 1,
189
- },
190
- },
191
- {
192
- name: 'volume',
193
- title: '音量',
194
- setter: {
195
- componentName: 'SliderSetter',
196
- props: {
197
- min: 0,
198
- max: 100,
199
- step: 1,
200
- suffix: '%',
201
- },
202
- },
203
- extraProps: {
204
- defaultValue: 100,
205
- },
206
- },
207
- ],
208
- },
209
- ],
210
- },
211
- {
212
- type: 'group',
213
- key: 'data',
214
- title: '数据',
215
- items: [
216
- {
217
- name: 'dataBinding',
218
- title: '数据绑定',
219
- setter: 'DataBindingSetter',
220
- },
221
- ],
222
- },
223
- {
224
- type: 'group',
225
- key: 'advanced',
226
- title: '高级',
227
- items: [
228
- {
229
- name: 'condition',
230
- title: '显隐控制',
231
- setter: 'SwitchSetter',
232
- extraProps: {
233
- defaultValue: true,
234
- supportVariable: true,
235
- },
236
- },
237
- ],
238
- },
239
- ],
240
- },
241
- ],
242
- component: {},
243
- supports: {},
244
- advanced: {},
245
- }
246
-
247
- export default configure
1
+ /**
2
+ * Audio Configure
3
+ * 音频组件配置
4
+ */
5
+
6
+ import type { FieldConfig } from '@easy-editor/core'
7
+ import type { UploadValue } from '@easy-editor/materials-shared'
8
+ import { createCollapseGroup, createDataConfigGroup, createStandardConfigure } from '@easy-editor/materials-shared'
9
+
10
+ /** 组件配置 - 音频独有 */
11
+ const componentConfigGroup: FieldConfig = createCollapseGroup(
12
+ '组件配置',
13
+ [
14
+ {
15
+ type: 'group',
16
+ title: '组件配置',
17
+ setter: 'SubTabSetter',
18
+ items: [
19
+ // 内容 Tab
20
+ {
21
+ type: 'group',
22
+ key: 'content',
23
+ title: '内容',
24
+ items: [
25
+ {
26
+ name: '__upload',
27
+ title: '上传',
28
+ setter: {
29
+ componentName: 'UploadSetter',
30
+ props: {
31
+ accept: '.mp3,.wav,.ogg',
32
+ },
33
+ },
34
+ extraProps: {
35
+ setValue(target, value: UploadValue) {
36
+ if (value) {
37
+ const { base64, raw } = value
38
+ if (base64) {
39
+ target.parent.setPropValue('src', base64)
40
+ }
41
+ if (raw?.width) {
42
+ target.parent.setExtraPropValue('$dashboard.rect.width', raw.width)
43
+ }
44
+ if (raw?.height) {
45
+ target.parent.setExtraPropValue('$dashboard.rect.height', raw.height)
46
+ }
47
+ } else {
48
+ target.parent.clearPropValue('src')
49
+ }
50
+ },
51
+ },
52
+ },
53
+ {
54
+ name: 'src',
55
+ title: '音频地址',
56
+ setter: 'StringSetter',
57
+ },
58
+ {
59
+ name: 'title',
60
+ title: '标题',
61
+ setter: 'StringSetter',
62
+ extraProps: {
63
+ defaultValue: '音频文件',
64
+ },
65
+ },
66
+ ],
67
+ },
68
+ // 播放 Tab
69
+ {
70
+ type: 'group',
71
+ key: 'playback',
72
+ title: '播放',
73
+ items: [
74
+ {
75
+ name: 'autoPlay',
76
+ title: '自动播放',
77
+ setter: 'SwitchSetter',
78
+ extraProps: {
79
+ defaultValue: false,
80
+ },
81
+ },
82
+ {
83
+ name: 'loop',
84
+ title: '循环播放',
85
+ setter: 'SwitchSetter',
86
+ extraProps: {
87
+ defaultValue: false,
88
+ },
89
+ },
90
+ {
91
+ name: 'playbackRate',
92
+ title: '播放速度',
93
+ setter: {
94
+ componentName: 'SelectSetter',
95
+ props: {
96
+ options: [
97
+ { label: '0.5x', value: 0.5 },
98
+ { label: '0.75x', value: 0.75 },
99
+ { label: '1x (正常)', value: 1 },
100
+ { label: '1.25x', value: 1.25 },
101
+ { label: '1.5x', value: 1.5 },
102
+ { label: '2x', value: 2 },
103
+ ],
104
+ },
105
+ },
106
+ extraProps: {
107
+ defaultValue: 1,
108
+ },
109
+ },
110
+ {
111
+ name: 'volume',
112
+ title: '音量',
113
+ setter: {
114
+ componentName: 'SliderSetter',
115
+ props: {
116
+ min: 0,
117
+ max: 100,
118
+ step: 1,
119
+ suffix: '%',
120
+ },
121
+ },
122
+ extraProps: {
123
+ defaultValue: 100,
124
+ },
125
+ },
126
+ ],
127
+ },
128
+ // 样式 Tab
129
+ {
130
+ type: 'group',
131
+ key: 'style',
132
+ title: '样式',
133
+ items: [
134
+ {
135
+ name: 'audioStyle',
136
+ title: '样式类型',
137
+ setter: {
138
+ componentName: 'SegmentedSetter',
139
+ props: {
140
+ options: [
141
+ { label: '自定义', value: 'custom' },
142
+ { label: '原生', value: 'native' },
143
+ ],
144
+ },
145
+ },
146
+ extraProps: {
147
+ defaultValue: 'custom',
148
+ },
149
+ },
150
+ ],
151
+ },
152
+ ],
153
+ },
154
+ ],
155
+ {
156
+ padding: '6px 16px 12px',
157
+ },
158
+ )
159
+
160
+ /** 数据配置 */
161
+ const dataConfigGroup: FieldConfig = createDataConfigGroup([
162
+ { name: 'src', label: 'src', type: 'string', required: true, description: '音频地址' },
163
+ ])
164
+
165
+ export const configure = createStandardConfigure(componentConfigGroup, dataConfigGroup)
package/src/index.tsx CHANGED
@@ -1,7 +1,7 @@
1
- /**
2
- * Audio Entry
3
- * 音频组件入口
4
- */
5
-
6
- export { Audio as component } from './component'
7
- export { default as meta } from './meta'
1
+ /**
2
+ * Audio Entry
3
+ * 音频组件入口
4
+ */
5
+
6
+ export { Audio as component } from './component'
7
+ export { meta } from './meta'
package/src/meta.ts CHANGED
@@ -1,28 +1,26 @@
1
- /**
2
- * Audio Meta
3
- * 音频组件元数据
4
- */
5
-
6
- import type { ComponentMetadata } from '@easy-editor/core'
7
- import { MaterialGroup } from '@easy-editor/materials-shared'
8
- import { COMPONENT_NAME, PACKAGE_NAME } from './constants'
9
- import configure from './configure'
10
- import snippets from './snippets'
11
- import pkg from '../package.json'
12
-
13
- export const meta: ComponentMetadata = {
14
- componentName: COMPONENT_NAME,
15
- title: '音频',
16
- group: MaterialGroup.MEDIA,
17
- devMode: 'proCode',
18
- npm: {
19
- package: PACKAGE_NAME,
20
- version: pkg.version,
21
- globalName: COMPONENT_NAME,
22
- componentName: COMPONENT_NAME,
23
- },
24
- snippets,
25
- configure,
26
- }
27
-
28
- export default meta
1
+ /**
2
+ * Audio Meta
3
+ * 音频组件元数据
4
+ */
5
+
6
+ import type { ComponentMetadata } from '@easy-editor/core'
7
+ import { MaterialGroup } from '@easy-editor/materials-shared'
8
+ import { COMPONENT_NAME, PACKAGE_NAME } from './constants'
9
+ import { configure } from './configure'
10
+ import { snippets } from './snippets'
11
+ import pkg from '../package.json'
12
+
13
+ export const meta: ComponentMetadata = {
14
+ componentName: COMPONENT_NAME,
15
+ title: '音频',
16
+ group: MaterialGroup.MEDIA,
17
+ devMode: 'proCode',
18
+ npm: {
19
+ package: PACKAGE_NAME,
20
+ version: pkg.version,
21
+ globalName: COMPONENT_NAME,
22
+ componentName: COMPONENT_NAME,
23
+ },
24
+ snippets,
25
+ configure,
26
+ }
package/src/snippets.ts CHANGED
@@ -1,50 +1,61 @@
1
- /**
2
- * Audio Snippets
3
- * 音频组件代码片段
4
- */
5
-
6
- import type { Snippet } from '@easy-editor/core'
7
- import { COMPONENT_NAME } from './constants'
8
-
9
- export const snippets: Snippet[] = [
10
- {
11
- title: '音频播放器',
12
- screenshot: '',
13
- schema: {
14
- componentName: COMPONENT_NAME,
15
- props: {
16
- src: '',
17
- title: '音频文件',
18
- autoPlay: false,
19
- loop: false,
20
- audioStyle: 'custom',
21
- },
22
- $dashboard: {
23
- rect: {
24
- width: 300,
25
- height: 60,
26
- },
27
- },
28
- },
29
- },
30
- {
31
- title: '原生音频',
32
- screenshot: '',
33
- schema: {
34
- componentName: COMPONENT_NAME,
35
- props: {
36
- src: '',
37
- title: '音频文件',
38
- audioStyle: 'native',
39
- },
40
- $dashboard: {
41
- rect: {
42
- width: 300,
43
- height: 60,
44
- },
45
- },
46
- },
47
- },
48
- ]
49
-
50
- export default snippets
1
+ /**
2
+ * Audio Snippets
3
+ * 音频组件代码片段 - 使用共享数据源生成函数
4
+ */
5
+
6
+ import type { Snippet } from '@easy-editor/core'
7
+ import { generateStaticDataSource } from '@easy-editor/materials-shared'
8
+ import { COMPONENT_NAME } from './constants'
9
+
10
+ const snippets: Snippet[] = [
11
+ {
12
+ title: '音频播放器',
13
+ screenshot: '',
14
+ schema: {
15
+ componentName: COMPONENT_NAME,
16
+ title: '音频播放器',
17
+ props: {
18
+ $data: generateStaticDataSource({ src: '' }),
19
+ title: '音频文件',
20
+ autoPlay: false,
21
+ loop: false,
22
+ audioStyle: 'custom',
23
+ playbackRate: 1,
24
+ volume: 100,
25
+ rotation: 0,
26
+ opacity: 100,
27
+ background: 'transparent',
28
+ },
29
+ $dashboard: {
30
+ rect: {
31
+ width: 300,
32
+ height: 60,
33
+ },
34
+ },
35
+ },
36
+ },
37
+ {
38
+ title: '原生音频',
39
+ screenshot: '',
40
+ schema: {
41
+ componentName: COMPONENT_NAME,
42
+ title: '原生音频',
43
+ props: {
44
+ $data: generateStaticDataSource({ src: '' }),
45
+ title: '音频文件',
46
+ audioStyle: 'native',
47
+ rotation: 0,
48
+ opacity: 100,
49
+ background: 'transparent',
50
+ },
51
+ $dashboard: {
52
+ rect: {
53
+ width: 300,
54
+ height: 60,
55
+ },
56
+ },
57
+ },
58
+ },
59
+ ]
60
+
61
+ export { snippets }
package/tsconfig.json CHANGED
@@ -1,9 +1,20 @@
1
- {
2
- "compilerOptions": {
3
- "jsx": "react-jsx",
4
- "esModuleInterop": true,
5
- "allowSyntheticDefaultImports": true
6
- },
7
- "extends": "./tsconfig.build.json",
8
- "include": ["./src", "./test"]
9
- }
1
+ {
2
+ "compilerOptions": {
3
+ "emitDeclarationOnly": true,
4
+ "declaration": true,
5
+ "target": "ESNext",
6
+ "newLine": "LF",
7
+ "module": "ESNext",
8
+ "moduleResolution": "Bundler",
9
+ "strict": true,
10
+ "strictNullChecks": true,
11
+ "jsx": "react-jsx",
12
+ "esModuleInterop": true,
13
+ "allowSyntheticDefaultImports": true,
14
+ "strictPropertyInitialization": false,
15
+ "outDir": "./dist",
16
+ "skipLibCheck": true,
17
+ },
18
+ "exclude": ["node_modules", "dist"],
19
+ "include": ["./src"]
20
+ }