@easy-editor/materials-dashboard-button 0.0.2

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.
Files changed (44) hide show
  1. package/.vite/plugins/vite-plugin-external-deps.ts +224 -0
  2. package/.vite/plugins/vite-plugin-material-dev.ts +218 -0
  3. package/CHANGELOG.md +7 -0
  4. package/LICENSE +9 -0
  5. package/dist/component.esm.js +97 -0
  6. package/dist/component.esm.js.map +1 -0
  7. package/dist/component.js +106 -0
  8. package/dist/component.js.map +1 -0
  9. package/dist/component.min.js +2 -0
  10. package/dist/component.min.js.map +1 -0
  11. package/dist/index.cjs +394 -0
  12. package/dist/index.cjs.map +1 -0
  13. package/dist/index.esm.js +391 -0
  14. package/dist/index.esm.js.map +1 -0
  15. package/dist/index.js +399 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/index.min.js +2 -0
  18. package/dist/index.min.js.map +1 -0
  19. package/dist/meta.esm.js +298 -0
  20. package/dist/meta.esm.js.map +1 -0
  21. package/dist/meta.js +309 -0
  22. package/dist/meta.js.map +1 -0
  23. package/dist/meta.min.js +2 -0
  24. package/dist/meta.min.js.map +1 -0
  25. package/dist/src/component.d.ts +26 -0
  26. package/dist/src/configure.d.ts +7 -0
  27. package/dist/src/constants.d.ts +16 -0
  28. package/dist/src/index.d.ts +6 -0
  29. package/dist/src/meta.d.ts +7 -0
  30. package/dist/src/snippets.d.ts +7 -0
  31. package/package.json +64 -0
  32. package/rollup.config.js +222 -0
  33. package/src/component.module.css +119 -0
  34. package/src/component.tsx +80 -0
  35. package/src/configure.ts +258 -0
  36. package/src/constants.ts +18 -0
  37. package/src/index.tsx +7 -0
  38. package/src/meta.ts +28 -0
  39. package/src/snippets.ts +49 -0
  40. package/src/type.d.ts +8 -0
  41. package/tsconfig.build.json +12 -0
  42. package/tsconfig.json +9 -0
  43. package/tsconfig.test.json +7 -0
  44. package/vite.config.ts +54 -0
@@ -0,0 +1,258 @@
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
@@ -0,0 +1,18 @@
1
+ /**
2
+ * 物料常量配置
3
+ * 统一管理全局变量名等配置,确保 meta.ts 和 rollup.config.js 使用相同的值
4
+ */
5
+
6
+ /**
7
+ * UMD 全局变量基础名称
8
+ * 用于构建:
9
+ * - 元数据:${GLOBAL_NAME}Meta (例如: EasyEditorMaterialsButtonMeta)
10
+ * - 组件:${GLOBAL_NAME}Component (例如: EasyEditorMaterialsButtonComponent)
11
+ * - 完整构建:${GLOBAL_NAME} (例如: EasyEditorMaterialsButton)
12
+ */
13
+ export const COMPONENT_NAME = 'EasyEditorMaterialsButton'
14
+
15
+ /**
16
+ * 包名
17
+ */
18
+ export const PACKAGE_NAME = '@easy-editor/materials-dashboard-button'
package/src/index.tsx ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Button Entry
3
+ * 按钮组件入口
4
+ */
5
+
6
+ export { Button as component } from './component'
7
+ export { default as meta } from './meta'
package/src/meta.ts ADDED
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Button 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.INTERACTION,
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
@@ -0,0 +1,49 @@
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
package/src/type.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * CSS Modules Type Declarations
3
+ */
4
+
5
+ declare module '*.module.css' {
6
+ const classes: { readonly [key: string]: string }
7
+ export default classes
8
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "../../../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "jsx": "react-jsx",
5
+ "strictPropertyInitialization": false,
6
+ "outDir": "./dist",
7
+ "skipLibCheck": true,
8
+ "esModuleInterop": true,
9
+ "allowSyntheticDefaultImports": true
10
+ },
11
+ "include": ["./src"]
12
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "compilerOptions": {
3
+ "jsx": "react-jsx",
4
+ "esModuleInterop": true,
5
+ "allowSyntheticDefaultImports": true
6
+ },
7
+ "extends": "./tsconfig.build.json",
8
+ "include": ["./src", "./test"]
9
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "./tsconfig.build.json",
3
+ "compilerOptions": {
4
+ "noEmit": true
5
+ },
6
+ "include": ["./src"]
7
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Vite Configuration for Material Development
3
+ * 物料开发 Vite 配置
4
+ */
5
+
6
+ import { defineConfig } from 'vite'
7
+ import react from '@vitejs/plugin-react'
8
+ import { materialDevPlugin } from './.vite/plugins/vite-plugin-material-dev'
9
+ import { externalDeps } from './.vite/plugins/vite-plugin-external-deps'
10
+
11
+ export default defineConfig({
12
+ plugins: [
13
+ react(),
14
+ // 外部化 React/ReactDOM,使用父应用提供的实例
15
+ externalDeps({
16
+ externals: ['react', 'react-dom', 'react/jsx-runtime', '@easy-editor/core'],
17
+ globals: {
18
+ react: 'React',
19
+ 'react-dom': 'ReactDOM',
20
+ 'react/jsx-runtime': 'jsxRuntime',
21
+ '@easy-editor/core': 'EasyEditorCore',
22
+ },
23
+ }),
24
+ materialDevPlugin({
25
+ entry: '/src/index.tsx',
26
+ }),
27
+ ],
28
+ server: {
29
+ port: 5001,
30
+ host: 'localhost',
31
+ cors: true,
32
+ hmr: {
33
+ port: 5001,
34
+ },
35
+ },
36
+ build: {
37
+ target: 'esnext',
38
+ rollupOptions: {
39
+ // 确保生产构建也外部化这些依赖
40
+ external: ['react', 'react-dom', 'react/jsx-runtime', '@easy-editor/core'],
41
+ output: {
42
+ globals: {
43
+ react: 'React',
44
+ 'react-dom': 'ReactDOM',
45
+ 'react/jsx-runtime': 'jsxRuntime',
46
+ '@easy-editor/core': 'EasyEditorCore',
47
+ },
48
+ },
49
+ },
50
+ },
51
+ resolve: {
52
+ dedupe: ['react', 'react-dom'],
53
+ },
54
+ })