@zjlab-fe/data-hub-ui 0.26.1 → 0.26.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.
- package/package.json +9 -1
- package/jest.config.js +0 -10
- package/postcss.config.js +0 -7
- package/rollup.es.config.mjs +0 -181
- package/tailwind.config.js +0 -62
- package/tsconfig.rollup.json +0 -7
- package/webpack.common.js +0 -54
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zjlab-fe/data-hub-ui",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.2",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"module": "es/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -30,6 +30,14 @@
|
|
|
30
30
|
},
|
|
31
31
|
"./package.json": "./package.json"
|
|
32
32
|
},
|
|
33
|
+
"files": [
|
|
34
|
+
"es",
|
|
35
|
+
"lib",
|
|
36
|
+
"dist",
|
|
37
|
+
"README.md",
|
|
38
|
+
"LICENSE",
|
|
39
|
+
"COMPONENTS_SKILL.md"
|
|
40
|
+
],
|
|
33
41
|
"sideEffects": [
|
|
34
42
|
"**/*.css",
|
|
35
43
|
"**/*.scss",
|
package/jest.config.js
DELETED
package/postcss.config.js
DELETED
package/rollup.es.config.mjs
DELETED
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import resolve from '@rollup/plugin-node-resolve';
|
|
2
|
-
import commonjs from '@rollup/plugin-commonjs';
|
|
3
|
-
import typescript from '@rollup/plugin-typescript';
|
|
4
|
-
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
|
|
5
|
-
import alias from '@rollup/plugin-alias';
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import fs from 'fs';
|
|
8
|
-
import { fileURLToPath } from 'url';
|
|
9
|
-
import * as sass from 'sass';
|
|
10
|
-
import postcss from 'postcss';
|
|
11
|
-
import postcssModules from 'postcss-modules';
|
|
12
|
-
import tailwindcss from 'tailwindcss';
|
|
13
|
-
import autoprefixer from 'autoprefixer';
|
|
14
|
-
import postcssImport from 'postcss-import';
|
|
15
|
-
import postcssNested from 'postcss-nested';
|
|
16
|
-
|
|
17
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
18
|
-
const srcDir = path.resolve(__dirname, 'src');
|
|
19
|
-
|
|
20
|
-
// PostCSS 基础插件
|
|
21
|
-
const basePostcssPlugins = [postcssImport(), postcssNested(), tailwindcss(), autoprefixer()];
|
|
22
|
-
|
|
23
|
-
// 图片插件:将图片全部 base64 内联到 JS 中
|
|
24
|
-
// 消费端无需任何额外配置,无路径问题
|
|
25
|
-
function imagePlugin() {
|
|
26
|
-
return {
|
|
27
|
-
name: 'images',
|
|
28
|
-
async load(id) {
|
|
29
|
-
const ext = path.extname(id).toLowerCase();
|
|
30
|
-
if (!['.png', '.jpg', '.jpeg', '.gif', '.svg'].includes(ext)) return null;
|
|
31
|
-
if (id.includes('node_modules')) return null;
|
|
32
|
-
|
|
33
|
-
const buffer = fs.readFileSync(id);
|
|
34
|
-
const mimeMap = {
|
|
35
|
-
'.png': 'image/png',
|
|
36
|
-
'.jpg': 'image/jpeg',
|
|
37
|
-
'.jpeg': 'image/jpeg',
|
|
38
|
-
'.gif': 'image/gif',
|
|
39
|
-
'.svg': 'image/svg+xml',
|
|
40
|
-
};
|
|
41
|
-
const dataUrl = `data:${mimeMap[ext] || 'image/png'};base64,${buffer.toString('base64')}`;
|
|
42
|
-
|
|
43
|
-
return { code: `export default ${JSON.stringify(dataUrl)};`, map: null };
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// 自定义 SCSS/CSS 处理插件
|
|
49
|
-
function stylePlugin() {
|
|
50
|
-
return {
|
|
51
|
-
name: 'styles',
|
|
52
|
-
|
|
53
|
-
async transform(code, id) {
|
|
54
|
-
// 处理 src 目录下的样式文件
|
|
55
|
-
const isSrc = id.startsWith(srcDir);
|
|
56
|
-
// 处理从 node_modules 导入的 CSS(经由 src 文件引用)
|
|
57
|
-
const isNodeModuleCss = !isSrc && id.includes('node_modules') && id.endsWith('.css');
|
|
58
|
-
|
|
59
|
-
if (!isSrc && !isNodeModuleCss) return null;
|
|
60
|
-
if (!id.endsWith('.scss') && !id.endsWith('.css')) return null;
|
|
61
|
-
|
|
62
|
-
const isModule = id.endsWith('.module.scss') && isSrc;
|
|
63
|
-
const ext = path.extname(id);
|
|
64
|
-
const dir = path.dirname(id);
|
|
65
|
-
|
|
66
|
-
let processedCode = code;
|
|
67
|
-
|
|
68
|
-
// 替换 SCSS @import 中的 @/ 为相对路径(仅 src 文件)
|
|
69
|
-
if (isSrc) {
|
|
70
|
-
processedCode = code.replace(
|
|
71
|
-
/@(import|use)\s+['"]@\/([^'"]+)['"]/g,
|
|
72
|
-
(_match, directive, importPath) => {
|
|
73
|
-
const absolutePath = path.resolve(srcDir, importPath);
|
|
74
|
-
const relativePath = path.relative(dir, absolutePath).replace(/\\/g, '/');
|
|
75
|
-
return `@${directive} '${relativePath.startsWith('.') ? relativePath : './' + relativePath}'`;
|
|
76
|
-
},
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// 编译 SCSS → CSS
|
|
81
|
-
let css;
|
|
82
|
-
try {
|
|
83
|
-
if (ext === '.scss') {
|
|
84
|
-
const result = sass.compileString(processedCode, {
|
|
85
|
-
loadPaths: [dir, srcDir, path.resolve(srcDir, 'styles')],
|
|
86
|
-
});
|
|
87
|
-
css = result.css;
|
|
88
|
-
} else {
|
|
89
|
-
css = processedCode;
|
|
90
|
-
}
|
|
91
|
-
} catch (err) {
|
|
92
|
-
this.error(`SCSS compile error: ${err.message}`);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// 对所有 CSS 运行 PostCSS(tailwindcss + postcss-nested + postcss-import)
|
|
96
|
-
try {
|
|
97
|
-
const tailwindResult = await postcss(basePostcssPlugins).process(css, {
|
|
98
|
-
from: id,
|
|
99
|
-
to: id.replace(/\.(scss|css)$/, '.css'),
|
|
100
|
-
});
|
|
101
|
-
css = tailwindResult.css;
|
|
102
|
-
} catch (err) {
|
|
103
|
-
this.error(`PostCSS error: ${err.message}`);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// 对 .module.scss 文件,用 postcss-modules 提取类名映射
|
|
107
|
-
let classMap = {};
|
|
108
|
-
|
|
109
|
-
if (isModule) {
|
|
110
|
-
const modulesPlugin = postcssModules({
|
|
111
|
-
generateScopedName: '[name]__[local]___[hash:base64:5]',
|
|
112
|
-
getJSON(cssFileName, json) {
|
|
113
|
-
classMap = json;
|
|
114
|
-
},
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
const result = await postcss([modulesPlugin]).process(css, { from: id });
|
|
118
|
-
css = result.css;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// 生成 JS 模块代码
|
|
122
|
-
const escapedCss = css.replace(/\\/g, '\\\\').replace(/`/g, '\\`').replace(/\$/g, '\\$');
|
|
123
|
-
|
|
124
|
-
let jsCode;
|
|
125
|
-
if (isModule) {
|
|
126
|
-
const namedExports = Object.entries(classMap)
|
|
127
|
-
.map(([key, value]) => {
|
|
128
|
-
const jsKey = key.replace(/[^a-zA-Z0-9_$]/g, '_');
|
|
129
|
-
return `var ${jsKey} = ${JSON.stringify(value)}; export { ${jsKey} as ${JSON.stringify(key)} };`;
|
|
130
|
-
})
|
|
131
|
-
.join('\n');
|
|
132
|
-
|
|
133
|
-
const mapJson = JSON.stringify(classMap);
|
|
134
|
-
|
|
135
|
-
jsCode = `
|
|
136
|
-
var style = document.createElement('style');
|
|
137
|
-
style.textContent = \`${escapedCss}\`;
|
|
138
|
-
document.head.appendChild(style);
|
|
139
|
-
|
|
140
|
-
${namedExports}
|
|
141
|
-
|
|
142
|
-
var styles = ${mapJson};
|
|
143
|
-
export default styles;
|
|
144
|
-
`;
|
|
145
|
-
} else {
|
|
146
|
-
// 普通样式或 node_modules CSS:只注入 CSS,没有 export
|
|
147
|
-
jsCode = `
|
|
148
|
-
var style = document.createElement('style');
|
|
149
|
-
style.textContent = \`${escapedCss}\`;
|
|
150
|
-
document.head.appendChild(style);
|
|
151
|
-
`;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return {
|
|
155
|
-
code: jsCode,
|
|
156
|
-
map: null,
|
|
157
|
-
moduleSideEffects: 'no-treeshake',
|
|
158
|
-
};
|
|
159
|
-
},
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export default {
|
|
164
|
-
input: ['src/index.tsx', 'src/components/notion-editor/index.tsx'],
|
|
165
|
-
output: {
|
|
166
|
-
dir: 'es',
|
|
167
|
-
format: 'esm',
|
|
168
|
-
preserveModules: true,
|
|
169
|
-
preserveModulesRoot: 'src',
|
|
170
|
-
entryFileNames: '[name].js',
|
|
171
|
-
},
|
|
172
|
-
plugins: [
|
|
173
|
-
peerDepsExternal({ includeDependencies: true }),
|
|
174
|
-
alias({ entries: [{ find: '@', replacement: srcDir }] }),
|
|
175
|
-
imagePlugin(),
|
|
176
|
-
resolve({ extensions: ['.js', '.ts', '.jsx', '.tsx', '.css', '.scss'] }),
|
|
177
|
-
commonjs(),
|
|
178
|
-
stylePlugin(),
|
|
179
|
-
typescript({ tsconfig: './tsconfig.rollup.json' }),
|
|
180
|
-
],
|
|
181
|
-
};
|
package/tailwind.config.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { fontFamily as _fontFamily } from 'tailwindcss/defaultTheme';
|
|
2
|
-
|
|
3
|
-
export const prefix = 'dhu-'; // data-hub-ui 缩写
|
|
4
|
-
|
|
5
|
-
/** @type {import('tailwindcss').Config} */
|
|
6
|
-
export const content = [
|
|
7
|
-
'./src/components/uploadDrawer/**/*.{js,jsx,ts,tsx}',
|
|
8
|
-
'./src/components/FileUploader/**/*.{js,jsx,ts,tsx}',
|
|
9
|
-
'./src/components/feature-card/**/*.{js,jsx,ts,tsx}',
|
|
10
|
-
'./src/components/section-heading/**/*.{js,jsx,ts,tsx}',
|
|
11
|
-
];
|
|
12
|
-
|
|
13
|
-
export const corePlugins = {
|
|
14
|
-
preflight: false,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const theme = {
|
|
18
|
-
extend: {
|
|
19
|
-
fontFamily: {
|
|
20
|
-
sans: ['AlibabaPuHuiTi-3-55-RegularL3', _fontFamily.sans],
|
|
21
|
-
'ali-55': 'AlibabaPuHuiTi-3-55-Regular',
|
|
22
|
-
'ali-65': 'AlibabaPuHuiTi-3-65-Medium',
|
|
23
|
-
'ali-75': 'AlibabaPuHuiTi-3-75-SemiBold',
|
|
24
|
-
'ali-85': 'AlibabaPuHuiTi-3-85-Bold',
|
|
25
|
-
},
|
|
26
|
-
colors: {
|
|
27
|
-
'blue-1': '#E8F1FF',
|
|
28
|
-
'blue-2': '#B9D6FF',
|
|
29
|
-
'blue-4': '#4591FE',
|
|
30
|
-
'blue-5': '#1775FE',
|
|
31
|
-
'red-red': '#FE4D4F',
|
|
32
|
-
'yellow-yellow': '#FAAD14',
|
|
33
|
-
'green-green': '#53C31B',
|
|
34
|
-
'assist-blue': '#1990FF',
|
|
35
|
-
'assist-bg-blue': '#F4F6FA',
|
|
36
|
-
'gray-2': '#EDF2FC',
|
|
37
|
-
'gray-3': '#D9E0ED',
|
|
38
|
-
'gray-5': '#87909E',
|
|
39
|
-
'gray-7': '#545B64',
|
|
40
|
-
'gray-9': '#30353A',
|
|
41
|
-
'gray-10': '#222427',
|
|
42
|
-
},
|
|
43
|
-
borderRadius: {
|
|
44
|
-
ml: '10px',
|
|
45
|
-
},
|
|
46
|
-
height: {
|
|
47
|
-
162: '648px',
|
|
48
|
-
},
|
|
49
|
-
minHeight: {
|
|
50
|
-
162: '648px',
|
|
51
|
-
},
|
|
52
|
-
spacing: {
|
|
53
|
-
18: '72px',
|
|
54
|
-
29: '116px',
|
|
55
|
-
384: '1536px',
|
|
56
|
-
},
|
|
57
|
-
boxShadow: {
|
|
58
|
-
float: '0px 12px 30px 0px rgba(32,60,48,0.2);',
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
export const plugins = [require('@tailwindcss/typography')];
|
package/tsconfig.rollup.json
DELETED
package/webpack.common.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
module: {
|
|
3
|
-
rules: [
|
|
4
|
-
{
|
|
5
|
-
test: /\.md$/,
|
|
6
|
-
use: ['raw-loader'],
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
test: /\.(svg|png|jpe?g)$/,
|
|
10
|
-
use: [
|
|
11
|
-
{
|
|
12
|
-
loader: 'url-loader',
|
|
13
|
-
options: {
|
|
14
|
-
// 图片大小小于20kb,就会base64处理
|
|
15
|
-
// limit: 300 * 1024,
|
|
16
|
-
// url-loader默认使用es6模块化解析,html-loader引入图片使用的是commonjs规范
|
|
17
|
-
// 关闭url-loader的es6模块化,使用commonjs解析
|
|
18
|
-
// esModule: false,
|
|
19
|
-
// outputPath: 'assets'
|
|
20
|
-
// 图片编译之后重命名
|
|
21
|
-
// [hash:10]获取图片hash前10位 [ext]取文件的原扩展名
|
|
22
|
-
name: '[hash:10].[ext]',
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
|
|
27
|
-
// type: 'asset/resource',
|
|
28
|
-
// generator: {
|
|
29
|
-
// filename: 'static/[contenthash].[ext]',
|
|
30
|
-
// },
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
test: /\.s?css$/,
|
|
34
|
-
use: ['style-loader', 'css-loader', 'postcss-loader', 'sass-loader'],
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
test: /\.(js|jsx|ts|tsx)$/,
|
|
38
|
-
exclude: /node_modules/,
|
|
39
|
-
use: [
|
|
40
|
-
// {
|
|
41
|
-
// loader: 'babel-loader',
|
|
42
|
-
// options: {
|
|
43
|
-
// // 开启 babel 缓存
|
|
44
|
-
// cacheDirectory: true,
|
|
45
|
-
// // 关闭缓存压缩
|
|
46
|
-
// cacheCompression: false,
|
|
47
|
-
// },
|
|
48
|
-
// },
|
|
49
|
-
{ loader: 'ts-loader' },
|
|
50
|
-
],
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
},
|
|
54
|
-
};
|