@easy-editor/materials-dashboard-carousel 0.0.3 → 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,194 +1,97 @@
1
- /**
2
- * Carousel Configure
3
- * 轮播组件配置
4
- */
5
-
6
- import type { Configure } from '@easy-editor/core'
7
-
8
- export const configure: Configure = {
9
- props: [
10
- {
11
- type: 'group',
12
- title: '属性',
13
- setter: 'TabSetter',
14
- items: [
15
- {
16
- type: 'group',
17
- key: 'config',
18
- title: '配置',
19
- setter: {
20
- componentName: 'CollapseSetter',
21
- props: {
22
- icon: false,
23
- },
24
- },
25
- items: [
26
- // 基础配置
27
- {
28
- name: 'id',
29
- title: 'ID',
30
- setter: 'NodeIdSetter',
31
- extraProps: {
32
- // @ts-expect-error label is not a valid extra prop
33
- label: false,
34
- },
35
- },
36
- {
37
- name: 'title',
38
- title: '标题',
39
- setter: 'StringSetter',
40
- extraProps: {
41
- getValue(target) {
42
- return target.getExtraPropValue('title')
43
- },
44
- setValue(target, value) {
45
- target.setExtraPropValue('title', value)
46
- },
47
- },
48
- },
49
- {
50
- type: 'group',
51
- title: '基础属性',
52
- setter: {
53
- componentName: 'CollapseSetter',
54
- props: {
55
- icon: false,
56
- },
57
- },
58
- items: [
59
- {
60
- name: 'rect',
61
- title: '位置尺寸',
62
- setter: 'RectSetter',
63
- extraProps: {
64
- getValue(target) {
65
- return target.getExtraPropValue('$dashboard.rect')
66
- },
67
- setValue(target, value) {
68
- target.setExtraPropValue('$dashboard.rect', value)
69
- },
70
- },
71
- },
72
- ],
73
- },
74
- // 组件配置
75
- {
76
- type: 'group',
77
- title: '数据',
78
- setter: {
79
- componentName: 'CollapseSetter',
80
- props: {
81
- icon: false,
82
- },
83
- },
84
- items: [
85
- {
86
- name: 'items',
87
- title: '轮播项',
88
- setter: 'JsonSetter',
89
- },
90
- ],
91
- },
92
- {
93
- type: 'group',
94
- title: '行为',
95
- setter: {
96
- componentName: 'CollapseSetter',
97
- props: {
98
- icon: false,
99
- },
100
- },
101
- items: [
102
- {
103
- name: 'autoPlay',
104
- title: '自动播放',
105
- setter: 'SwitchSetter',
106
- extraProps: {
107
- defaultValue: true,
108
- },
109
- },
110
- {
111
- name: 'interval',
112
- title: '播放间隔(ms)',
113
- setter: 'NumberSetter',
114
- extraProps: {
115
- defaultValue: 3000,
116
- },
117
- },
118
- {
119
- name: 'loop',
120
- title: '循环播放',
121
- setter: 'SwitchSetter',
122
- extraProps: {
123
- defaultValue: true,
124
- },
125
- },
126
- ],
127
- },
128
- {
129
- type: 'group',
130
- title: '显示',
131
- setter: {
132
- componentName: 'CollapseSetter',
133
- props: {
134
- icon: false,
135
- },
136
- },
137
- items: [
138
- {
139
- name: 'showNav',
140
- title: '显示导航按钮',
141
- setter: 'SwitchSetter',
142
- extraProps: {
143
- defaultValue: true,
144
- },
145
- },
146
- {
147
- name: 'showIndicators',
148
- title: '显示指示器',
149
- setter: 'SwitchSetter',
150
- extraProps: {
151
- defaultValue: true,
152
- },
153
- },
154
- ],
155
- },
156
- ],
157
- },
158
- {
159
- type: 'group',
160
- key: 'data',
161
- title: '数据',
162
- items: [
163
- {
164
- name: 'dataBinding',
165
- title: '数据绑定',
166
- setter: 'DataBindingSetter',
167
- },
168
- ],
169
- },
170
- {
171
- type: 'group',
172
- key: 'advanced',
173
- title: '高级',
174
- items: [
175
- {
176
- name: 'condition',
177
- title: '显隐控制',
178
- setter: 'SwitchSetter',
179
- extraProps: {
180
- defaultValue: true,
181
- supportVariable: true,
182
- },
183
- },
184
- ],
185
- },
186
- ],
187
- },
188
- ],
189
- component: {},
190
- supports: {},
191
- advanced: {},
192
- }
193
-
194
- export default configure
1
+ /**
2
+ * Carousel Configure
3
+ * 轮播组件配置
4
+ */
5
+
6
+ import type { FieldConfig } from '@easy-editor/core'
7
+ import { createCollapseGroup, createDataConfigGroup, createStandardConfigure } from '@easy-editor/materials-shared'
8
+
9
+ /** 组件配置 - 轮播独有 */
10
+ const componentConfigGroup: FieldConfig = createCollapseGroup(
11
+ '组件配置',
12
+ [
13
+ {
14
+ type: 'group',
15
+ title: '组件配置',
16
+ setter: 'SubTabSetter',
17
+ items: [
18
+ // 行为 Tab
19
+ {
20
+ type: 'group',
21
+ key: 'behavior',
22
+ title: '行为',
23
+ items: [
24
+ {
25
+ name: 'autoPlay',
26
+ title: '自动播放',
27
+ setter: 'SwitchSetter',
28
+ extraProps: {
29
+ defaultValue: true,
30
+ },
31
+ },
32
+ {
33
+ name: 'interval',
34
+ title: '播放间隔',
35
+ setter: {
36
+ componentName: 'SliderSetter',
37
+ props: {
38
+ min: 1000,
39
+ max: 10000,
40
+ step: 500,
41
+ suffix: 'ms',
42
+ },
43
+ },
44
+ extraProps: {
45
+ defaultValue: 3000,
46
+ },
47
+ },
48
+ {
49
+ name: 'loop',
50
+ title: '循环播放',
51
+ setter: 'SwitchSetter',
52
+ extraProps: {
53
+ defaultValue: true,
54
+ },
55
+ },
56
+ ],
57
+ },
58
+ // 显示 Tab
59
+ {
60
+ type: 'group',
61
+ key: 'display',
62
+ title: '显示',
63
+ items: [
64
+ {
65
+ name: 'showNav',
66
+ title: '显示导航按钮',
67
+ setter: 'SwitchSetter',
68
+ extraProps: {
69
+ defaultValue: true,
70
+ },
71
+ },
72
+ {
73
+ name: 'showIndicators',
74
+ title: '显示指示器',
75
+ setter: 'SwitchSetter',
76
+ extraProps: {
77
+ defaultValue: true,
78
+ },
79
+ },
80
+ ],
81
+ },
82
+ ],
83
+ },
84
+ ],
85
+ {
86
+ padding: '6px 16px 12px',
87
+ },
88
+ )
89
+
90
+ /** 数据配置 */
91
+ const dataConfigGroup: FieldConfig = createDataConfigGroup([
92
+ { name: 'src', label: 'src', type: 'string', required: true, description: '图片地址' },
93
+ { name: 'alt', label: 'alt', type: 'string', required: false, description: '图片描述' },
94
+ { name: 'link', label: 'link', type: 'string', required: false, description: '点击链接' },
95
+ ])
96
+
97
+ export const configure = createStandardConfigure(componentConfigGroup, dataConfigGroup)
package/src/index.tsx CHANGED
@@ -1,7 +1,7 @@
1
- /**
2
- * Carousel Entry
3
- * 轮播组件入口
4
- */
5
-
6
- export { Carousel as component } from './component'
7
- export { default as meta } from './meta'
1
+ /**
2
+ * Carousel Entry
3
+ * 轮播组件入口
4
+ */
5
+
6
+ export { Carousel as component } from './component'
7
+ export { meta } from './meta'
package/src/meta.ts CHANGED
@@ -1,28 +1,26 @@
1
- /**
2
- * Carousel 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.DISPLAY,
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
+ * Carousel 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.DISPLAY,
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,60 +1,70 @@
1
- /**
2
- * Carousel 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
- items: [
17
- { src: 'https://picsum.photos/800/400?random=1', alt: 'Slide 1' },
18
- { src: 'https://picsum.photos/800/400?random=2', alt: 'Slide 2' },
19
- { src: 'https://picsum.photos/800/400?random=3', alt: 'Slide 3' },
20
- ],
21
- autoPlay: true,
22
- interval: 3000,
23
- showNav: true,
24
- showIndicators: true,
25
- loop: true,
26
- },
27
- $dashboard: {
28
- rect: {
29
- width: 600,
30
- height: 300,
31
- },
32
- },
33
- },
34
- },
35
- {
36
- title: '手动轮播',
37
- screenshot: '',
38
- schema: {
39
- componentName: COMPONENT_NAME,
40
- props: {
41
- items: [
42
- { src: 'https://picsum.photos/800/400?random=4', alt: 'Slide 1' },
43
- { src: 'https://picsum.photos/800/400?random=5', alt: 'Slide 2' },
44
- ],
45
- autoPlay: false,
46
- showNav: true,
47
- showIndicators: true,
48
- loop: true,
49
- },
50
- $dashboard: {
51
- rect: {
52
- width: 600,
53
- height: 300,
54
- },
55
- },
56
- },
57
- },
58
- ]
59
-
60
- export default snippets
1
+ /**
2
+ * Carousel 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
+ /** 默认轮播数据 */
11
+ const DEFAULT_CAROUSEL_DATA = [
12
+ { src: 'https://picsum.photos/800/400?random=1', alt: 'Slide 1' },
13
+ { src: 'https://picsum.photos/800/400?random=2', alt: 'Slide 2' },
14
+ { src: 'https://picsum.photos/800/400?random=3', alt: 'Slide 3' },
15
+ ]
16
+
17
+ export const snippets: Snippet[] = [
18
+ {
19
+ title: '图片轮播',
20
+ screenshot: '',
21
+ schema: {
22
+ componentName: COMPONENT_NAME,
23
+ title: '图片轮播',
24
+ props: {
25
+ $data: generateStaticDataSource(DEFAULT_CAROUSEL_DATA),
26
+ autoPlay: true,
27
+ interval: 3000,
28
+ showNav: true,
29
+ showIndicators: true,
30
+ loop: true,
31
+ rotation: 0,
32
+ opacity: 100,
33
+ background: 'transparent',
34
+ },
35
+ $dashboard: {
36
+ rect: {
37
+ width: 600,
38
+ height: 300,
39
+ },
40
+ },
41
+ },
42
+ },
43
+ {
44
+ title: '手动轮播',
45
+ screenshot: '',
46
+ schema: {
47
+ componentName: COMPONENT_NAME,
48
+ title: '手动轮播',
49
+ props: {
50
+ $data: generateStaticDataSource([
51
+ { src: 'https://picsum.photos/800/400?random=4', alt: 'Slide 1' },
52
+ { src: 'https://picsum.photos/800/400?random=5', alt: 'Slide 2' },
53
+ ]),
54
+ autoPlay: false,
55
+ showNav: true,
56
+ showIndicators: true,
57
+ loop: true,
58
+ rotation: 0,
59
+ opacity: 100,
60
+ background: 'transparent',
61
+ },
62
+ $dashboard: {
63
+ rect: {
64
+ width: 600,
65
+ height: 300,
66
+ },
67
+ },
68
+ },
69
+ },
70
+ ]
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
+ }