@easy-editor/materials-dashboard-carousel 0.0.3 → 0.0.5
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/CHANGELOG.md +27 -13
- package/easypack.config.ts +10 -0
- package/package.json +4 -8
- package/src/component.tsx +67 -22
- package/src/configure.ts +97 -194
- package/src/index.tsx +7 -7
- package/src/meta.ts +2 -2
- package/src/snippets.ts +70 -60
- package/tsconfig.json +20 -9
- package/.vite/plugins/vite-plugin-external-deps.ts +0 -224
- package/.vite/plugins/vite-plugin-material-dev.ts +0 -218
- package/dist/component.esm.js +0 -178
- package/dist/component.esm.js.map +0 -1
- package/dist/component.js +0 -186
- package/dist/component.js.map +0 -1
- package/dist/component.min.js +0 -2
- package/dist/component.min.js.map +0 -1
- package/dist/index.cjs +0 -418
- package/dist/index.cjs.map +0 -1
- package/dist/index.esm.js +0 -415
- package/dist/index.esm.js.map +0 -1
- package/dist/index.js +0 -422
- package/dist/index.js.map +0 -1
- package/dist/index.min.js +0 -2
- package/dist/index.min.js.map +0 -1
- package/dist/meta.esm.js +0 -241
- package/dist/meta.esm.js.map +0 -1
- package/dist/meta.js +0 -252
- package/dist/meta.js.map +0 -1
- package/dist/meta.min.js +0 -2
- package/dist/meta.min.js.map +0 -1
- package/dist/src/component.d.ts +0 -32
- package/dist/src/configure.d.ts +0 -7
- package/dist/src/constants.d.ts +0 -16
- package/dist/src/index.d.ts +0 -6
- package/dist/src/meta.d.ts +0 -7
- package/dist/src/snippets.d.ts +0 -7
- package/rollup.config.js +0 -222
- package/tsconfig.build.json +0 -12
- package/tsconfig.test.json +0 -7
- package/vite.config.ts +0 -54
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,27 @@
|
|
|
1
|
-
# @easy-editor/materials-dashboard-carousel
|
|
2
|
-
|
|
3
|
-
## 0.0.
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- fix:
|
|
8
|
-
|
|
9
|
-
## 0.0.
|
|
10
|
-
|
|
11
|
-
### Patch Changes
|
|
12
|
-
|
|
13
|
-
-
|
|
1
|
+
# @easy-editor/materials-dashboard-carousel
|
|
2
|
+
|
|
3
|
+
## 0.0.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: component export error
|
|
8
|
+
|
|
9
|
+
## 0.0.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- perf: configure & datasource
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
- @easy-editor/materials-shared@0.0.1
|
|
16
|
+
|
|
17
|
+
## 0.0.3
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- fix: build error
|
|
22
|
+
|
|
23
|
+
## 0.0.2
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- feat: new setters
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easy-editor/materials-dashboard-carousel",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Carousel component for EasyEditor dashboard",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -45,19 +45,15 @@
|
|
|
45
45
|
"@types/react-dom": "^18 || ^19"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@easy-editor/materials-shared": "0.0.
|
|
48
|
+
"@easy-editor/materials-shared": "0.0.1"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
|
-
"dev": "
|
|
51
|
+
"dev": "easypack dev",
|
|
52
52
|
"format": "biome format --write .",
|
|
53
53
|
"lint": "biome check .",
|
|
54
54
|
"build": "npm-run-all -nl build:*",
|
|
55
55
|
"build:clean": "rimraf dist/",
|
|
56
|
-
"build:js": "
|
|
57
|
-
"build:types": "pnpm types",
|
|
58
|
-
"types": "npm-run-all -nl types:*",
|
|
59
|
-
"types:src": "tsc --project tsconfig.build.json",
|
|
60
|
-
"test-types": "tsc --project tsconfig.test.json"
|
|
56
|
+
"build:js": "easypack build"
|
|
61
57
|
},
|
|
62
58
|
"module": "dist/index.esm.js",
|
|
63
59
|
"unpkg": "dist/index.min.js"
|
package/src/component.tsx
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Carousel Component
|
|
3
|
-
* 轮播组件
|
|
3
|
+
* 轮播组件 - 支持数据源绑定和事件交互
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { useState, useEffect, useCallback,
|
|
6
|
+
import { useState, useEffect, useCallback, useMemo, type CSSProperties } from 'react'
|
|
7
|
+
import { type MaterialComponet, useDataSource } from '@easy-editor/materials-shared'
|
|
7
8
|
import styles from './component.module.css'
|
|
8
9
|
|
|
9
10
|
export interface CarouselItem {
|
|
@@ -15,10 +16,7 @@ export interface CarouselItem {
|
|
|
15
16
|
link?: string
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
export interface CarouselProps {
|
|
19
|
-
ref?: Ref<HTMLDivElement>
|
|
20
|
-
/** 轮播项 */
|
|
21
|
-
items?: CarouselItem[]
|
|
19
|
+
export interface CarouselProps extends MaterialComponet {
|
|
22
20
|
/** 自动播放 */
|
|
23
21
|
autoPlay?: boolean
|
|
24
22
|
/** 自动播放间隔(毫秒) */
|
|
@@ -29,8 +27,16 @@ export interface CarouselProps {
|
|
|
29
27
|
showIndicators?: boolean
|
|
30
28
|
/** 是否循环播放 */
|
|
31
29
|
loop?: boolean
|
|
32
|
-
/**
|
|
33
|
-
|
|
30
|
+
/** 点击事件 */
|
|
31
|
+
onClick?: (e: React.MouseEvent) => void
|
|
32
|
+
/** 双击事件 */
|
|
33
|
+
onDoubleClick?: (e: React.MouseEvent) => void
|
|
34
|
+
/** 鼠标进入 */
|
|
35
|
+
onMouseEnter?: (e: React.MouseEvent) => void
|
|
36
|
+
/** 鼠标离开 */
|
|
37
|
+
onMouseLeave?: (e: React.MouseEvent) => void
|
|
38
|
+
/** 切换事件 */
|
|
39
|
+
onChange?: (index: number) => void
|
|
34
40
|
}
|
|
35
41
|
|
|
36
42
|
const DEFAULT_ITEMS: CarouselItem[] = [
|
|
@@ -55,37 +61,61 @@ const ChevronRight = () => (
|
|
|
55
61
|
|
|
56
62
|
export const Carousel: React.FC<CarouselProps> = ({
|
|
57
63
|
ref,
|
|
58
|
-
|
|
64
|
+
$data,
|
|
65
|
+
__dataSource,
|
|
59
66
|
autoPlay = true,
|
|
60
67
|
interval = 3000,
|
|
61
68
|
showNav = true,
|
|
62
69
|
showIndicators = true,
|
|
63
70
|
loop = true,
|
|
71
|
+
rotation,
|
|
72
|
+
opacity,
|
|
73
|
+
background,
|
|
64
74
|
style: externalStyle,
|
|
75
|
+
onClick,
|
|
76
|
+
onDoubleClick,
|
|
77
|
+
onMouseEnter,
|
|
78
|
+
onMouseLeave,
|
|
79
|
+
onChange,
|
|
65
80
|
}) => {
|
|
66
81
|
const [currentIndex, setCurrentIndex] = useState(0)
|
|
67
82
|
|
|
83
|
+
// 解析数据源
|
|
84
|
+
const dataSource = useDataSource($data, __dataSource)
|
|
85
|
+
const items = useMemo<CarouselItem[]>(() => {
|
|
86
|
+
if (dataSource.length > 0) {
|
|
87
|
+
return dataSource as CarouselItem[]
|
|
88
|
+
}
|
|
89
|
+
return DEFAULT_ITEMS
|
|
90
|
+
}, [dataSource])
|
|
91
|
+
|
|
68
92
|
const goToNext = useCallback(() => {
|
|
69
93
|
setCurrentIndex(prev => {
|
|
70
|
-
|
|
71
|
-
|
|
94
|
+
const nextIndex = prev >= items.length - 1 ? (loop ? 0 : prev) : prev + 1
|
|
95
|
+
if (nextIndex !== prev) {
|
|
96
|
+
onChange?.(nextIndex)
|
|
72
97
|
}
|
|
73
|
-
return
|
|
98
|
+
return nextIndex
|
|
74
99
|
})
|
|
75
|
-
}, [items.length, loop])
|
|
100
|
+
}, [items.length, loop, onChange])
|
|
76
101
|
|
|
77
102
|
const goToPrev = useCallback(() => {
|
|
78
103
|
setCurrentIndex(prev => {
|
|
79
|
-
|
|
80
|
-
|
|
104
|
+
const nextIndex = prev <= 0 ? (loop ? items.length - 1 : prev) : prev - 1
|
|
105
|
+
if (nextIndex !== prev) {
|
|
106
|
+
onChange?.(nextIndex)
|
|
81
107
|
}
|
|
82
|
-
return
|
|
108
|
+
return nextIndex
|
|
83
109
|
})
|
|
84
|
-
}, [items.length, loop])
|
|
85
|
-
|
|
86
|
-
const goToSlide = useCallback(
|
|
87
|
-
|
|
88
|
-
|
|
110
|
+
}, [items.length, loop, onChange])
|
|
111
|
+
|
|
112
|
+
const goToSlide = useCallback(
|
|
113
|
+
(index: number) => {
|
|
114
|
+
setCurrentIndex(index)
|
|
115
|
+
onChange?.(index)
|
|
116
|
+
},
|
|
117
|
+
[onChange],
|
|
118
|
+
)
|
|
89
119
|
|
|
90
120
|
// 自动播放
|
|
91
121
|
useEffect(() => {
|
|
@@ -101,8 +131,23 @@ export const Carousel: React.FC<CarouselProps> = ({
|
|
|
101
131
|
return null
|
|
102
132
|
}
|
|
103
133
|
|
|
134
|
+
const containerStyle: CSSProperties = {
|
|
135
|
+
transform: rotation ? `rotate(${rotation}deg)` : undefined,
|
|
136
|
+
opacity: opacity !== undefined ? opacity / 100 : undefined,
|
|
137
|
+
backgroundColor: background,
|
|
138
|
+
...externalStyle,
|
|
139
|
+
}
|
|
140
|
+
|
|
104
141
|
return (
|
|
105
|
-
<div
|
|
142
|
+
<div
|
|
143
|
+
className={styles.container}
|
|
144
|
+
onClick={onClick}
|
|
145
|
+
onDoubleClick={onDoubleClick}
|
|
146
|
+
onMouseEnter={onMouseEnter}
|
|
147
|
+
onMouseLeave={onMouseLeave}
|
|
148
|
+
ref={ref}
|
|
149
|
+
style={containerStyle}
|
|
150
|
+
>
|
|
106
151
|
<div className={styles.track} style={{ transform: `translateX(-${currentIndex * 100}%)` }}>
|
|
107
152
|
{items.map((item, index) => (
|
|
108
153
|
<div className={styles.slide} key={index}>
|
package/src/configure.ts
CHANGED
|
@@ -1,194 +1,97 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Carousel Configure
|
|
3
|
-
* 轮播组件配置
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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 {
|
|
1
|
+
/**
|
|
2
|
+
* Carousel Entry
|
|
3
|
+
* 轮播组件入口
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export { Carousel as component } from './component'
|
|
7
|
+
export { meta } from './meta'
|
package/src/meta.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
import type { ComponentMetadata } from '@easy-editor/core'
|
|
7
7
|
import { MaterialGroup } from '@easy-editor/materials-shared'
|
|
8
8
|
import { COMPONENT_NAME, PACKAGE_NAME } from './constants'
|
|
9
|
-
import configure from './configure'
|
|
10
|
-
import snippets from './snippets'
|
|
9
|
+
import { configure } from './configure'
|
|
10
|
+
import { snippets } from './snippets'
|
|
11
11
|
import pkg from '../package.json'
|
|
12
12
|
|
|
13
13
|
export const meta: ComponentMetadata = {
|
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 {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
+
]
|