Skip to content

Commit 9d1a0b0

Browse files
committed
feat: 初始化form包
1 parent d5d1ef9 commit 9d1a0b0

File tree

10 files changed

+261
-5
lines changed

10 files changed

+261
-5
lines changed

main/src/components/SvgIcon.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { computed, ref } from 'vue';
2+
import { computed, ref, toRefs } from 'vue';
33
const props = withDefaults(
44
defineProps<{
55
name: string;
@@ -16,7 +16,9 @@ const props = withDefaults(
1616
}
1717
);
1818
19-
const fill = ref<string>(props.color);
19+
const { color } = toRefs(props);
20+
21+
const fill = ref<string>(color.value);
2022
2123
const svgSymbol = computed<string>(() => `#${props.prefix}-${props.name}`);
2224
</script>

packages/form/package.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"version": "0.0.1",
3+
"name": "@pictode/form",
4+
"sideEffects": [
5+
"dist/*",
6+
"src/theme/*"
7+
],
8+
"main": "dist/pictode-form.umd.js",
9+
"module": "dist/pictode-form.mjs",
10+
"style": "dist/style.css",
11+
"types": "types/index.d.ts",
12+
"exports": {
13+
".": {
14+
"import": "./dist/pictode-form.mjs",
15+
"require": "./dist/pictode-form.umd.js"
16+
},
17+
"./dist/style.css": {
18+
"import": "./dist/style.css",
19+
"require": "./dist/style.css"
20+
},
21+
"./*": "./*"
22+
},
23+
"scripts": {
24+
"build": "npm run build:type && vite build",
25+
"build:type": "npm run clear:type && vue-tsc --declaration --emitDeclarationOnly --project tsconfig.build.json",
26+
"clear:type": "rimraf ./types"
27+
},
28+
"dependencies": {
29+
"@element-plus/icons-vue": "^2.1.0",
30+
"@pictode/utils": "workspace:^0.0.1",
31+
"element-plus": "^2.2.28",
32+
"vue": "^3.3.4"
33+
},
34+
"devDependencies": {
35+
"@babel/core": "^7.18.0",
36+
"@types/lodash-es": "^4.17.4",
37+
"@types/node": "^15.12.4",
38+
"@types/sortablejs": "^1.10.7",
39+
"@vitejs/plugin-vue": "^4.2.3",
40+
"@vue/compiler-sfc": "^3.2.37",
41+
"rimraf": "^3.0.2",
42+
"sass": "^1.35.1",
43+
"typescript": "^5.0.2",
44+
"vite": "^4.4.5",
45+
"vue-tsc": "^1.8.5"
46+
}
47+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { InjectionKey } from 'vue';
2+
3+
import { RadioCtx } from '@/types';
4+
5+
export const RadioCtxKey: InjectionKey<RadioCtx<unknown>> = Symbol('RadioCtx');

packages/form/src/index.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<script setup lang="ts">
2+
import { ElForm } from 'element-plus';
3+
</script>
4+
5+
<template>
6+
<ElForm></ElForm>
7+
</template>

packages/form/src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default {};

packages/form/src/types.ts

Whitespace-only changes.

packages/form/tsconfig.build.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"baseUrl": ".",
5+
"declaration": true,
6+
"declarationDir": "types",
7+
"forceConsistentCasingInFileNames": true,
8+
"paths": {}
9+
},
10+
"include": ["src"]
11+
}

packages/form/tsconfig.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"baseUrl": "../.."
5+
},
6+
"exclude": ["**/dist/**/*"]
7+
}

packages/form/vite.config.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import path from 'path';
2+
3+
import { defineConfig } from 'vite';
4+
import vue from '@vitejs/plugin-vue';
5+
6+
import pkg from './package.json';
7+
8+
export default defineConfig({
9+
plugins: [vue()],
10+
11+
resolve: {
12+
alias:
13+
process.env.NODE_ENV === 'production'
14+
? []
15+
: [{ find: /^@pictode\/utils/, replacement: path.join(__dirname, '../utils/src/index.ts') }],
16+
},
17+
18+
build: {
19+
cssCodeSplit: false,
20+
sourcemap: true,
21+
minify: false,
22+
target: 'esnext',
23+
24+
lib: {
25+
entry: 'src/index.ts',
26+
name: 'PictodeForm',
27+
fileName: 'pictode-form',
28+
},
29+
30+
rollupOptions: {
31+
// 确保外部化处理那些你不想打包进库的依赖
32+
external(id: string) {
33+
return (
34+
/^vue/.test(id) ||
35+
/^element-plus/.test(id) ||
36+
/^@edoms\//.test(id) ||
37+
Object.keys(pkg.dependencies).some((k) => new RegExp(`^${k}`).test(id))
38+
);
39+
},
40+
41+
output: {
42+
// 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
43+
globals: {
44+
vue: 'Vue',
45+
'element-plus': 'ElementPlus',
46+
},
47+
},
48+
},
49+
},
50+
});

pnpm-lock.yaml

Lines changed: 129 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)