fy-components-test 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.
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # @miaoma/components
2
+
3
+ 基于 Element Plus 的二次封装组件库,提供更加易用、美观的 UI 组件。
4
+
5
+ ## 特性
6
+
7
+ - 基于 Element Plus 二次封装
8
+ - 支持 Vue 3 + TypeScript
9
+ - 现代化的设计风格
10
+ - 丰富的组件库
11
+ - 完善的文档
12
+
13
+ ## 安装
14
+
15
+ ```bash
16
+ # 使用 npm
17
+ npm install @miaoma/components element-plus
18
+
19
+ # 使用 pnpm
20
+ pnpm add @miaoma/components element-plus
21
+
22
+ # 使用 yarn
23
+ yarn add @miaoma/components element-plus
24
+ ```
25
+
26
+ ## 引入
27
+
28
+ ### 全局引入
29
+
30
+ ```ts
31
+ import { createApp } from 'vue'
32
+ import App from './App.vue'
33
+ import ElementPlus from 'element-plus'
34
+ import 'element-plus/dist/index.css'
35
+ import MiaomaComponents from '@miaoma/components'
36
+
37
+ const app = createApp(App)
38
+ app.use(ElementPlus)
39
+ app.use(MiaomaComponents)
40
+ app.mount('#app')
41
+ ```
42
+
43
+ ### 按需引入
44
+
45
+ ```ts
46
+ import { MButton } from '@miaoma/components'
47
+ ```
48
+
49
+ ## 组件列表
50
+
51
+ - MButton - 按钮组件
52
+
53
+ ## 文档
54
+
55
+ 详细文档请查看 [官方文档](https://miaoma-components-docs.netlify.app/)
56
+
57
+ ## 浏览器支持
58
+
59
+ - Chrome
60
+ - Firefox
61
+ - Safari
62
+ - Edge
63
+
64
+ ## 许可证
65
+
66
+ MIT
@@ -0,0 +1,3 @@
1
+ export * from './src/index'
2
+ import MiaomaComponents from './src/index'
3
+ export default MiaomaComponents
@@ -0,0 +1,126 @@
1
+ import { defineComponent as c, resolveComponent as u, openBlock as o, createBlock as d, withCtx as r, renderSlot as s, createElementBlock as f, Fragment as y, createTextVNode as g, toDisplayString as m } from "vue";
2
+ const p = {
3
+ name: "MButton"
4
+ }, v = /* @__PURE__ */ c({
5
+ ...p,
6
+ props: {
7
+ // 按钮类型
8
+ type: {
9
+ type: String,
10
+ default: "primary",
11
+ validator: (t) => [
12
+ "primary",
13
+ "success",
14
+ "warning",
15
+ "danger",
16
+ "info",
17
+ "text"
18
+ ].includes(t)
19
+ },
20
+ // 按钮尺寸
21
+ size: {
22
+ type: String,
23
+ default: "default",
24
+ validator: (t) => ["large", "default", "small", "mini"].includes(t)
25
+ },
26
+ // 是否朴素按钮
27
+ plain: {
28
+ type: Boolean,
29
+ default: !1
30
+ },
31
+ // 是否圆角按钮
32
+ round: {
33
+ type: Boolean,
34
+ default: !1
35
+ },
36
+ // 是否圆形按钮
37
+ circle: {
38
+ type: Boolean,
39
+ default: !1
40
+ },
41
+ // 是否禁用
42
+ disabled: {
43
+ type: Boolean,
44
+ default: !1
45
+ },
46
+ // 是否加载中
47
+ loading: {
48
+ type: Boolean,
49
+ default: !1
50
+ },
51
+ // 图标
52
+ icon: {
53
+ type: String,
54
+ default: ""
55
+ },
56
+ // 按钮文本
57
+ text: {
58
+ type: String,
59
+ default: ""
60
+ },
61
+ // 是否自动聚焦
62
+ autofocus: {
63
+ type: Boolean,
64
+ default: !1
65
+ },
66
+ // 原生 type 属性
67
+ nativeType: {
68
+ type: String,
69
+ default: "button",
70
+ validator: (t) => ["button", "submit", "reset"].includes(t)
71
+ },
72
+ // 自定义标签
73
+ tag: {
74
+ type: String,
75
+ default: "button"
76
+ }
77
+ },
78
+ emits: ["click"],
79
+ setup(t, { emit: e }) {
80
+ const n = e, l = (a) => {
81
+ n("click", a);
82
+ };
83
+ return (a, x) => {
84
+ const i = u("el-button");
85
+ return o(), d(i, {
86
+ type: t.type,
87
+ size: t.size,
88
+ plain: t.plain,
89
+ round: t.round,
90
+ circle: t.circle,
91
+ disabled: t.disabled,
92
+ loading: t.loading,
93
+ icon: t.icon,
94
+ autofocus: t.autofocus,
95
+ "native-type": t.nativeType,
96
+ tag: t.tag,
97
+ onClick: l
98
+ }, {
99
+ default: r(() => [
100
+ a.$slots.default ? s(a.$slots, "default", { key: 0 }, void 0, !0) : (o(), f(y, { key: 1 }, [
101
+ g(m(t.text), 1)
102
+ ], 64))
103
+ ]),
104
+ _: 3
105
+ }, 8, ["type", "size", "plain", "round", "circle", "disabled", "loading", "icon", "autofocus", "native-type", "tag"]);
106
+ };
107
+ }
108
+ }), B = (t, e) => {
109
+ const n = t.__vccOpts || t;
110
+ for (const [l, a] of e)
111
+ n[l] = a;
112
+ return n;
113
+ }, b = /* @__PURE__ */ B(v, [["__scopeId", "data-v-79154a89"]]), k = [
114
+ b
115
+ ], S = (t) => {
116
+ k.forEach((e) => {
117
+ e.name && t.component(e.name, e);
118
+ });
119
+ }, h = {
120
+ install: S
121
+ };
122
+ export {
123
+ b as MButton,
124
+ h as default,
125
+ S as install
126
+ };
@@ -0,0 +1 @@
1
+ (function(n,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(n=typeof globalThis<"u"?globalThis:n||self,t(n.MiaomaComponents={},n.Vue))})(this,function(n,t){"use strict";const u={name:"MButton"},s=t.defineComponent({...u,props:{type:{type:String,default:"primary",validator:e=>["primary","success","warning","danger","info","text"].includes(e)},size:{type:String,default:"default",validator:e=>["large","default","small","mini"].includes(e)},plain:{type:Boolean,default:!1},round:{type:Boolean,default:!1},circle:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},icon:{type:String,default:""},text:{type:String,default:""},autofocus:{type:Boolean,default:!1},nativeType:{type:String,default:"button",validator:e=>["button","submit","reset"].includes(e)},tag:{type:String,default:"button"}},emits:["click"],setup(e,{emit:a}){const l=a,i=o=>{l("click",o)};return(o,m)=>{const y=t.resolveComponent("el-button");return t.openBlock(),t.createBlock(y,{type:e.type,size:e.size,plain:e.plain,round:e.round,circle:e.circle,disabled:e.disabled,loading:e.loading,icon:e.icon,autofocus:e.autofocus,"native-type":e.nativeType,tag:e.tag,onClick:i},{default:t.withCtx(()=>[o.$slots.default?t.renderSlot(o.$slots,"default",{key:0},void 0,!0):(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[t.createTextVNode(t.toDisplayString(e.text),1)],64))]),_:3},8,["type","size","plain","round","circle","disabled","loading","icon","autofocus","native-type","tag"])}}}),d=((e,a)=>{const l=e.__vccOpts||e;for(const[i,o]of a)l[i]=o;return l})(s,[["__scopeId","data-v-79154a89"]]),f=[d],c=e=>{f.forEach(a=>{a.name&&e.component(a.name,a)})},r={install:c};n.MButton=d,n.default=r,n.install=c,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -0,0 +1,130 @@
1
+ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<import('vue').ExtractPropTypes<{
2
+ type: {
3
+ type: StringConstructor;
4
+ default: string;
5
+ validator: (value: string) => boolean;
6
+ };
7
+ size: {
8
+ type: StringConstructor;
9
+ default: string;
10
+ validator: (value: string) => boolean;
11
+ };
12
+ plain: {
13
+ type: BooleanConstructor;
14
+ default: boolean;
15
+ };
16
+ round: {
17
+ type: BooleanConstructor;
18
+ default: boolean;
19
+ };
20
+ circle: {
21
+ type: BooleanConstructor;
22
+ default: boolean;
23
+ };
24
+ disabled: {
25
+ type: BooleanConstructor;
26
+ default: boolean;
27
+ };
28
+ loading: {
29
+ type: BooleanConstructor;
30
+ default: boolean;
31
+ };
32
+ icon: {
33
+ type: StringConstructor;
34
+ default: string;
35
+ };
36
+ text: {
37
+ type: StringConstructor;
38
+ default: string;
39
+ };
40
+ autofocus: {
41
+ type: BooleanConstructor;
42
+ default: boolean;
43
+ };
44
+ nativeType: {
45
+ type: StringConstructor;
46
+ default: string;
47
+ validator: (value: string) => boolean;
48
+ };
49
+ tag: {
50
+ type: StringConstructor;
51
+ default: string;
52
+ };
53
+ }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
54
+ click: (...args: any[]) => void;
55
+ }, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
56
+ type: {
57
+ type: StringConstructor;
58
+ default: string;
59
+ validator: (value: string) => boolean;
60
+ };
61
+ size: {
62
+ type: StringConstructor;
63
+ default: string;
64
+ validator: (value: string) => boolean;
65
+ };
66
+ plain: {
67
+ type: BooleanConstructor;
68
+ default: boolean;
69
+ };
70
+ round: {
71
+ type: BooleanConstructor;
72
+ default: boolean;
73
+ };
74
+ circle: {
75
+ type: BooleanConstructor;
76
+ default: boolean;
77
+ };
78
+ disabled: {
79
+ type: BooleanConstructor;
80
+ default: boolean;
81
+ };
82
+ loading: {
83
+ type: BooleanConstructor;
84
+ default: boolean;
85
+ };
86
+ icon: {
87
+ type: StringConstructor;
88
+ default: string;
89
+ };
90
+ text: {
91
+ type: StringConstructor;
92
+ default: string;
93
+ };
94
+ autofocus: {
95
+ type: BooleanConstructor;
96
+ default: boolean;
97
+ };
98
+ nativeType: {
99
+ type: StringConstructor;
100
+ default: string;
101
+ validator: (value: string) => boolean;
102
+ };
103
+ tag: {
104
+ type: StringConstructor;
105
+ default: string;
106
+ };
107
+ }>> & Readonly<{
108
+ onClick?: ((...args: any[]) => any) | undefined;
109
+ }>, {
110
+ type: string;
111
+ size: string;
112
+ plain: boolean;
113
+ round: boolean;
114
+ circle: boolean;
115
+ disabled: boolean;
116
+ loading: boolean;
117
+ icon: string;
118
+ text: string;
119
+ autofocus: boolean;
120
+ nativeType: string;
121
+ tag: string;
122
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>, {
123
+ default?(_: {}): any;
124
+ }>;
125
+ export default _default;
126
+ type __VLS_WithTemplateSlots<T, S> = T & {
127
+ new (): {
128
+ $slots: S;
129
+ };
130
+ };
@@ -0,0 +1,9 @@
1
+ import { App } from 'vue';
2
+ import { default as MButton } from './components/MButton.vue';
3
+
4
+ export declare const install: (app: App) => void;
5
+ export { MButton };
6
+ declare const _default: {
7
+ install: (app: App) => void;
8
+ };
9
+ export default _default;
@@ -0,0 +1 @@
1
+
package/dist/style.css ADDED
File without changes
@@ -0,0 +1,2 @@
1
+ declare const _default: import('vite').UserConfig;
2
+ export default _default;
package/index.html ADDED
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>组件库测试</title>
8
+ </head>
9
+ <body>
10
+ <div id="app"></div>
11
+ <script type="module" src="/src/main.ts"></script>
12
+ </body>
13
+ </html>
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "fy-components-test",
3
+ "version": "1.0.0",
4
+ "description": "基于 Element Plus 的二次封装组件库",
5
+ "type": "module",
6
+ "main": "./dist/index.umd.js",
7
+ "module": "./dist/index.es.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.es.js",
12
+ "require": "./dist/index.umd.js",
13
+ "types": "./dist/index.d.ts"
14
+ }
15
+ },
16
+ "scripts": {
17
+ "dev": "vite",
18
+ "build": "vite build",
19
+ "preview": "vite preview"
20
+ },
21
+ "dependencies": {
22
+ "element-plus": "^2.6.0",
23
+ "vue": "^3.4.0"
24
+ },
25
+ "devDependencies": {
26
+ "@types/node": "^25.5.2",
27
+ "@vitejs/plugin-vue": "^5.0.0",
28
+ "typescript": "^5.3.0",
29
+ "vite": "^5.0.0",
30
+ "vite-plugin-dts": "^3.7.0"
31
+ },
32
+ "keywords": [
33
+ "vue3",
34
+ "element-plus",
35
+ "components"
36
+ ],
37
+ "author": "",
38
+ "license": "MIT"
39
+ }
package/src/App.vue ADDED
@@ -0,0 +1,27 @@
1
+ <template>
2
+ <div style="padding: 20px;">
3
+ <h1>组件库测试</h1>
4
+ <div style="display: flex; gap: 10px; margin: 20px 0;">
5
+ <m-button type="primary" text="主要按钮" />
6
+ <m-button type="success" text="成功按钮" />
7
+ <m-button type="warning" text="警告按钮" />
8
+ <m-button type="danger" text="危险按钮" />
9
+ <m-button type="info" text="信息按钮" />
10
+ </div>
11
+ <div style="display: flex; gap: 10px; margin: 20px 0;">
12
+ <m-button type="primary" size="large" text="大按钮" />
13
+ <m-button type="primary" size="default" text="默认按钮" />
14
+ <m-button type="primary" size="small" text="小按钮" />
15
+ <m-button type="primary" size="mini" text="迷你按钮" />
16
+ </div>
17
+ <div style="display: flex; gap: 10px; margin: 20px 0;">
18
+ <m-button type="primary" plain text="朴素按钮" />
19
+ <m-button type="primary" round text="圆角按钮" />
20
+ <m-button type="primary" circle icon="el-icon-search" />
21
+ </div>
22
+ </div>
23
+ </template>
24
+
25
+ <script setup lang="ts">
26
+ import { MButton } from './index'
27
+ </script>
@@ -0,0 +1,122 @@
1
+ <template>
2
+ <el-button
3
+ :type="type"
4
+ :size="size"
5
+ :plain="plain"
6
+ :round="round"
7
+ :circle="circle"
8
+ :disabled="disabled"
9
+ :loading="loading"
10
+ :icon="icon"
11
+ :autofocus="autofocus"
12
+ :native-type="nativeType"
13
+ :tag="tag"
14
+ @click="handleClick"
15
+ >
16
+ <template v-if="$slots.default">
17
+ <slot></slot>
18
+ </template>
19
+ <template v-else>
20
+ {{ text }}
21
+ </template>
22
+ </el-button>
23
+ </template>
24
+
25
+ <script lang="ts">
26
+ export default {
27
+ name: 'MButton',
28
+ };
29
+ </script>
30
+
31
+ <script setup lang="ts">
32
+ import { defineProps, defineEmits } from 'vue';
33
+
34
+ defineProps({
35
+ // 按钮类型
36
+ type: {
37
+ type: String,
38
+ default: 'primary',
39
+ validator: (value: string) => {
40
+ return [
41
+ 'primary',
42
+ 'success',
43
+ 'warning',
44
+ 'danger',
45
+ 'info',
46
+ 'text',
47
+ ].includes(value);
48
+ },
49
+ },
50
+ // 按钮尺寸
51
+ size: {
52
+ type: String,
53
+ default: 'default',
54
+ validator: (value: string) => {
55
+ return ['large', 'default', 'small', 'mini'].includes(value);
56
+ },
57
+ },
58
+ // 是否朴素按钮
59
+ plain: {
60
+ type: Boolean,
61
+ default: false,
62
+ },
63
+ // 是否圆角按钮
64
+ round: {
65
+ type: Boolean,
66
+ default: false,
67
+ },
68
+ // 是否圆形按钮
69
+ circle: {
70
+ type: Boolean,
71
+ default: false,
72
+ },
73
+ // 是否禁用
74
+ disabled: {
75
+ type: Boolean,
76
+ default: false,
77
+ },
78
+ // 是否加载中
79
+ loading: {
80
+ type: Boolean,
81
+ default: false,
82
+ },
83
+ // 图标
84
+ icon: {
85
+ type: String,
86
+ default: '',
87
+ },
88
+ // 按钮文本
89
+ text: {
90
+ type: String,
91
+ default: '',
92
+ },
93
+ // 是否自动聚焦
94
+ autofocus: {
95
+ type: Boolean,
96
+ default: false,
97
+ },
98
+ // 原生 type 属性
99
+ nativeType: {
100
+ type: String,
101
+ default: 'button',
102
+ validator: (value: string) => {
103
+ return ['button', 'submit', 'reset'].includes(value);
104
+ },
105
+ },
106
+ // 自定义标签
107
+ tag: {
108
+ type: String,
109
+ default: 'button',
110
+ },
111
+ });
112
+
113
+ const emit = defineEmits(['click']);
114
+
115
+ const handleClick = (event: MouseEvent) => {
116
+ emit('click', event);
117
+ };
118
+ </script>
119
+
120
+ <style scoped>
121
+ /* 可以添加自定义样式 */
122
+ </style>
package/src/index.ts ADDED
@@ -0,0 +1,22 @@
1
+ import type { App } from 'vue'
2
+ import MButton from './components/MButton.vue'
3
+
4
+ const components = [
5
+ MButton
6
+ ]
7
+
8
+ export const install = (app: App) => {
9
+ components.forEach(component => {
10
+ if (component.name) {
11
+ app.component(component.name, component)
12
+ }
13
+ })
14
+ }
15
+
16
+ export {
17
+ MButton
18
+ }
19
+
20
+ export default {
21
+ install
22
+ }
package/src/main.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { createApp } from 'vue'
2
+ import App from './App.vue'
3
+ import ElementPlus from 'element-plus'
4
+ import 'element-plus/dist/index.css'
5
+ import MiaomaComponents from './index'
6
+
7
+ const app = createApp(App)
8
+ app.use(ElementPlus)
9
+ app.use(MiaomaComponents)
10
+ app.mount('#app')
package/vite.config.ts ADDED
@@ -0,0 +1,32 @@
1
+ import { defineConfig } from 'vite'
2
+ import vue from '@vitejs/plugin-vue'
3
+ import dts from 'vite-plugin-dts'
4
+ import { resolve } from 'path'
5
+ import { fileURLToPath, URL } from 'url'
6
+
7
+ const __dirname = fileURLToPath(new URL('.', import.meta.url))
8
+
9
+ export default defineConfig({
10
+ plugins: [
11
+ vue(),
12
+ dts({
13
+ insertTypesEntry: true
14
+ })
15
+ ],
16
+ build: {
17
+ lib: {
18
+ entry: resolve(__dirname, 'src/index.ts'),
19
+ name: 'MiaomaComponents',
20
+ fileName: (format) => `index.${format}.js`
21
+ },
22
+ rollupOptions: {
23
+ external: ['vue', 'element-plus'],
24
+ output: {
25
+ globals: {
26
+ vue: 'Vue',
27
+ 'element-plus': 'ElementPlus'
28
+ }
29
+ }
30
+ }
31
+ }
32
+ })