@easy-editor/materials-dashboard-image 0.0.2 → 0.0.3

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,285 +1,186 @@
1
- /**
2
- * Image 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: '.jpg,.jpeg,.png,.gif,.svg',
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: 'alt',
121
- title: '替代文本',
122
- setter: 'StringSetter',
123
- },
124
- ],
125
- },
126
- {
127
- type: 'group',
128
- title: '加载',
129
- setter: {
130
- componentName: 'CollapseSetter',
131
- props: {
132
- icon: false,
133
- },
134
- },
135
- items: [
136
- {
137
- name: 'lazyLoad',
138
- title: '懒加载',
139
- setter: 'SwitchSetter',
140
- extraProps: {
141
- defaultValue: false,
142
- },
143
- },
144
- {
145
- name: 'lazyLoadThreshold',
146
- title: '懒加载阈值',
147
- setter: {
148
- componentName: 'SliderSetter',
149
- props: {
150
- min: 0,
151
- max: 500,
152
- step: 50,
153
- suffix: 'px',
154
- },
155
- },
156
- extraProps: {
157
- defaultValue: 100,
158
- },
159
- },
160
- {
161
- name: 'placeholder',
162
- title: '占位图',
163
- setter: 'StringSetter',
164
- },
165
- ],
166
- },
167
- {
168
- type: 'group',
169
- title: '样式',
170
- setter: {
171
- componentName: 'CollapseSetter',
172
- props: {
173
- icon: false,
174
- },
175
- },
176
- items: [
177
- {
178
- name: 'objectFit',
179
- title: '填充方式',
180
- setter: {
181
- componentName: 'SelectSetter',
182
- props: {
183
- options: [
184
- { label: '覆盖', value: 'cover' },
185
- { label: '包含', value: 'contain' },
186
- { label: '填充', value: 'fill' },
187
- { label: '无', value: 'none' },
188
- ],
189
- },
190
- },
191
- extraProps: {
192
- defaultValue: 'cover',
193
- },
194
- },
195
- {
196
- name: 'borderRadius',
197
- title: '圆角',
198
- setter: 'NumberSetter',
199
- extraProps: {
200
- defaultValue: 0,
201
- },
202
- },
203
- {
204
- name: 'borderStyle',
205
- title: '边框样式',
206
- setter: {
207
- componentName: 'SelectSetter',
208
- props: {
209
- options: [
210
- { label: '无', value: 'none' },
211
- { label: '霓虹', value: 'neon' },
212
- { label: '渐变', value: 'gradient' },
213
- { label: '科技感', value: 'tech' },
214
- ],
215
- },
216
- },
217
- extraProps: {
218
- defaultValue: 'none',
219
- },
220
- },
221
- {
222
- name: 'borderColor',
223
- title: '边框颜色',
224
- setter: 'ColorSetter',
225
- extraProps: {
226
- defaultValue: '#00d4ff',
227
- },
228
- },
229
- {
230
- name: 'shadow',
231
- title: '启用阴影',
232
- setter: 'SwitchSetter',
233
- extraProps: {
234
- defaultValue: false,
235
- },
236
- },
237
- {
238
- name: 'shadowColor',
239
- title: '阴影颜色',
240
- setter: 'ColorSetter',
241
- extraProps: {
242
- defaultValue: 'rgba(0, 212, 255, 0.3)',
243
- },
244
- },
245
- ],
246
- },
247
- ],
248
- },
249
- {
250
- type: 'group',
251
- key: 'data',
252
- title: '数据',
253
- items: [
254
- {
255
- name: 'dataBinding',
256
- title: '数据绑定',
257
- setter: 'DataBindingSetter',
258
- },
259
- ],
260
- },
261
- {
262
- type: 'group',
263
- key: 'advanced',
264
- title: '高级',
265
- items: [
266
- {
267
- name: 'condition',
268
- title: '显隐控制',
269
- setter: 'SwitchSetter',
270
- extraProps: {
271
- defaultValue: true,
272
- supportVariable: true,
273
- },
274
- },
275
- ],
276
- },
277
- ],
278
- },
279
- ],
280
- component: {},
281
- supports: {},
282
- advanced: {},
283
- }
284
-
285
- export default configure
1
+ /**
2
+ * Image Configure
3
+ * 图片组件配置
4
+ */
5
+
6
+ import type { FieldConfig } from '@easy-editor/core'
7
+ import type { UploadValue } from '@easy-editor/materials-shared'
8
+ import { createCollapseGroup, createSimpleConfigure } 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: '.jpg,.jpeg,.png,.gif,.svg',
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: 'alt',
60
+ title: '替代文本',
61
+ setter: 'StringSetter',
62
+ },
63
+ ],
64
+ },
65
+ // 加载 Tab
66
+ {
67
+ type: 'group',
68
+ key: 'loading',
69
+ title: '加载',
70
+ items: [
71
+ {
72
+ name: 'lazyLoad',
73
+ title: '懒加载',
74
+ setter: 'SwitchSetter',
75
+ extraProps: {
76
+ defaultValue: false,
77
+ },
78
+ },
79
+ {
80
+ name: 'lazyLoadThreshold',
81
+ title: '懒加载阈值',
82
+ setter: {
83
+ componentName: 'SliderSetter',
84
+ props: {
85
+ min: 0,
86
+ max: 500,
87
+ step: 50,
88
+ suffix: 'px',
89
+ },
90
+ },
91
+ extraProps: {
92
+ defaultValue: 100,
93
+ },
94
+ },
95
+ {
96
+ name: 'placeholder',
97
+ title: '占位图',
98
+ setter: 'StringSetter',
99
+ },
100
+ ],
101
+ },
102
+ // 样式 Tab
103
+ {
104
+ type: 'group',
105
+ key: 'style',
106
+ title: '样式',
107
+ items: [
108
+ {
109
+ name: 'objectFit',
110
+ title: '填充方式',
111
+ setter: {
112
+ componentName: 'SelectSetter',
113
+ props: {
114
+ options: [
115
+ { label: '覆盖', value: 'cover' },
116
+ { label: '包含', value: 'contain' },
117
+ { label: '填充', value: 'fill' },
118
+ { label: '无', value: 'none' },
119
+ ],
120
+ },
121
+ },
122
+ extraProps: {
123
+ defaultValue: 'cover',
124
+ },
125
+ },
126
+ {
127
+ name: 'borderRadius',
128
+ title: '圆角',
129
+ setter: 'NumberSetter',
130
+ extraProps: {
131
+ defaultValue: 0,
132
+ },
133
+ },
134
+ {
135
+ name: 'borderStyle',
136
+ title: '边框样式',
137
+ setter: {
138
+ componentName: 'SelectSetter',
139
+ props: {
140
+ options: [
141
+ { label: '无', value: 'none' },
142
+ { label: '霓虹', value: 'neon' },
143
+ { label: '渐变', value: 'gradient' },
144
+ { label: '科技感', value: 'tech' },
145
+ ],
146
+ },
147
+ },
148
+ extraProps: {
149
+ defaultValue: 'none',
150
+ },
151
+ },
152
+ {
153
+ name: 'borderColor',
154
+ title: '边框颜色',
155
+ setter: 'ColorSetter',
156
+ extraProps: {
157
+ defaultValue: '#00d4ff',
158
+ },
159
+ },
160
+ {
161
+ name: 'shadow',
162
+ title: '启用阴影',
163
+ setter: 'SwitchSetter',
164
+ extraProps: {
165
+ defaultValue: false,
166
+ },
167
+ },
168
+ {
169
+ name: 'shadowColor',
170
+ title: '阴影颜色',
171
+ setter: 'ColorSetter',
172
+ extraProps: {
173
+ defaultValue: 'rgba(0, 212, 255, 0.3)',
174
+ },
175
+ },
176
+ ],
177
+ },
178
+ ],
179
+ },
180
+ ],
181
+ {
182
+ padding: '6px 16px 12px',
183
+ },
184
+ )
185
+
186
+ export const configure = createSimpleConfigure(componentConfigGroup)
package/src/index.tsx CHANGED
@@ -1,7 +1,7 @@
1
- /**
2
- * Image Entry
3
- * 图片组件入口
4
- */
5
-
6
- export { Image as component } from './component'
7
- export { default as meta } from './meta'
1
+ /**
2
+ * Image Entry
3
+ * 图片组件入口
4
+ */
5
+
6
+ export { Image as component } from './component'
7
+ export { meta } from './meta'
package/src/meta.ts CHANGED
@@ -1,28 +1,26 @@
1
- /**
2
- * Image 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
+ * Image 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,49 +1,55 @@
1
- /**
2
- * Image 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
- alt: '图片',
17
- objectFit: 'contain',
18
- borderRadius: 0,
19
- },
20
- $dashboard: {
21
- rect: {
22
- width: 200,
23
- height: 180,
24
- },
25
- },
26
- },
27
- },
28
- {
29
- title: '圆角图片',
30
- screenshot: '',
31
- schema: {
32
- componentName: COMPONENT_NAME,
33
- props: {
34
- alt: '圆角图片',
35
- objectFit: 'contain',
36
- borderRadius: 100,
37
- borderStyle: 'tech',
38
- },
39
- $dashboard: {
40
- rect: {
41
- width: 200,
42
- height: 200,
43
- },
44
- },
45
- },
46
- },
47
- ]
48
-
49
- export default snippets
1
+ /**
2
+ * Image 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
+ title: '普通图片',
16
+ props: {
17
+ alt: '图片',
18
+ objectFit: 'contain',
19
+ borderRadius: 0,
20
+ rotation: 0,
21
+ opacity: 100,
22
+ background: 'transparent',
23
+ },
24
+ $dashboard: {
25
+ rect: {
26
+ width: 200,
27
+ height: 180,
28
+ },
29
+ },
30
+ },
31
+ },
32
+ {
33
+ title: '圆角图片',
34
+ screenshot: '',
35
+ schema: {
36
+ componentName: COMPONENT_NAME,
37
+ title: '圆角图片',
38
+ props: {
39
+ alt: '圆角图片',
40
+ objectFit: 'contain',
41
+ borderRadius: 100,
42
+ borderStyle: 'tech',
43
+ rotation: 0,
44
+ opacity: 100,
45
+ background: 'transparent',
46
+ },
47
+ $dashboard: {
48
+ rect: {
49
+ width: 200,
50
+ height: 200,
51
+ },
52
+ },
53
+ },
54
+ },
55
+ ]