neo-cmp-cli 1.1.8 → 1.1.9

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 (50) hide show
  1. package/package.json +1 -1
  2. package/src/cmpUtils/createCommonModulesCode.js +61 -0
  3. package/src/cmpUtils/getCmpPreview.js +3 -1
  4. package/src/module/index.js +10 -0
  5. package/src/module/main.js +33 -10
  6. package/src/module/neoInitByCopy.js +8 -0
  7. package/src/neo/neoRequire.js +14 -2
  8. package/src/template/antd-custom-cmp-template/neo.config.js +6 -0
  9. package/src/template/antd-custom-cmp-template/src/components/data-dashboard/model.ts +2 -2
  10. package/src/template/antd-custom-cmp-template/src/components/data-dashboard/style.scss +377 -119
  11. package/src/template/echarts-custom-cmp-template/README.md +91 -0
  12. package/src/template/echarts-custom-cmp-template/neo.config.js +117 -0
  13. package/src/template/echarts-custom-cmp-template/package.json +60 -0
  14. package/src/template/echarts-custom-cmp-template/src/components/chart-widget/README.md +186 -0
  15. package/src/template/echarts-custom-cmp-template/src/components/chart-widget/index.tsx +724 -0
  16. package/src/template/echarts-custom-cmp-template/src/components/chart-widget/model.ts +153 -0
  17. package/src/template/echarts-custom-cmp-template/src/components/chart-widget/style.scss +209 -0
  18. package/src/template/neo-custom-cmp-template/.prettierrc.js +12 -0
  19. package/src/template/neo-custom-cmp-template/commitlint.config.js +59 -0
  20. package/src/template/{echart-custom-cmp-template → neo-custom-cmp-template}/package.json +7 -5
  21. package/src/template/neo-custom-cmp-template/public/css/base.css +283 -0
  22. package/src/template/neo-custom-cmp-template/public/scripts/app/bluebird.js +6679 -0
  23. package/src/template/neo-custom-cmp-template/public/template.html +13 -0
  24. package/src/template/neo-custom-cmp-template/src/assets/css/common.scss +127 -0
  25. package/src/template/neo-custom-cmp-template/src/assets/css/mixin.scss +47 -0
  26. package/src/template/neo-custom-cmp-template/src/components/info-card/index.tsx +69 -0
  27. package/src/template/neo-custom-cmp-template/src/components/info-card/model.ts +78 -0
  28. package/src/template/neo-custom-cmp-template/src/components/info-card/style.scss +105 -0
  29. package/src/template/neo-custom-cmp-template/src/components/neo-entity-grid/README.md +128 -0
  30. package/src/template/neo-custom-cmp-template/src/components/neo-entity-grid/index.tsx +295 -0
  31. package/src/template/neo-custom-cmp-template/src/components/neo-entity-grid/model.ts +94 -0
  32. package/src/template/neo-custom-cmp-template/src/components/neo-entity-grid/style.scss +127 -0
  33. package/src/template/neo-custom-cmp-template/tsconfig.json +68 -0
  34. package/src/template/echart-custom-cmp-template/src/components/list-widget/README.md +0 -2
  35. package/src/template/echart-custom-cmp-template/src/components/list-widget/index.tsx +0 -208
  36. package/src/template/echart-custom-cmp-template/src/components/list-widget/model.ts +0 -90
  37. package/src/template/echart-custom-cmp-template/src/components/list-widget/style.scss +0 -350
  38. /package/src/template/{echart-custom-cmp-template → echarts-custom-cmp-template}/.prettierrc.js +0 -0
  39. /package/src/template/{echart-custom-cmp-template → echarts-custom-cmp-template}/commitlint.config.js +0 -0
  40. /package/src/template/{echart-custom-cmp-template → echarts-custom-cmp-template}/public/css/base.css +0 -0
  41. /package/src/template/{echart-custom-cmp-template → echarts-custom-cmp-template}/public/scripts/app/bluebird.js +0 -0
  42. /package/src/template/{echart-custom-cmp-template → echarts-custom-cmp-template}/public/template.html +0 -0
  43. /package/src/template/{echart-custom-cmp-template → echarts-custom-cmp-template}/src/assets/css/common.scss +0 -0
  44. /package/src/template/{echart-custom-cmp-template → echarts-custom-cmp-template}/src/assets/css/mixin.scss +0 -0
  45. /package/src/template/{echart-custom-cmp-template → echarts-custom-cmp-template}/src/components/info-card/index.tsx +0 -0
  46. /package/src/template/{echart-custom-cmp-template → echarts-custom-cmp-template}/src/components/info-card/model.ts +0 -0
  47. /package/src/template/{echart-custom-cmp-template → echarts-custom-cmp-template}/src/components/info-card/style.scss +0 -0
  48. /package/src/template/{echart-custom-cmp-template → echarts-custom-cmp-template}/tsconfig.json +0 -0
  49. /package/src/template/{echart-custom-cmp-template → neo-custom-cmp-template}/README.md +0 -0
  50. /package/src/template/{echart-custom-cmp-template → neo-custom-cmp-template}/neo.config.js +0 -0
@@ -0,0 +1,91 @@
1
+ ### 目录说明
2
+ - src: 自定义组件源码;
3
+ - src/assets: 存放组件静态资源,比如 css、img等;
4
+ - src/components: 存放自定义组件代码,每个自定义组件以自身名称(cmpType 数值)作为目录进行存放;
5
+ - src/components/info-card/: 信息卡片组件;
6
+ - src/components/chart-widget/: 酷炫图表组件(新增);
7
+ - neo.config.js: neo-cmp-cli 配置文件。
8
+
9
+ ### 🎨 酷炫图表组件 (Chart Widget)
10
+
11
+ 这是一个功能丰富的图表组件,基于 ECharts 5.x 构建,支持多种图表类型和丰富的配置选项。
12
+
13
+ #### 特性
14
+ - **8种图表类型**: 折线图、柱状图、饼图、散点图、雷达图、仪表盘、漏斗图、桑基图
15
+ - **现代化设计**: 渐变背景、毛玻璃效果、响应式布局
16
+ - **丰富配置**: JSON AMIS 表单配置,支持主题切换、尺寸调整、交互控制
17
+ - **数据驱动**: 支持多种数据源,实时数据更新
18
+
19
+ #### 快速开始
20
+ ```bash
21
+ # 安装依赖
22
+ ./install-deps.sh
23
+
24
+ # 预览图表组件
25
+ npm run preview --cmpType=chart-widget
26
+
27
+ # 查看演示页面
28
+ npm run preview --cmpType=demo
29
+ ```
30
+
31
+ #### 组件使用
32
+ ```tsx
33
+ import ChartWidget from './components/chart-widget';
34
+
35
+ <ChartWidget
36
+ chartType="line"
37
+ title="销售趋势"
38
+ subtitle="2024年数据"
39
+ width={800}
40
+ height={400}
41
+ mockData={{
42
+ xAxis: ['1月', '2月', '3月', '4月', '5月', '6月'],
43
+ series: [{
44
+ name: '销售额',
45
+ data: [120, 200, 150, 80, 70, 110]
46
+ }]
47
+ }}
48
+ />
49
+ ```
50
+
51
+ 更多详细信息请查看 [图表组件文档](./src/components/chart-widget/README.md)。
52
+
53
+ ### 组件开发规范
54
+ - 存放在 src/components 目录下的自定义组件,默认 index 为自定义组件源码入口文件,register.[tj]s 为注册 自定义组件的脚本文件,model.[tj]s 为自定义组件的模型文件(对接页面设计器需要);
55
+ - 当 neo.config.js 中的 entry 为空或者不存在时,cli 将根据 src/components 目录下的自定义组件结构生成对应的 entry 配置(可在命令控制台查看生成的 entry 配置);
56
+ - 自定义组件中可用的配置项类型 请见 [当前可用表单项](https://github.com/wibetter/neo-register/blob/master/docs/FormItemType.md);
57
+ - 自定义组件最外层请设置一个唯一的 ClassName(比如 xx-cmpType-container),所有内容样式请放在该 ClassName 中,避免自定义组件样式相互干扰;
58
+ - 默认开启代码规范检测(含样式内容),如需关闭,请调整 neo.config.js 相关配置;
59
+ - 请使用 react 16版本。
60
+
61
+ ### 自定义组件注册器使用说明
62
+ - [neo-register 使用说明](https://www.npmjs.com/package/neo-register?activeTab=readme)
63
+ 备注:预览、调试(linkDebug)和构建发布时 cli 会自动创建对应的注册文件(含 neo-register 的使用),用户无需关注 neo-register。
64
+
65
+ ### 开发说明
66
+
67
+ 1. **安装依赖**
68
+ ```bash
69
+ $ npm i 或者 yarn
70
+ ```
71
+
72
+ 2. **preview: 组件预览模式(带热更新)**
73
+ > preview模式:用于预览自定义组件内容。
74
+ ```bash
75
+ $ npm run preview
76
+ ```
77
+
78
+ 3. **linkDebug: 外链调试(在线上页面设计器端预览自定义组件)**
79
+ > linkDebug模式:用于在线上页面设计器中预览和调试自定义组件。
80
+ ```bash
81
+ $ npm run linkDebug
82
+ ```
83
+
84
+ 4. **发布到对象存储服务中**
85
+ > 需要确保 package.json 中的 name 值唯一,version 值不重复。
86
+ ```bash
87
+ $ npm run publish2oss
88
+ ```
89
+
90
+ ### 配置项说明(neo-cmp-cli)
91
+ [请查看neo-cmp-cli](https://github.com/wibetter/neo-cmp-cli)
@@ -0,0 +1,117 @@
1
+ 'use strict';
2
+ const path = require('path');
3
+
4
+ // 统一路径解析
5
+ function resolve(dir) {
6
+ return path.resolve(__dirname, dir);
7
+ }
8
+
9
+ // 包括生产和开发的环境配置信息
10
+ module.exports = {
11
+ settings: {
12
+ enableESLint: true, // 调试模式是否开启ESLint,默认开启ESLint检测代码格式
13
+ enableESLintFix: true, // 是否自动修正代码格式,默认不自动修正
14
+ enableStyleLint: false, // 是否开启StyleLint,默认开启ESLint检测代码格式
15
+ enableStyleLintFix: false, // 是否需要StyleLint自动修正代码格式
16
+ },
17
+ webpack: {
18
+ target: ['web', 'es5'], // 指定目标环境为 web 和 es5,确保兼容性
19
+ resolve: {
20
+ // webpack的resolve配置
21
+ extensions: ['.js', '.jsx', '.ts', '.tsx', '.umd.js', '.min.js', '.json'], // 用于配置webpack在尝试过程中用到的后缀列表
22
+ alias: {
23
+ '@': resolve('src'),
24
+ $assets: resolve('src/assets'),
25
+ $public: resolve('public'),
26
+ },
27
+ },
28
+ // sassResources中的sass文件会自动注入每一个sass文件中
29
+ sassResources: [
30
+ resolve('./src/assets/css/common.scss'),
31
+ resolve('./src/assets/css/mixin.scss'),
32
+ ],
33
+ // createDeclaration: true, // 打包时是否创建ts声明文件
34
+ ignoreNodeModules: false, // 打包时是否忽略 node_modules
35
+ allowList: [], // ignoreNodeModules为true时生效
36
+ projectDir: ['src'],
37
+ // template: resolve('./public/template.html'), // 自定义html模板
38
+ // plugins: [],
39
+ // babelPlugins: [],
40
+ },
41
+ neoCommonModule: {
42
+ // neoExports: ['echarts'], // 自定义组件 共享出来的模块,支持数组和对象
43
+ neoExports: {
44
+ 'neo/chart-widget': require('./src/components/chart-widget'),
45
+ 'neo-register': require('neo-register'),
46
+ },
47
+ neoExternals: ['echarts'], // 自定义组件 需要剔除的模块,仅支持数组写法
48
+ },
49
+ preview: {
50
+ // 用于开启本地预览模式的相关配置信息
51
+ /*
52
+ 【特别说明】以下配置项都自带默认值,非必填。如需自定义请自行配置。
53
+ entry: { // 根据 src/components 目录下的文件自动生成 entry 相关配置
54
+ // 本地预览自定义组件内容
55
+ index: './src/preview.jsx',
56
+ },
57
+ NODE_ENV: 'development',
58
+ port: 80, // 设置基础端口,如果被占用则自动寻找可用端口
59
+ assetsPublicPath: '/', // 设置静态资源的引用路径(根域名+路径)
60
+ assetsSubDirectory: '',
61
+ hostname: 'localhost',
62
+ proxyTable: {
63
+ '/apiTest': {
64
+ target: 'http://api-test.com.cn', // 不支持跨域的接口根地址
65
+ ws: true,
66
+ changeOrigin: true,
67
+ },
68
+ },
69
+ */
70
+ },
71
+ linkDebug: {
72
+ // 用于开启本地调试模式的相关配置信息
73
+ /*
74
+ 【特别说明】以下配置项都自带默认值,非必填。如需自定义请自行配置。
75
+ entry: { // 根据 src/components 目录下的文件自动生成 entry 相关配置
76
+ // 外链调试(在线上页面设计器端预览自定义组件)
77
+ index: [
78
+ './src/components/info-card/register.ts',
79
+ './src/components/info-card/model.ts',
80
+ ],
81
+ },
82
+ NODE_ENV: 'development',
83
+ port: 80, // 设置基础端口,如果被占用则自动寻找可用端口
84
+ closeHotReload: true, // 是否关闭热更新
85
+ assetsPublicPath: '/', // 设置静态资源的引用路径(根域名+路径)
86
+ assetsSubDirectory: '',
87
+ hostname: 'localhost',
88
+ proxyTable: {
89
+ '/apiTest': {
90
+ target: 'http://api-test.com.cn', // 不支持跨域的接口根地址
91
+ ws: true,
92
+ changeOrigin: true,
93
+ },
94
+ }
95
+ */
96
+ },
97
+ publish2oss: {
98
+ // 用于构建并发布至 OSS 的相关配置
99
+ /*
100
+ 【特别说明】以下配置项都自带默认值,非必填。如需自定义请自行配置。
101
+ NODE_ENV: 'production',
102
+ entry: { // 根据 src/components 目录下的文件自动生成 entry 相关配置
103
+ InfoCardModel: './src/components/info-card/model.ts',
104
+ infoCard: './src/components/info-card/register.ts'
105
+ },
106
+ cssExtract: false, // 不额外提取css文件
107
+ ossType: 'ali', // oss类型:ali、baidu
108
+ ossConfig: {
109
+ endpoint: 'https://oss-cn-beijing.aliyuncs.com',
110
+ AccessKeyId: 'xxx',
111
+ AccessKeySecret: 'xx',
112
+ bucket: 'neo-widgets' // 存储桶名称
113
+ },
114
+ assetsRoot: resolve('dist') // 上传指定目录下的脚本文件
115
+ */
116
+ },
117
+ };
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "echarts-custom-cmp-template",
3
+ "version": "1.1.0",
4
+ "description": "neo自定义组件模板(react&ts技术栈)",
5
+ "keywords": [
6
+ "自定义组件模板",
7
+ "react&ts技术栈",
8
+ "neo自定义组件"
9
+ ],
10
+ "author": "wibetter",
11
+ "license": "MIT",
12
+ "scripts": {
13
+ "preview": "neo preview --cmpType=chart-widget",
14
+ "linkDebug": "neo linkDebug",
15
+ "publish2oss": "neo publish2oss",
16
+ "format": "prettier --write \"src/**/**/*.{js,jsx,ts,tsx,vue,scss,json}\""
17
+ },
18
+ "files": [
19
+ "dist/*"
20
+ ],
21
+ "husky": {
22
+ "hooks": {
23
+ "pre-commit": "lint-staged",
24
+ "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
25
+ }
26
+ },
27
+ "lint-staged": {
28
+ "src/**/**/*.{js,jsx,ts,tsx,vue,scss,json}": [
29
+ "prettier --write"
30
+ ]
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://git@github.com:wibetter/echarts-custom-cmp-template.git"
35
+ },
36
+ "bugs": {
37
+ "url": "https://github.com/wibetter/echarts-custom-cmp-template/issues"
38
+ },
39
+ "dependencies": {
40
+ "neo-register": "^1.0.2",
41
+ "react": "^16.9.0",
42
+ "react-dom": "^16.9.0",
43
+ "echarts": "^5.5.1"
44
+ },
45
+ "devDependencies": {
46
+ "@commitlint/cli": "^8.3.5",
47
+ "@commitlint/config-conventional": "^9.1.1",
48
+ "@types/react": "^16.9.11",
49
+ "@types/react-dom": "^16.9.15",
50
+ "neo-cmp-cli": "^1.1.8",
51
+ "husky": "^4.2.5",
52
+ "lint-staged": "^10.2.9",
53
+ "prettier": "^2.0.5",
54
+ "@types/echarts": "^4.9.0"
55
+ },
56
+ "engines": {
57
+ "node": ">= 10.13.0",
58
+ "npm": ">= 6.4.1"
59
+ }
60
+ }
@@ -0,0 +1,186 @@
1
+ # 酷炫图表组件 (Chart Widget)
2
+ 一个功能丰富的图表组件,基于 ECharts 5.x 构建,支持多种图表类型和丰富的配置选项。
3
+
4
+ ### 特别说明
5
+ - 这是通过 Cursor 生成的一个自定义组件示例
6
+
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
+ - 支持 JSON AMIS 表单配置
39
+ - 多种数据源类型(模拟数据、API接口、静态数据)
40
+ - 不同类型图表的专用数据配置
41
+ - 实时数据更新支持
42
+
43
+ ## 使用方法
44
+
45
+ ### 基础用法
46
+
47
+ ```tsx
48
+ import ChartWidget from './components/chart-widget';
49
+
50
+ <ChartWidget
51
+ chartType="line"
52
+ title="销售趋势"
53
+ subtitle="2025年数据"
54
+ width={800}
55
+ height={400}
56
+ mockData={{
57
+ xAxis: ['1月', '2月', '3月', '4月', '5月', '6月'],
58
+ series: [{
59
+ name: '销售额',
60
+ data: [120, 200, 150, 80, 70, 110]
61
+ }]
62
+ }}
63
+ />
64
+ ```
65
+
66
+ ### 配置选项
67
+
68
+ | 属性 | 类型 | 默认值 | 说明 |
69
+ |------|------|--------|------|
70
+ | chartType | string | 'line' | 图表类型 |
71
+ | title | string | '图表标题' | 主标题 |
72
+ | subtitle | string | '' | 副标题 |
73
+ | width | number | 800 | 图表宽度 |
74
+ | height | number | 400 | 图表高度 |
75
+ | theme | string | 'default' | 主题风格 |
76
+ | showLegend | boolean | true | 是否显示图例 |
77
+ | showTooltip | boolean | true | 是否显示提示框 |
78
+ | showDataZoom | boolean | false | 是否显示数据缩放 |
79
+ | showGrid | boolean | true | 是否显示网格 |
80
+ | backgroundColor | string | 'transparent' | 背景颜色 |
81
+ | textColor | string | '#333' | 文字颜色 |
82
+ | mockData | object | {} | 模拟数据 |
83
+ | dataConfig | object | {} | 数据配置 |
84
+
85
+ ### 数据格式
86
+
87
+ #### 折线图/柱状图数据
88
+ ```javascript
89
+ {
90
+ xAxis: ['1月', '2月', '3月', '4月', '5月', '6月'],
91
+ series: [{
92
+ name: '销售额',
93
+ data: [120, 200, 150, 80, 70, 110]
94
+ }]
95
+ }
96
+ ```
97
+
98
+ #### 饼图数据
99
+ ```javascript
100
+ {
101
+ series: [{
102
+ data: [
103
+ { value: 1048, name: '搜索引擎' },
104
+ { value: 735, name: '直接访问' },
105
+ { value: 580, name: '邮件营销' }
106
+ ]
107
+ }]
108
+ }
109
+ ```
110
+
111
+ #### 散点图数据
112
+ ```javascript
113
+ {
114
+ series: [{
115
+ data: [
116
+ [161.2, 51.6], [167.5, 59.0], [159.5, 49.2]
117
+ ]
118
+ }]
119
+ }
120
+ ```
121
+
122
+ #### 雷达图数据
123
+ ```javascript
124
+ {
125
+ indicator: [
126
+ { name: '销售', max: 6500 },
127
+ { name: '管理', max: 16000 }
128
+ ],
129
+ series: [{
130
+ value: [4200, 3000],
131
+ name: '预算分配'
132
+ }]
133
+ }
134
+ ```
135
+
136
+ ## 主题配置
137
+
138
+ 组件支持多种主题风格:
139
+ - `default` - 默认主题
140
+ - `dark` - 深色主题
141
+ - `light` - 明亮主题
142
+ - `business` - 商务主题
143
+
144
+ ## 响应式设计
145
+
146
+ 组件自动适配不同屏幕尺寸,在移动端和桌面端都有良好的显示效果。
147
+
148
+ ## 浏览器兼容性
149
+
150
+ - Chrome 60+
151
+ - Firefox 55+
152
+ - Safari 12+
153
+ - Edge 79+
154
+
155
+ ## 技术栈
156
+
157
+ - React 16.9+
158
+ - TypeScript
159
+ - ECharts 5.4+
160
+ - SCSS
161
+
162
+ ## 开发说明
163
+
164
+ ### 安装依赖
165
+ ```bash
166
+ npm install
167
+ ```
168
+
169
+ ### 预览组件
170
+ ```bash
171
+ npm run preview --cmpType=chart-widget
172
+ ```
173
+
174
+ ### 构建发布
175
+ ```bash
176
+ npm run publish2oss
177
+ ```
178
+
179
+ ## 更新日志
180
+
181
+ ### v1.0.0
182
+ - 初始版本发布
183
+ - 支持8种图表类型
184
+ - 完整的配置选项
185
+ - 响应式设计
186
+ - 现代化UI设计