@easy-editor/materials-dashboard-bar-chart 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 +34452 -0
  6. package/dist/component.esm.js.map +1 -0
  7. package/dist/component.js +34459 -0
  8. package/dist/component.js.map +1 -0
  9. package/dist/component.min.js +24 -0
  10. package/dist/component.min.js.map +1 -0
  11. package/dist/index.cjs +34870 -0
  12. package/dist/index.cjs.map +1 -0
  13. package/dist/index.esm.js +34867 -0
  14. package/dist/index.esm.js.map +1 -0
  15. package/dist/index.js +34874 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/index.min.js +24 -0
  18. package/dist/index.min.js.map +1 -0
  19. package/dist/meta.esm.js +441 -0
  20. package/dist/meta.esm.js.map +1 -0
  21. package/dist/meta.js +451 -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 +21 -0
  26. package/dist/src/configure.d.ts +7 -0
  27. package/dist/src/constants.d.ts +27 -0
  28. package/dist/src/index.d.ts +6 -0
  29. package/dist/src/meta.d.ts +3 -0
  30. package/dist/src/snippets.d.ts +3 -0
  31. package/package.json +68 -0
  32. package/rollup.config.js +212 -0
  33. package/src/component.module.css +16 -0
  34. package/src/component.tsx +260 -0
  35. package/src/configure.ts +365 -0
  36. package/src/constants.ts +38 -0
  37. package/src/index.tsx +7 -0
  38. package/src/meta.ts +23 -0
  39. package/src/snippets.ts +79 -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,365 @@
1
+ /**
2
+ * Bar Chart Configure
3
+ * 柱状图组件配置
4
+ */
5
+
6
+ import type { Configure } from '@easy-editor/core'
7
+
8
+ 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: 'data',
87
+ title: '数据',
88
+ setter: 'JsonSetter',
89
+ },
90
+ {
91
+ name: 'xField',
92
+ title: 'X轴字段',
93
+ setter: 'StringSetter',
94
+ extraProps: {
95
+ defaultValue: 'name',
96
+ },
97
+ },
98
+ {
99
+ name: 'yFields',
100
+ title: 'Y轴字段',
101
+ setter: {
102
+ componentName: 'ArraySetter',
103
+ props: {
104
+ itemSetter: 'StringSetter',
105
+ },
106
+ },
107
+ },
108
+ ],
109
+ },
110
+ {
111
+ type: 'group',
112
+ title: '坐标轴',
113
+ setter: {
114
+ componentName: 'CollapseSetter',
115
+ props: {
116
+ icon: false,
117
+ },
118
+ },
119
+ items: [
120
+ {
121
+ name: 'xAxisLabel',
122
+ title: 'X轴标签',
123
+ setter: 'StringSetter',
124
+ },
125
+ {
126
+ name: 'yAxisLabel',
127
+ title: 'Y轴标签',
128
+ setter: 'StringSetter',
129
+ },
130
+ {
131
+ name: 'xAxisVisible',
132
+ title: '显示X轴',
133
+ setter: 'SwitchSetter',
134
+ extraProps: {
135
+ defaultValue: true,
136
+ },
137
+ },
138
+ {
139
+ name: 'yAxisVisible',
140
+ title: '显示Y轴',
141
+ setter: 'SwitchSetter',
142
+ extraProps: {
143
+ defaultValue: true,
144
+ },
145
+ },
146
+ {
147
+ name: 'axisLabelRotate',
148
+ title: '标签旋转',
149
+ setter: {
150
+ componentName: 'SliderSetter',
151
+ props: {
152
+ min: -90,
153
+ max: 90,
154
+ step: 15,
155
+ suffix: '°',
156
+ },
157
+ },
158
+ extraProps: {
159
+ defaultValue: 0,
160
+ },
161
+ },
162
+ ],
163
+ },
164
+ {
165
+ type: 'group',
166
+ title: '数值格式',
167
+ setter: {
168
+ componentName: 'CollapseSetter',
169
+ props: {
170
+ icon: false,
171
+ },
172
+ },
173
+ items: [
174
+ {
175
+ name: 'valuePrefix',
176
+ title: '前缀',
177
+ setter: 'StringSetter',
178
+ },
179
+ {
180
+ name: 'valueSuffix',
181
+ title: '后缀',
182
+ setter: 'StringSetter',
183
+ },
184
+ {
185
+ name: 'valueDecimals',
186
+ title: '小数位数',
187
+ setter: {
188
+ componentName: 'NumberSetter',
189
+ props: {
190
+ suffix: '位',
191
+ },
192
+ },
193
+ extraProps: {
194
+ defaultValue: 0,
195
+ },
196
+ },
197
+ {
198
+ name: 'valueSeparator',
199
+ title: '千分位分隔',
200
+ setter: 'SwitchSetter',
201
+ extraProps: {
202
+ defaultValue: false,
203
+ },
204
+ },
205
+ ],
206
+ },
207
+ {
208
+ type: 'group',
209
+ title: '样式',
210
+ setter: {
211
+ componentName: 'CollapseSetter',
212
+ props: {
213
+ icon: false,
214
+ },
215
+ },
216
+ items: [
217
+ {
218
+ name: 'layout',
219
+ title: '布局方向',
220
+ setter: {
221
+ componentName: 'SegmentedSetter',
222
+ props: {
223
+ options: [
224
+ { label: '垂直', value: 'vertical' },
225
+ { label: '水平', value: 'horizontal' },
226
+ ],
227
+ },
228
+ },
229
+ extraProps: {
230
+ defaultValue: 'vertical',
231
+ },
232
+ },
233
+ {
234
+ name: 'stacked',
235
+ title: '堆叠模式',
236
+ setter: 'SwitchSetter',
237
+ extraProps: {
238
+ defaultValue: false,
239
+ },
240
+ },
241
+ {
242
+ name: 'gradient',
243
+ title: '渐变填充',
244
+ setter: 'SwitchSetter',
245
+ extraProps: {
246
+ defaultValue: true,
247
+ },
248
+ },
249
+ {
250
+ name: 'borderRadius',
251
+ title: '圆角',
252
+ setter: {
253
+ componentName: 'SliderSetter',
254
+ props: {
255
+ min: 0,
256
+ max: 20,
257
+ step: 1,
258
+ suffix: 'px',
259
+ },
260
+ },
261
+ extraProps: {
262
+ defaultValue: 4,
263
+ },
264
+ },
265
+ {
266
+ name: 'barGap',
267
+ title: '柱间距',
268
+ setter: {
269
+ componentName: 'SliderSetter',
270
+ props: {
271
+ min: 0,
272
+ max: 20,
273
+ step: 1,
274
+ suffix: 'px',
275
+ },
276
+ },
277
+ extraProps: {
278
+ defaultValue: 4,
279
+ },
280
+ },
281
+ {
282
+ name: 'colors',
283
+ title: '颜色',
284
+ setter: {
285
+ componentName: 'ArraySetter',
286
+ props: {
287
+ itemSetter: 'ColorSetter',
288
+ },
289
+ },
290
+ },
291
+ {
292
+ name: 'showGrid',
293
+ title: '显示网格',
294
+ setter: 'SwitchSetter',
295
+ extraProps: {
296
+ defaultValue: true,
297
+ },
298
+ },
299
+ {
300
+ name: 'showLegend',
301
+ title: '显示图例',
302
+ setter: 'SwitchSetter',
303
+ extraProps: {
304
+ defaultValue: true,
305
+ },
306
+ },
307
+ {
308
+ name: 'legendPosition',
309
+ title: '图例位置',
310
+ setter: {
311
+ componentName: 'SelectSetter',
312
+ props: {
313
+ options: [
314
+ { label: '顶部', value: 'top' },
315
+ { label: '底部', value: 'bottom' },
316
+ { label: '左侧', value: 'left' },
317
+ { label: '右侧', value: 'right' },
318
+ ],
319
+ },
320
+ },
321
+ extraProps: {
322
+ defaultValue: 'bottom',
323
+ },
324
+ },
325
+ ],
326
+ },
327
+ ],
328
+ },
329
+ {
330
+ type: 'group',
331
+ key: 'data',
332
+ title: '数据',
333
+ items: [
334
+ {
335
+ name: 'dataBinding',
336
+ title: '数据绑定',
337
+ setter: 'DataBindingSetter',
338
+ },
339
+ ],
340
+ },
341
+ {
342
+ type: 'group',
343
+ key: 'advanced',
344
+ title: '高级',
345
+ items: [
346
+ {
347
+ name: 'condition',
348
+ title: '显隐控制',
349
+ setter: 'SwitchSetter',
350
+ extraProps: {
351
+ defaultValue: true,
352
+ supportVariable: true,
353
+ },
354
+ },
355
+ ],
356
+ },
357
+ ],
358
+ },
359
+ ],
360
+ component: {},
361
+ supports: {},
362
+ advanced: {},
363
+ }
364
+
365
+ export default configure
@@ -0,0 +1,38 @@
1
+ /**
2
+ * 物料常量配置
3
+ * 统一管理全局变量名等配置,确保 meta.ts 和 rollup.config.js 使用相同的值
4
+ */
5
+
6
+ /**
7
+ * UMD 全局变量基础名称
8
+ */
9
+ export const COMPONENT_NAME = 'EasyEditorMaterialsBarChart'
10
+
11
+ /**
12
+ * 包名
13
+ */
14
+ export const PACKAGE_NAME = '@easy-editor/materials-dashboard-bar-chart'
15
+
16
+ /**
17
+ * 默认颜色
18
+ */
19
+ export const DEFAULT_COLORS = ['#00d4ff', '#00ff88', '#ff6b6b', '#ffd93d', '#6bcbff', '#c56bff']
20
+
21
+ /**
22
+ * 数据点类型
23
+ */
24
+ export interface DataPoint {
25
+ name: string
26
+ [key: string]: number | string | undefined
27
+ }
28
+
29
+ /**
30
+ * 默认数据
31
+ */
32
+ export const DEFAULT_DATA: DataPoint[] = [
33
+ { name: 'A', value1: 120, value2: 80 },
34
+ { name: 'B', value1: 200, value2: 120 },
35
+ { name: 'C', value1: 150, value2: 100 },
36
+ { name: 'D', value1: 280, value2: 180 },
37
+ { name: 'E', value1: 220, value2: 140 },
38
+ ]
package/src/index.tsx ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * BarChart Entry
3
+ * 柱状图组件入口
4
+ */
5
+
6
+ export { default as component } from './component'
7
+ export { default as meta } from './meta'
package/src/meta.ts ADDED
@@ -0,0 +1,23 @@
1
+ import type { ComponentMetadata } from '@easy-editor/core'
2
+ import { MaterialGroup } from '@easy-editor/materials-shared'
3
+ import { COMPONENT_NAME, PACKAGE_NAME } from './constants'
4
+ import configure from './configure'
5
+ import snippets from './snippets'
6
+ import pkg from '../package.json'
7
+
8
+ const meta: ComponentMetadata = {
9
+ componentName: COMPONENT_NAME,
10
+ title: '柱状图',
11
+ group: MaterialGroup.CHART,
12
+ devMode: 'proCode',
13
+ npm: {
14
+ package: PACKAGE_NAME,
15
+ version: pkg.version,
16
+ globalName: COMPONENT_NAME,
17
+ componentName: COMPONENT_NAME,
18
+ },
19
+ snippets,
20
+ configure,
21
+ }
22
+
23
+ export default meta
@@ -0,0 +1,79 @@
1
+ import type { Snippet } from '@easy-editor/core'
2
+ import { COMPONENT_NAME, DEFAULT_DATA } from './constants'
3
+
4
+ const snippets: Snippet[] = [
5
+ {
6
+ title: '柱状图',
7
+ screenshot: '',
8
+ schema: {
9
+ componentName: COMPONENT_NAME,
10
+ props: {
11
+ data: DEFAULT_DATA,
12
+ xField: 'name',
13
+ yFields: ['value1', 'value2'],
14
+ layout: 'vertical',
15
+ stacked: false,
16
+ gradient: true,
17
+ borderRadius: 4,
18
+ showGrid: true,
19
+ showLegend: true,
20
+ },
21
+ $dashboard: {
22
+ rect: {
23
+ width: 400,
24
+ height: 300,
25
+ },
26
+ },
27
+ },
28
+ },
29
+ {
30
+ title: '堆叠柱状图',
31
+ screenshot: '',
32
+ schema: {
33
+ componentName: COMPONENT_NAME,
34
+ props: {
35
+ data: DEFAULT_DATA,
36
+ xField: 'name',
37
+ yFields: ['value1', 'value2'],
38
+ layout: 'vertical',
39
+ stacked: true,
40
+ gradient: true,
41
+ borderRadius: 4,
42
+ showGrid: true,
43
+ showLegend: true,
44
+ },
45
+ $dashboard: {
46
+ rect: {
47
+ width: 400,
48
+ height: 300,
49
+ },
50
+ },
51
+ },
52
+ },
53
+ {
54
+ title: '水平柱状图',
55
+ screenshot: '',
56
+ schema: {
57
+ componentName: COMPONENT_NAME,
58
+ props: {
59
+ data: DEFAULT_DATA,
60
+ xField: 'name',
61
+ yFields: ['value1'],
62
+ layout: 'horizontal',
63
+ stacked: false,
64
+ gradient: true,
65
+ borderRadius: 4,
66
+ showGrid: true,
67
+ showLegend: false,
68
+ },
69
+ $dashboard: {
70
+ rect: {
71
+ width: 400,
72
+ height: 250,
73
+ },
74
+ },
75
+ },
76
+ },
77
+ ]
78
+
79
+ 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
+ })