@easy-editor/materials-dashboard-button 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,258 +1,136 @@
1
- /**
2
- * Button 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: 'text',
87
- title: '按钮文本',
88
- setter: 'StringSetter',
89
- extraProps: {
90
- defaultValue: '按钮',
91
- },
92
- },
93
- ],
94
- },
95
- {
96
- type: 'group',
97
- title: '样式',
98
- setter: {
99
- componentName: 'CollapseSetter',
100
- props: {
101
- icon: false,
102
- },
103
- },
104
- items: [
105
- {
106
- name: 'variant',
107
- title: '变体',
108
- setter: {
109
- componentName: 'SelectSetter',
110
- props: {
111
- options: [
112
- { label: '主要', value: 'primary' },
113
- { label: '次要', value: 'secondary' },
114
- { label: '轮廓', value: 'outline' },
115
- { label: '幽灵', value: 'ghost' },
116
- { label: '危险', value: 'danger' },
117
- ],
118
- },
119
- },
120
- extraProps: {
121
- defaultValue: 'primary',
122
- },
123
- },
124
- {
125
- name: 'size',
126
- title: '尺寸',
127
- setter: {
128
- componentName: 'SelectSetter',
129
- props: {
130
- options: [
131
- { label: '小', value: 'small' },
132
- { label: '中', value: 'medium' },
133
- { label: '', value: 'large' },
134
- ],
135
- },
136
- },
137
- extraProps: {
138
- defaultValue: 'medium',
139
- },
140
- },
141
- {
142
- name: 'glowEnable',
143
- title: '发光效果',
144
- setter: 'SwitchSetter',
145
- extraProps: {
146
- defaultValue: false,
147
- },
148
- },
149
- ],
150
- },
151
- {
152
- type: 'group',
153
- title: '链接',
154
- setter: {
155
- componentName: 'CollapseSetter',
156
- props: {
157
- icon: false,
158
- },
159
- },
160
- items: [
161
- {
162
- name: 'href',
163
- title: '链接地址',
164
- setter: 'StringSetter',
165
- },
166
- {
167
- name: 'target',
168
- title: '打开方式',
169
- setter: {
170
- componentName: 'SelectSetter',
171
- props: {
172
- options: [
173
- { label: '新窗口', value: '_blank' },
174
- { label: '当前窗口', value: '_self' },
175
- ],
176
- },
177
- },
178
- extraProps: {
179
- defaultValue: '_blank',
180
- },
181
- },
182
- ],
183
- },
184
- {
185
- type: 'group',
186
- title: '行为',
187
- setter: {
188
- componentName: 'CollapseSetter',
189
- props: {
190
- icon: false,
191
- },
192
- },
193
- items: [
194
- {
195
- name: 'disabled',
196
- title: '禁用',
197
- setter: 'SwitchSetter',
198
- extraProps: {
199
- defaultValue: false,
200
- },
201
- },
202
- {
203
- name: 'loading',
204
- title: '加载中',
205
- setter: 'SwitchSetter',
206
- extraProps: {
207
- defaultValue: false,
208
- },
209
- },
210
- {
211
- name: 'loadingText',
212
- title: '加载文本',
213
- setter: 'StringSetter',
214
- extraProps: {
215
- defaultValue: '加载中...',
216
- },
217
- },
218
- ],
219
- },
220
- ],
221
- },
222
- {
223
- type: 'group',
224
- key: 'data',
225
- title: '数据',
226
- items: [
227
- {
228
- name: 'dataBinding',
229
- title: '数据绑定',
230
- setter: 'DataBindingSetter',
231
- },
232
- ],
233
- },
234
- {
235
- type: 'group',
236
- key: 'advanced',
237
- title: '高级',
238
- items: [
239
- {
240
- name: 'condition',
241
- title: '显隐控制',
242
- setter: 'SwitchSetter',
243
- extraProps: {
244
- defaultValue: true,
245
- supportVariable: true,
246
- },
247
- },
248
- ],
249
- },
250
- ],
251
- },
252
- ],
253
- component: {},
254
- supports: {},
255
- advanced: {},
256
- }
257
-
258
- export default configure
1
+ /**
2
+ * Button 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: 'style',
22
+ title: '样式',
23
+ items: [
24
+ {
25
+ name: 'variant',
26
+ title: '变体',
27
+ setter: {
28
+ componentName: 'SelectSetter',
29
+ props: {
30
+ options: [
31
+ { label: '主要', value: 'primary' },
32
+ { label: '次要', value: 'secondary' },
33
+ { label: '轮廓', value: 'outline' },
34
+ { label: '幽灵', value: 'ghost' },
35
+ { label: '危险', value: 'danger' },
36
+ ],
37
+ },
38
+ },
39
+ extraProps: {
40
+ defaultValue: 'primary',
41
+ },
42
+ },
43
+ {
44
+ name: 'size',
45
+ title: '尺寸',
46
+ setter: {
47
+ componentName: 'SegmentedSetter',
48
+ props: {
49
+ options: [
50
+ { label: '', value: 'small' },
51
+ { label: '', value: 'medium' },
52
+ { label: '大', value: 'large' },
53
+ ],
54
+ },
55
+ },
56
+ extraProps: {
57
+ defaultValue: 'medium',
58
+ },
59
+ },
60
+ {
61
+ name: 'glowEnable',
62
+ title: '发光效果',
63
+ setter: 'SwitchSetter',
64
+ extraProps: {
65
+ defaultValue: false,
66
+ },
67
+ },
68
+ ],
69
+ },
70
+ // 行为 Tab
71
+ {
72
+ type: 'group',
73
+ key: 'behavior',
74
+ title: '行为',
75
+ items: [
76
+ {
77
+ name: 'href',
78
+ title: '链接地址',
79
+ setter: 'StringSetter',
80
+ },
81
+ {
82
+ name: 'target',
83
+ title: '打开方式',
84
+ setter: {
85
+ componentName: 'SegmentedSetter',
86
+ props: {
87
+ options: [
88
+ { label: '新窗口', value: '_blank' },
89
+ { label: '当前窗口', value: '_self' },
90
+ ],
91
+ },
92
+ },
93
+ extraProps: {
94
+ defaultValue: '_blank',
95
+ },
96
+ },
97
+ {
98
+ name: 'disabled',
99
+ title: '禁用',
100
+ setter: 'SwitchSetter',
101
+ extraProps: {
102
+ defaultValue: false,
103
+ },
104
+ },
105
+ {
106
+ name: 'loading',
107
+ title: '加载中',
108
+ setter: 'SwitchSetter',
109
+ extraProps: {
110
+ defaultValue: false,
111
+ },
112
+ },
113
+ {
114
+ name: 'loadingText',
115
+ title: '加载文本',
116
+ setter: 'StringSetter',
117
+ extraProps: {
118
+ defaultValue: '加载中...',
119
+ },
120
+ },
121
+ ],
122
+ },
123
+ ],
124
+ },
125
+ ],
126
+ {
127
+ padding: '6px 16px 12px',
128
+ },
129
+ )
130
+
131
+ /** 数据配置 */
132
+ const dataConfigGroup: FieldConfig = createDataConfigGroup([
133
+ { name: 'text', label: 'text', type: 'string', required: true, description: '按钮文本' },
134
+ ])
135
+
136
+ export const configure = createStandardConfigure(componentConfigGroup, dataConfigGroup)
package/src/index.tsx CHANGED
@@ -1,7 +1,7 @@
1
- /**
2
- * Button Entry
3
- * 按钮组件入口
4
- */
5
-
6
- export { Button as component } from './component'
7
- export { default as meta } from './meta'
1
+ /**
2
+ * Button Entry
3
+ * 按钮组件入口
4
+ */
5
+
6
+ export { Button 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,49 +1,54 @@
1
- /**
2
- * Button 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
- text: '主要按钮',
17
- variant: 'primary',
18
- size: 'medium',
19
- },
20
- $dashboard: {
21
- rect: {
22
- width: 120,
23
- height: 40,
24
- },
25
- },
26
- },
27
- },
28
- {
29
- title: '发光按钮',
30
- screenshot: '',
31
- schema: {
32
- componentName: COMPONENT_NAME,
33
- props: {
34
- text: '发光按钮',
35
- variant: 'outline',
36
- size: 'large',
37
- glowEnable: true,
38
- },
39
- $dashboard: {
40
- rect: {
41
- width: 140,
42
- height: 48,
43
- },
44
- },
45
- },
46
- },
47
- ]
48
-
49
- export default snippets
1
+ /**
2
+ * Button 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
+ export const snippets: Snippet[] = [
11
+ {
12
+ title: '主要按钮',
13
+ screenshot: '',
14
+ schema: {
15
+ componentName: COMPONENT_NAME,
16
+ title: '主要按钮',
17
+ props: {
18
+ $data: generateStaticDataSource({ text: '主要按钮' }),
19
+ variant: 'primary',
20
+ size: 'medium',
21
+ rotation: 0,
22
+ opacity: 100,
23
+ },
24
+ $dashboard: {
25
+ rect: {
26
+ width: 120,
27
+ height: 40,
28
+ },
29
+ },
30
+ },
31
+ },
32
+ {
33
+ title: '发光按钮',
34
+ screenshot: '',
35
+ schema: {
36
+ componentName: COMPONENT_NAME,
37
+ title: '发光按钮',
38
+ props: {
39
+ $data: generateStaticDataSource({ text: '发光按钮' }),
40
+ variant: 'outline',
41
+ size: 'large',
42
+ glowEnable: true,
43
+ rotation: 0,
44
+ opacity: 100,
45
+ },
46
+ $dashboard: {
47
+ rect: {
48
+ width: 140,
49
+ height: 48,
50
+ },
51
+ },
52
+ },
53
+ },
54
+ ]
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
+ }