@zzzzzzhaopu/my-ui 1.0.0

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 (30) hide show
  1. package/README.md +289 -0
  2. package/dist/es/_virtual/_plugin-vue_export-helper.js +9 -0
  3. package/dist/es/components/MyButton/index.d.ts +6 -0
  4. package/dist/es/components/MyButton/index.js +7 -0
  5. package/dist/es/components/MyButton/src/MyButton.css +1 -0
  6. package/dist/es/components/MyButton/src/MyButton.vue.d.ts +59 -0
  7. package/dist/es/components/MyButton/src/MyButton.vue.js +7 -0
  8. package/dist/es/components/MyButton/src/MyButton.vue2.js +42 -0
  9. package/dist/es/components/MyButton/src/types.d.ts +13 -0
  10. package/dist/es/components/MyCard/index.d.ts +6 -0
  11. package/dist/es/components/MyCard/index.js +7 -0
  12. package/dist/es/components/MyCard/src/MyCard.css +1 -0
  13. package/dist/es/components/MyCard/src/MyCard.vue.d.ts +38 -0
  14. package/dist/es/components/MyCard/src/MyCard.vue.js +7 -0
  15. package/dist/es/components/MyCard/src/MyCard.vue2.js +35 -0
  16. package/dist/es/components/MyCard/src/types.d.ts +5 -0
  17. package/dist/es/components/MyInput/index.d.ts +6 -0
  18. package/dist/es/components/MyInput/index.js +7 -0
  19. package/dist/es/components/MyInput/src/MyInput.css +1 -0
  20. package/dist/es/components/MyInput/src/MyInput.vue.d.ts +60 -0
  21. package/dist/es/components/MyInput/src/MyInput.vue.js +7 -0
  22. package/dist/es/components/MyInput/src/MyInput.vue2.js +59 -0
  23. package/dist/es/components/MyInput/src/types.d.ts +15 -0
  24. package/dist/es/components/index.d.ts +11 -0
  25. package/dist/es/components/index.js +24 -0
  26. package/dist/es/index.d.ts +2 -0
  27. package/dist/es/index.js +15 -0
  28. package/dist/es/styles/index.css +1 -0
  29. package/dist/umd/index.js +2 -0
  30. package/package.json +62 -0
package/README.md ADDED
@@ -0,0 +1,289 @@
1
+ # My UI Library
2
+
3
+ 基于 Vite + Vue3 + TypeScript 的业务组件库
4
+
5
+ ## 特性
6
+
7
+ - ⚡️ 基于 Vite 构建,开发体验极佳
8
+ - 🎨 基于 Element Plus,UI 精美
9
+ - 📦 支持按需引入,Tree-shaking
10
+ - 🔧 完整的 TypeScript 类型定义
11
+ - 🌈 支持 SCSS 变量定制主题
12
+ - 📖 详细的文档和示例
13
+
14
+ ## 安装
15
+
16
+ ```bash
17
+ npm install @demo/my-ui
18
+ ```
19
+
20
+ ## 快速开始
21
+
22
+ ### 完整引入
23
+
24
+ ```typescript
25
+ import { createApp } from 'vue'
26
+ import MyUI from '@demo/my-ui'
27
+ import '@demo/my-ui/dist/style.css'
28
+
29
+ const app = createApp(App)
30
+ app.use(MyUI)
31
+ ```
32
+
33
+ ### 按需引入
34
+
35
+ ```vue
36
+ <script setup>
37
+ import { MyButton, MyInput } from '@demo/my-ui'
38
+ import '@demo/my-ui/dist/style.css'
39
+ </script>
40
+
41
+ <template>
42
+ <MyButton>按钮</MyButton>
43
+ <MyInput v-model="value" />
44
+ </template>
45
+ ```
46
+
47
+ ## 组件列表
48
+
49
+ - MyButton - 按钮组件
50
+ - MyInput - 输入框组件
51
+ - MyCard - 卡片组件
52
+
53
+ ## 开发
54
+
55
+ ```bash
56
+ # 安装依赖
57
+ npm install
58
+
59
+ # 启动开发服务器
60
+ npm run dev
61
+
62
+ # 启动文档站点
63
+ npm run docs:dev
64
+
65
+ # 构建组件库
66
+ npm run build
67
+
68
+ # 构建文档
69
+ npm run docs:build
70
+ ```
71
+
72
+ ## 项目结构
73
+
74
+ ```
75
+ my-component-library/
76
+ ├── packages/ # 组件源码目录
77
+ │ ├── components/ # 业务组件
78
+ │ │ ├── MyButton/ # 按钮组件
79
+ │ │ │ ├── src/
80
+ │ │ │ │ ├── MyButton.vue # 组件实现
81
+ │ │ │ │ └── types.ts # 组件类型定义
82
+ │ │ │ ├── style/
83
+ │ │ │ │ └── index.scss # 组件样式
84
+ │ │ │ └── index.ts # 组件入口(支持 install 方法)
85
+ │ │ ├── MyInput/ # 输入框组件(结构同上)
86
+ │ │ ├── MyCard/ # 卡片组件(结构同上)
87
+ │ │ └── index.ts # 组件统一导出
88
+ │ ├── styles/ # 全局样式系统
89
+ │ │ ├── variables.scss # SCSS 变量(颜色、字体、间距等)
90
+ │ │ ├── mixins.scss # SCSS 混入(工具函数)
91
+ │ │ └── index.scss # 样式入口
92
+ │ ├── types/ # 全局类型定义
93
+ │ ├── utils/ # 工具函数
94
+ │ ├── composables/ # 组合式函数
95
+ │ └── index.ts # 组件库总入口(导出所有组件)
96
+
97
+ ├── src/ # 开发预览环境
98
+ │ ├── App.vue # 组件预览页面
99
+ │ ├── main.ts # 开发环境入口
100
+ │ └── examples/ # 组件示例
101
+
102
+ ├── docs/ # VitePress 文档站点
103
+ │ ├── .vitepress/ # VitePress 配置
104
+ │ │ ├── config.ts # 站点配置(导航、侧边栏等)
105
+ │ │ └── theme/
106
+ │ │ └── index.ts # 自定义主题(注册组件库)
107
+ │ ├── components/ # 组件文档
108
+ │ │ ├── button.md # Button 组件文档
109
+ │ │ ├── input.md # Input 组件文档
110
+ │ │ └── card.md # Card 组件文档
111
+ │ ├── guide/ # 指南文档
112
+ │ │ └── quick-start.md # 快速开始
113
+ │ └── index.md # 文档首页
114
+
115
+ ├── dist/ # 构建产物(自动生成)
116
+ │ ├── index.es.js # ES Module 格式
117
+ │ ├── index.umd.js # UMD 格式
118
+ │ ├── index.d.ts # TypeScript 类型定义
119
+ │ ├── style.css # 打包后的样式
120
+ │ ├── components/ # 各组件独立文件(支持按需引入)
121
+ │ └── assets/ # 静态资源
122
+
123
+ ├── vite.config.ts # Vite 核心配置(库模式构建)
124
+ ├── tsconfig.json # TypeScript 配置
125
+ ├── package.json # 项目配置和依赖管理
126
+ ├── env.d.ts # 环境类型声明
127
+ ├── .gitignore # Git 忽略文件
128
+ ├── .npmignore # npm 发布忽略文件
129
+ └── README.md # 项目说明文档
130
+ ```
131
+
132
+ ### 关键文件说明
133
+
134
+ #### 配置文件
135
+
136
+ **vite.config.ts** - Vite 核心配置
137
+ ```typescript
138
+ // 关键配置项说明:
139
+ {
140
+ plugins: [
141
+ vue(), // Vue 3 支持
142
+ dts({ // 自动生成 TypeScript 类型定义
143
+ include: ['packages/**/*'],
144
+ outDir: 'dist'
145
+ }),
146
+ svgLoader() // SVG 作为 Vue 组件导入
147
+ ],
148
+ resolve: {
149
+ alias: {
150
+ '@': resolve(__dirname, 'packages') // 路径别名,@ 指向 packages 目录
151
+ }
152
+ },
153
+ build: {
154
+ lib: {
155
+ entry: 'packages/index.ts', // 组件库入口
156
+ name: 'MyUILibrary', // UMD 格式全局变量名
157
+ formats: ['es', 'umd'] // 输出 ES Module 和 UMD 两种格式
158
+ },
159
+ rollupOptions: {
160
+ external: ['vue', 'element-plus'], // 外部依赖,不打包进组件库
161
+ output: {
162
+ preserveModules: true, // 保留模块结构,支持按需引入
163
+ preserveModulesRoot: 'packages'
164
+ }
165
+ },
166
+ cssCodeSplit: true // CSS 代码分割,每个组件独立样式
167
+ }
168
+ }
169
+ ```
170
+
171
+ **package.json** - 项目配置
172
+ ```json
173
+ {
174
+ "name": "@demo/my-ui", // npm 包名
175
+ "type": "module", // 声明为 ES Module
176
+ "main": "./dist/index.umd.js", // CommonJS 入口
177
+ "module": "./dist/index.es.js", // ES Module 入口
178
+ "types": "./dist/index.d.ts", // TypeScript 类型入口
179
+ "exports": { // 现代化导出方式
180
+ ".": {
181
+ "import": "./dist/index.es.js", // import 使用 ES Module
182
+ "require": "./dist/index.umd.js", // require 使用 UMD
183
+ "types": "./dist/index.d.ts"
184
+ },
185
+ "./dist/style.css": "./dist/style.css" // 样式文件导出
186
+ },
187
+ "files": ["dist"], // npm 发布时只包含 dist 目录
188
+ "scripts": {
189
+ "dev": "vite", // 启动开发服务器
190
+ "build": "vue-tsc && vite build", // 类型检查 + 构建
191
+ "docs:dev": "vitepress dev docs", // 启动文档站点
192
+ "prepublishOnly": "npm run build" // 发布前自动构建
193
+ },
194
+ "peerDependencies": { // 对等依赖,用户项目需要安装
195
+ "vue": "^3.4.0"
196
+ }
197
+ }
198
+ ```
199
+
200
+ **tsconfig.json** - TypeScript 配置
201
+ ```json
202
+ {
203
+ "compilerOptions": {
204
+ "target": "ES2020", // 编译目标
205
+ "module": "ESNext", // 模块系统
206
+ "moduleResolution": "bundler", // 模块解析策略
207
+ "strict": true, // 严格类型检查
208
+ "jsx": "preserve", // 保留 JSX(由 Vite 处理)
209
+ "baseUrl": ".", // 路径解析基准
210
+ "paths": {
211
+ "@/*": ["packages/*"] // 路径映射,@ 指向 packages
212
+ }
213
+ },
214
+ "include": ["src/**/*", "packages/**/*"], // 包含的文件
215
+ "exclude": ["node_modules", "dist"] // 排除的文件
216
+ }
217
+ ```
218
+
219
+ **docs/.vitepress/config.ts** - VitePress 配置
220
+ ```typescript
221
+ {
222
+ title: 'My UI Library', // 站点标题
223
+ description: '基于 Vite + Vue3 的业务组件库',
224
+ themeConfig: {
225
+ nav: [...], // 顶部导航栏
226
+ sidebar: [...], // 侧边栏菜单
227
+ socialLinks: [...] // 社交链接(GitHub 等)
228
+ },
229
+ vite: { // 继承 Vite 配置
230
+ resolve: { alias: { '@': '/packages' } },
231
+ css: { // SCSS 全局变量注入
232
+ preprocessorOptions: {
233
+ scss: {
234
+ additionalData: `@import "/packages/styles/variables.scss";`
235
+ }
236
+ }
237
+ }
238
+ }
239
+ }
240
+ ```
241
+
242
+ #### 核心源码文件
243
+
244
+ **packages/index.ts** - 组件库总入口
245
+ - 导出所有组件
246
+ - 提供全局安装方法(支持 app.use())
247
+ - 导入全局样式
248
+
249
+ **packages/components/index.ts** - 组件统一导出
250
+ - 收集所有组件
251
+ - 实现全局安装逻辑
252
+ - 支持按需引入和全量引入
253
+
254
+ **packages/components/MyButton/index.ts** - 单个组件入口
255
+ - 为组件添加 install 方法
256
+ - 导出组件和类型定义
257
+ - 支持独立使用 app.use(MyButton)
258
+
259
+ **packages/styles/variables.scss** - SCSS 变量系统
260
+ - 定义颜色、字体、间距等设计令牌
261
+ - 支持主题定制
262
+ - 全局自动注入,组件中可直接使用
263
+
264
+ #### 文档相关文件
265
+
266
+ **docs/.vitepress/theme/index.ts** - 自定义主题
267
+ - 扩展默认主题
268
+ - 注册组件库(使文档中可直接使用组件)
269
+ - 引入 Element Plus
270
+
271
+ **docs/components/*.md** - 组件文档
272
+ - Markdown 格式
273
+ - 支持内嵌 Vue 组件(实时预览)
274
+ - 包含组件 API 说明和示例代码
275
+
276
+ ### 构建产物说明
277
+
278
+ 运行 `npm run build` 后,在 `dist/` 目录生成:
279
+
280
+ 1. **index.es.js** - ES Module 格式,支持 Tree-shaking
281
+ 2. **index.umd.js** - UMD 格式,支持 script 标签直接引入
282
+ 3. **index.d.ts** - TypeScript 类型定义入口
283
+ 4. **style.css** - 打包后的全量样式文件
284
+ 5. **components/** - 各组件独立文件,支持按需引入
285
+ 6. **各组件的 .d.ts 文件** - 每个组件的类型定义
286
+
287
+ ## License
288
+
289
+ MIT
@@ -0,0 +1,9 @@
1
+ const s = (t, e) => {
2
+ const o = t.__vccOpts || t;
3
+ for (const [r, c] of e)
4
+ o[r] = c;
5
+ return o;
6
+ };
7
+ export {
8
+ s as default
9
+ };
@@ -0,0 +1,6 @@
1
+ import { Plugin } from 'vue';
2
+ import { default as MyButton } from './src/MyButton.vue';
3
+
4
+ declare const _default: typeof MyButton & Plugin;
5
+ export default _default;
6
+ export * from './src/types';
@@ -0,0 +1,7 @@
1
+ import t from "./src/MyButton.vue.js";
2
+ t.install = function(n) {
3
+ n.component(t.name, t);
4
+ };
5
+ export {
6
+ t as default
7
+ };
@@ -0,0 +1 @@
1
+ .my-button[data-v-4e6c7abb]{font-weight:500;transition:all .3s cubic-bezier(.645,.045,.355,1)}.my-button[data-v-4e6c7abb]:hover{opacity:.8}
@@ -0,0 +1,59 @@
1
+ import { MyButtonProps } from './types';
2
+ import { DefineComponent, ExtractPropTypes, ComponentOptionsMixin, PublicProps, ComponentProvideOptions, PropType } from 'vue';
3
+
4
+ declare function __VLS_template(): {
5
+ default?(_: {}): any;
6
+ };
7
+ declare const __VLS_component: DefineComponent<ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<MyButtonProps>, {
8
+ type: string;
9
+ size: string;
10
+ disabled: boolean;
11
+ loading: boolean;
12
+ text: string;
13
+ round: boolean;
14
+ circle: boolean;
15
+ }>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
16
+ click: (event: MouseEvent) => void;
17
+ }, string, PublicProps, Readonly< ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<MyButtonProps>, {
18
+ type: string;
19
+ size: string;
20
+ disabled: boolean;
21
+ loading: boolean;
22
+ text: string;
23
+ round: boolean;
24
+ circle: boolean;
25
+ }>>> & Readonly<{
26
+ onClick?: ((event: MouseEvent) => any) | undefined;
27
+ }>, {
28
+ type: "primary" | "success" | "warning" | "danger" | "info";
29
+ size: "large" | "default" | "small";
30
+ disabled: boolean;
31
+ loading: boolean;
32
+ text: string;
33
+ round: boolean;
34
+ circle: boolean;
35
+ }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
36
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
37
+ export default _default;
38
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
39
+ type __VLS_TypePropsToRuntimeProps<T> = {
40
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
41
+ type: PropType<__VLS_NonUndefinedable<T[K]>>;
42
+ } : {
43
+ type: PropType<T[K]>;
44
+ required: true;
45
+ };
46
+ };
47
+ type __VLS_WithDefaults<P, D> = {
48
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
49
+ default: D[K];
50
+ }> : P[K];
51
+ };
52
+ type __VLS_Prettify<T> = {
53
+ [K in keyof T]: T[K];
54
+ } & {};
55
+ type __VLS_WithTemplateSlots<T, S> = T & {
56
+ new (): {
57
+ $slots: S;
58
+ };
59
+ };
@@ -0,0 +1,7 @@
1
+ import o from "./MyButton.vue2.js";
2
+ /* empty css */
3
+ import t from "../../../_virtual/_plugin-vue_export-helper.js";
4
+ const p = /* @__PURE__ */ t(o, [["__scopeId", "data-v-4e6c7abb"]]);
5
+ export {
6
+ p as default
7
+ };
@@ -0,0 +1,42 @@
1
+ import { defineComponent as i, createBlock as d, openBlock as c, unref as u, normalizeClass as s, withCtx as r, renderSlot as f, createTextVNode as m, toDisplayString as y } from "vue";
2
+ import { ElButton as B } from "element-plus";
3
+ const p = /* @__PURE__ */ i({
4
+ name: "MyButton",
5
+ __name: "MyButton",
6
+ props: {
7
+ type: { default: "primary" },
8
+ size: { default: "default" },
9
+ disabled: { type: Boolean, default: !1 },
10
+ loading: { type: Boolean, default: !1 },
11
+ text: { default: "" },
12
+ icon: {},
13
+ round: { type: Boolean, default: !1 },
14
+ circle: { type: Boolean, default: !1 }
15
+ },
16
+ emits: ["click"],
17
+ setup(e, { emit: a }) {
18
+ const l = e, n = a, o = (t) => {
19
+ l.disabled || l.loading || n("click", t);
20
+ };
21
+ return (t, b) => (c(), d(u(B), {
22
+ class: s(["my-button", `my-button--${e.type}`]),
23
+ type: e.type,
24
+ size: e.size,
25
+ disabled: e.disabled,
26
+ loading: e.loading,
27
+ round: e.round,
28
+ circle: e.circle,
29
+ onClick: o
30
+ }, {
31
+ default: r(() => [
32
+ f(t.$slots, "default", {}, () => [
33
+ m(y(e.text), 1)
34
+ ], !0)
35
+ ]),
36
+ _: 3
37
+ }, 8, ["class", "type", "size", "disabled", "loading", "round", "circle"]));
38
+ }
39
+ });
40
+ export {
41
+ p as default
42
+ };
@@ -0,0 +1,13 @@
1
+ export interface MyButtonProps {
2
+ type?: 'primary' | 'success' | 'warning' | 'danger' | 'info';
3
+ size?: 'large' | 'default' | 'small';
4
+ disabled?: boolean;
5
+ loading?: boolean;
6
+ text?: string;
7
+ icon?: string;
8
+ round?: boolean;
9
+ circle?: boolean;
10
+ }
11
+ export interface MyButtonEmits {
12
+ (e: 'click', event: MouseEvent): void;
13
+ }
@@ -0,0 +1,6 @@
1
+ import { Plugin } from 'vue';
2
+ import { default as MyCard } from './src/MyCard.vue';
3
+
4
+ declare const _default: typeof MyCard & Plugin;
5
+ export default _default;
6
+ export * from './src/types';
@@ -0,0 +1,7 @@
1
+ import n from "./src/MyCard.vue.js";
2
+ n.install = function(o) {
3
+ o.component(n.name, n);
4
+ };
5
+ export {
6
+ n as default
7
+ };
@@ -0,0 +1 @@
1
+ .my-card[data-v-88cf7b28]{border-radius:4px;transition:all .3s cubic-bezier(.645,.045,.355,1)}.my-card[data-v-88cf7b28]:hover{box-shadow:0 2px 12px rgba(0,0,0,.1)}
@@ -0,0 +1,38 @@
1
+ import { MyCardProps } from './types';
2
+ import { DefineComponent, ExtractPropTypes, ComponentOptionsMixin, PublicProps, ComponentProvideOptions, PropType } from 'vue';
3
+
4
+ declare function __VLS_template(): {
5
+ header?(_: {}): any;
6
+ default?(_: {}): any;
7
+ };
8
+ declare const __VLS_component: DefineComponent<ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<MyCardProps>, {
9
+ shadow: string;
10
+ }>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly< ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<MyCardProps>, {
11
+ shadow: string;
12
+ }>>> & Readonly<{}>, {
13
+ shadow: "always" | "hover" | "never";
14
+ }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
15
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
16
+ export default _default;
17
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
18
+ type __VLS_TypePropsToRuntimeProps<T> = {
19
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
20
+ type: PropType<__VLS_NonUndefinedable<T[K]>>;
21
+ } : {
22
+ type: PropType<T[K]>;
23
+ required: true;
24
+ };
25
+ };
26
+ type __VLS_WithDefaults<P, D> = {
27
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
28
+ default: D[K];
29
+ }> : P[K];
30
+ };
31
+ type __VLS_Prettify<T> = {
32
+ [K in keyof T]: T[K];
33
+ } & {};
34
+ type __VLS_WithTemplateSlots<T, S> = T & {
35
+ new (): {
36
+ $slots: S;
37
+ };
38
+ };
@@ -0,0 +1,7 @@
1
+ import o from "./MyCard.vue2.js";
2
+ /* empty css */
3
+ import r from "../../../_virtual/_plugin-vue_export-helper.js";
4
+ const m = /* @__PURE__ */ r(o, [["__scopeId", "data-v-88cf7b28"]]);
5
+ export {
6
+ m as default
7
+ };
@@ -0,0 +1,35 @@
1
+ import { defineComponent as r, createBlock as t, openBlock as s, unref as l, createSlots as n, withCtx as d, renderSlot as o } from "vue";
2
+ import { ElCard as h } from "element-plus";
3
+ const u = /* @__PURE__ */ r({
4
+ name: "MyCard",
5
+ __name: "MyCard",
6
+ props: {
7
+ header: {},
8
+ shadow: { default: "always" },
9
+ bodyStyle: {}
10
+ },
11
+ setup(e) {
12
+ return (a, y) => (s(), t(l(h), {
13
+ header: e.header,
14
+ shadow: e.shadow,
15
+ "body-style": e.bodyStyle,
16
+ class: "my-card"
17
+ }, n({
18
+ default: d(() => [
19
+ o(a.$slots, "default", {}, void 0, !0)
20
+ ]),
21
+ _: 2
22
+ }, [
23
+ a.$slots.header ? {
24
+ name: "header",
25
+ fn: d(() => [
26
+ o(a.$slots, "header", {}, void 0, !0)
27
+ ]),
28
+ key: "0"
29
+ } : void 0
30
+ ]), 1032, ["header", "shadow", "body-style"]));
31
+ }
32
+ });
33
+ export {
34
+ u as default
35
+ };
@@ -0,0 +1,5 @@
1
+ export interface MyCardProps {
2
+ header?: string;
3
+ shadow?: 'always' | 'hover' | 'never';
4
+ bodyStyle?: Record<string, string>;
5
+ }
@@ -0,0 +1,6 @@
1
+ import { Plugin } from 'vue';
2
+ import { default as MyInput } from './src/MyInput.vue';
3
+
4
+ declare const _default: typeof MyInput & Plugin;
5
+ export default _default;
6
+ export * from './src/types';
@@ -0,0 +1,7 @@
1
+ import n from "./src/MyInput.vue.js";
2
+ n.install = function(t) {
3
+ t.component(n.name, n);
4
+ };
5
+ export {
6
+ n as default
7
+ };
@@ -0,0 +1 @@
1
+ .my-input[data-v-151b015e]{width:100%}
@@ -0,0 +1,60 @@
1
+ import { MyInputProps } from './types';
2
+ import { DefineComponent, ExtractPropTypes, ComponentOptionsMixin, PublicProps, ComponentProvideOptions, PropType } from 'vue';
3
+
4
+ declare function __VLS_template(): {
5
+ prefix?(_: {}): any;
6
+ suffix?(_: {}): any;
7
+ };
8
+ declare const __VLS_component: DefineComponent<ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<MyInputProps>, {
9
+ type: string;
10
+ placeholder: string;
11
+ disabled: boolean;
12
+ clearable: boolean;
13
+ size: string;
14
+ }>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
15
+ "update:modelValue": (value: string | number) => void;
16
+ change: (value: string | number) => void;
17
+ blur: (event: FocusEvent) => void;
18
+ focus: (event: FocusEvent) => void;
19
+ }, string, PublicProps, Readonly< ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<MyInputProps>, {
20
+ type: string;
21
+ placeholder: string;
22
+ disabled: boolean;
23
+ clearable: boolean;
24
+ size: string;
25
+ }>>> & Readonly<{
26
+ "onUpdate:modelValue"?: ((value: string | number) => any) | undefined;
27
+ onChange?: ((value: string | number) => any) | undefined;
28
+ onBlur?: ((event: FocusEvent) => any) | undefined;
29
+ onFocus?: ((event: FocusEvent) => any) | undefined;
30
+ }>, {
31
+ type: "text" | "password" | "number" | "email";
32
+ size: "large" | "default" | "small";
33
+ disabled: boolean;
34
+ placeholder: string;
35
+ clearable: boolean;
36
+ }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
37
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
38
+ export default _default;
39
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
40
+ type __VLS_TypePropsToRuntimeProps<T> = {
41
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
42
+ type: PropType<__VLS_NonUndefinedable<T[K]>>;
43
+ } : {
44
+ type: PropType<T[K]>;
45
+ required: true;
46
+ };
47
+ };
48
+ type __VLS_WithDefaults<P, D> = {
49
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
50
+ default: D[K];
51
+ }> : P[K];
52
+ };
53
+ type __VLS_Prettify<T> = {
54
+ [K in keyof T]: T[K];
55
+ } & {};
56
+ type __VLS_WithTemplateSlots<T, S> = T & {
57
+ new (): {
58
+ $slots: S;
59
+ };
60
+ };
@@ -0,0 +1,7 @@
1
+ import o from "./MyInput.vue2.js";
2
+ /* empty css */
3
+ import t from "../../../_virtual/_plugin-vue_export-helper.js";
4
+ const _ = /* @__PURE__ */ t(o, [["__scopeId", "data-v-151b015e"]]);
5
+ export {
6
+ _ as default
7
+ };
@@ -0,0 +1,59 @@
1
+ import { defineComponent as i, createBlock as r, openBlock as c, unref as m, createSlots as h, withCtx as t, renderSlot as n } from "vue";
2
+ import { ElInput as p } from "element-plus";
3
+ const g = /* @__PURE__ */ i({
4
+ name: "MyInput",
5
+ __name: "MyInput",
6
+ props: {
7
+ modelValue: {},
8
+ type: { default: "text" },
9
+ placeholder: { default: "请输入" },
10
+ disabled: { type: Boolean, default: !1 },
11
+ clearable: { type: Boolean, default: !1 },
12
+ size: { default: "default" },
13
+ maxlength: {}
14
+ },
15
+ emits: ["update:modelValue", "change", "blur", "focus"],
16
+ setup(l, { emit: o }) {
17
+ const a = o, d = (e) => {
18
+ a("update:modelValue", e);
19
+ }, u = (e) => {
20
+ a("change", e);
21
+ }, s = (e) => {
22
+ a("blur", e);
23
+ }, f = (e) => {
24
+ a("focus", e);
25
+ };
26
+ return (e, y) => (c(), r(m(p), {
27
+ "model-value": l.modelValue,
28
+ type: l.type,
29
+ placeholder: l.placeholder,
30
+ disabled: l.disabled,
31
+ clearable: l.clearable,
32
+ size: l.size,
33
+ maxlength: l.maxlength,
34
+ class: "my-input",
35
+ "onUpdate:modelValue": d,
36
+ onChange: u,
37
+ onBlur: s,
38
+ onFocus: f
39
+ }, h({ _: 2 }, [
40
+ e.$slots.prefix ? {
41
+ name: "prefix",
42
+ fn: t(() => [
43
+ n(e.$slots, "prefix", {}, void 0, !0)
44
+ ]),
45
+ key: "0"
46
+ } : void 0,
47
+ e.$slots.suffix ? {
48
+ name: "suffix",
49
+ fn: t(() => [
50
+ n(e.$slots, "suffix", {}, void 0, !0)
51
+ ]),
52
+ key: "1"
53
+ } : void 0
54
+ ]), 1032, ["model-value", "type", "placeholder", "disabled", "clearable", "size", "maxlength"]));
55
+ }
56
+ });
57
+ export {
58
+ g as default
59
+ };
@@ -0,0 +1,15 @@
1
+ export interface MyInputProps {
2
+ modelValue?: string | number;
3
+ type?: 'text' | 'password' | 'number' | 'email';
4
+ placeholder?: string;
5
+ disabled?: boolean;
6
+ clearable?: boolean;
7
+ size?: 'large' | 'default' | 'small';
8
+ maxlength?: number;
9
+ }
10
+ export interface MyInputEmits {
11
+ (e: 'update:modelValue', value: string | number): void;
12
+ (e: 'change', value: string | number): void;
13
+ (e: 'blur', event: FocusEvent): void;
14
+ (e: 'focus', event: FocusEvent): void;
15
+ }
@@ -0,0 +1,11 @@
1
+ import { App } from 'vue';
2
+ import { default as MyButton } from './MyButton';
3
+ import { default as MyInput } from './MyInput';
4
+ import { default as MyCard } from './MyCard';
5
+
6
+ declare const install: (app: App) => void;
7
+ export { install, MyButton, MyInput, MyCard };
8
+ declare const _default: {
9
+ install: (app: App) => void;
10
+ };
11
+ export default _default;
@@ -0,0 +1,24 @@
1
+ import "./MyButton/index.js";
2
+ import "./MyInput/index.js";
3
+ import "./MyCard/index.js";
4
+ import r from "./MyButton/src/MyButton.vue.js";
5
+ import m from "./MyInput/src/MyInput.vue.js";
6
+ import n from "./MyCard/src/MyCard.vue.js";
7
+ const p = [
8
+ r,
9
+ m,
10
+ n
11
+ ], i = (o) => {
12
+ p.forEach((t) => {
13
+ o.use(t);
14
+ });
15
+ }, d = {
16
+ install: i
17
+ };
18
+ export {
19
+ r as MyButton,
20
+ n as MyCard,
21
+ m as MyInput,
22
+ d as default,
23
+ i as install
24
+ };
@@ -0,0 +1,2 @@
1
+ export * from './components';
2
+ export { default } from './components';
@@ -0,0 +1,15 @@
1
+ import { default as f, install as m } from "./components/index.js";
2
+ /* empty css */
3
+ import "./components/MyButton/index.js";
4
+ import { default as u } from "./components/MyButton/src/MyButton.vue.js";
5
+ import "./components/MyInput/index.js";
6
+ import { default as i } from "./components/MyInput/src/MyInput.vue.js";
7
+ import "./components/MyCard/index.js";
8
+ import { default as x } from "./components/MyCard/src/MyCard.vue.js";
9
+ export {
10
+ u as MyButton,
11
+ x as MyCard,
12
+ i as MyInput,
13
+ f as default,
14
+ m as install
15
+ };
@@ -0,0 +1 @@
1
+ *{margin:0;padding:0;box-sizing:border-box}
@@ -0,0 +1,2 @@
1
+ (function(a,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue"),require("element-plus")):typeof define=="function"&&define.amd?define(["exports","vue","element-plus"],t):(a=typeof globalThis!="undefined"?globalThis:a||self,t(a.MyUILibrary={},a.Vue,a.ElementPlus))})(this,function(a,t,f){"use strict";var y=document.createElement("style");y.textContent=`.my-button[data-v-4e6c7abb]{font-weight:500;transition:all .3s cubic-bezier(.645,.045,.355,1)}.my-button[data-v-4e6c7abb]:hover{opacity:.8}.my-input[data-v-151b015e]{width:100%}.my-card[data-v-88cf7b28]{border-radius:4px;transition:all .3s cubic-bezier(.645,.045,.355,1)}.my-card[data-v-88cf7b28]:hover{box-shadow:0 2px 12px rgba(0,0,0,.1)}*{margin:0;padding:0;box-sizing:border-box}
2
+ /*$vite$:1*/`,document.head.appendChild(y);const p=t.defineComponent({name:"MyButton",__name:"MyButton",props:{type:{default:"primary"},size:{default:"default"},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},text:{default:""},icon:{},round:{type:Boolean,default:!1},circle:{type:Boolean,default:!1}},emits:["click"],setup(e,{emit:l}){const o=e,c=l,r=u=>{o.disabled||o.loading||c("click",u)};return(u,b)=>(t.openBlock(),t.createBlock(t.unref(f.ElButton),{class:t.normalizeClass(["my-button",`my-button--${e.type}`]),type:e.type,size:e.size,disabled:e.disabled,loading:e.loading,round:e.round,circle:e.circle,onClick:r},{default:t.withCtx(()=>[t.renderSlot(u.$slots,"default",{},()=>[t.createTextVNode(t.toDisplayString(e.text),1)],!0)]),_:3},8,["class","type","size","disabled","loading","round","circle"]))}}),m=(e,l)=>{const o=e.__vccOpts||e;for(const[c,r]of l)o[c]=r;return o},d=m(p,[["__scopeId","data-v-4e6c7abb"]]);d.install=function(e){e.component(d.name,d)};const i=m(t.defineComponent({name:"MyInput",__name:"MyInput",props:{modelValue:{},type:{default:"text"},placeholder:{default:"请输入"},disabled:{type:Boolean,default:!1},clearable:{type:Boolean,default:!1},size:{default:"default"},maxlength:{}},emits:["update:modelValue","change","blur","focus"],setup(e,{emit:l}){const o=l,c=n=>{o("update:modelValue",n)},r=n=>{o("change",n)},u=n=>{o("blur",n)},b=n=>{o("focus",n)};return(n,M)=>(t.openBlock(),t.createBlock(t.unref(f.ElInput),{"model-value":e.modelValue,type:e.type,placeholder:e.placeholder,disabled:e.disabled,clearable:e.clearable,size:e.size,maxlength:e.maxlength,class:"my-input","onUpdate:modelValue":c,onChange:r,onBlur:u,onFocus:b},t.createSlots({_:2},[n.$slots.prefix?{name:"prefix",fn:t.withCtx(()=>[t.renderSlot(n.$slots,"prefix",{},void 0,!0)]),key:"0"}:void 0,n.$slots.suffix?{name:"suffix",fn:t.withCtx(()=>[t.renderSlot(n.$slots,"suffix",{},void 0,!0)]),key:"1"}:void 0]),1032,["model-value","type","placeholder","disabled","clearable","size","maxlength"]))}}),[["__scopeId","data-v-151b015e"]]);i.install=function(e){e.component(i.name,i)};const s=m(t.defineComponent({name:"MyCard",__name:"MyCard",props:{header:{},shadow:{default:"always"},bodyStyle:{}},setup(e){return(l,o)=>(t.openBlock(),t.createBlock(t.unref(f.ElCard),{header:e.header,shadow:e.shadow,"body-style":e.bodyStyle,class:"my-card"},t.createSlots({default:t.withCtx(()=>[t.renderSlot(l.$slots,"default",{},void 0,!0)]),_:2},[l.$slots.header?{name:"header",fn:t.withCtx(()=>[t.renderSlot(l.$slots,"header",{},void 0,!0)]),key:"0"}:void 0]),1032,["header","shadow","body-style"]))}}),[["__scopeId","data-v-88cf7b28"]]);s.install=function(e){e.component(s.name,s)};const x=[d,i,s],h=e=>{x.forEach(l=>{e.use(l)})},g={install:h};a.MyButton=d,a.MyCard=s,a.MyInput=i,a.default=g,a.install=h,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@zzzzzzhaopu/my-ui",
3
+ "version": "1.0.0",
4
+ "description": "基于 Vite + Vue3 的业务组件库",
5
+ "type": "module",
6
+ "main": "./dist/umd/index.js",
7
+ "module": "./dist/es/index.js",
8
+ "types": "./dist/es/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/es/index.js",
12
+ "require": "./dist/umd/index.js",
13
+ "types": "./dist/es/index.d.ts"
14
+ },
15
+ "./es/*": "./dist/es/*",
16
+ "./dist/*": "./dist/*",
17
+ "./package.json": "./package.json"
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "scripts": {
23
+ "dev": "vite",
24
+ "build": "rm -rf dist && vue-tsc && vite build",
25
+ "build:watch": "vite build --watch",
26
+ "preview": "vite preview",
27
+ "docs:dev": "vitepress dev docs",
28
+ "docs:build": "vitepress build docs",
29
+ "docs:preview": "vitepress preview docs",
30
+ "prepublishOnly": "npm run build"
31
+ },
32
+ "keywords": [
33
+ "vue3",
34
+ "component",
35
+ "ui",
36
+ "vite",
37
+ "typescript"
38
+ ],
39
+ "author": "Demo",
40
+ "license": "MIT",
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "peerDependencies": {
45
+ "vue": "^3.4.0"
46
+ },
47
+ "dependencies": {
48
+ "element-plus": "^2.5.0"
49
+ },
50
+ "devDependencies": {
51
+ "@types/node": "^20.10.0",
52
+ "@vitejs/plugin-vue": "^5.0.0",
53
+ "sass": "^1.70.0",
54
+ "typescript": "^5.3.0",
55
+ "vite": "^5.0.0",
56
+ "vite-plugin-dts": "^3.7.0",
57
+ "vite-svg-loader": "^5.1.0",
58
+ "vitepress": "^1.0.0",
59
+ "vue": "^3.4.0",
60
+ "vue-tsc": "^2.0.0"
61
+ }
62
+ }