@chase-shao/vue-component-lib 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/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2017 [these people](https://github.com/rollup/rollup-starter-lib/graphs/contributors)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # Vue Component Library
2
+
3
+ [![Build Status](https://img.shields.io/badge/build-passing-brightgreen.svg)](https://github.com/your-username/vue-component-lib)
4
+
5
+ 一个现代化的 Vue 3 组件库,使用 Vite 构建,支持 TypeScript 和 `<script setup>` 语法。
6
+
7
+ ## 特性
8
+
9
+ - 🚀 **Vite 驱动** - 极快的构建速度和开发体验
10
+ - ⚡ **Vue 3** - 完全支持 Composition API 和 `<script setup>`
11
+ - 📦 **TypeScript** - 完整的类型支持
12
+ - 🎨 **CSS 模块化** - 组件样式独立打包
13
+ - 📚 **多格式输出** - ES、CJS、UMD 多种格式支持
14
+
15
+ ## 安装
16
+
17
+ ```bash
18
+ npm install vue-component-lib
19
+ # 或
20
+ pnpm add vue-component-lib
21
+ # 或
22
+ yarn add vue-component-lib
23
+ ```
24
+
25
+ ## 使用
26
+
27
+ ### 作为 Vue 插件使用
28
+
29
+ ```typescript
30
+ import { createApp } from 'vue'
31
+ import MyPlugin from 'vue-component-lib'
32
+ import 'vue-component-lib/dist/index.css'
33
+
34
+ const app = createApp({})
35
+ app.use(MyPlugin)
36
+ ```
37
+
38
+ ### 单独导入组件
39
+
40
+ ```typescript
41
+ import { MyComponent } from 'vue-component-lib'
42
+ import 'vue-component-lib/dist/index.css'
43
+ ```
44
+
45
+ ## 开发
46
+
47
+ ```bash
48
+ # 克隆项目
49
+ git clone https://github.com/your-username/vue-component-lib
50
+ cd vue-component-lib
51
+
52
+ # 安装依赖
53
+ pnpm install
54
+
55
+ # 开发模式(监听文件变化)
56
+ pnpm dev
57
+
58
+ # 构建
59
+ pnpm build
60
+
61
+ # 预览构建结果
62
+ pnpm preview
63
+ ```
64
+
65
+ ## 构建输出
66
+
67
+ - `dist/index.es.js` - ES 模块版本
68
+ - `dist/index.cjs.js` - CommonJS 版本
69
+ - `dist/index.umd.js` - UMD 版本(浏览器直接使用)
70
+ - `dist/index.d.ts` - TypeScript 类型声明
71
+ - `dist/index.css` - 组件样式
72
+
73
+ ## 技术栈
74
+
75
+ - **构建工具**: Vite
76
+ - **框架**: Vue 3
77
+ - **语言**: TypeScript
78
+ - **样式**: CSS with Scoped Styles
79
+
80
+ ## 许可证
81
+
82
+ MIT License
83
+
84
+ `npm test` builds the library, then tests it.
85
+
86
+ ## Variations
87
+
88
+ * [babel](https://github.com/rollup/rollup-starter-lib/tree/babel) — illustrates writing the source code in ES2015 and transpiling it for older environments with [Babel](https://babeljs.io/)
89
+ * [buble](https://github.com/rollup/rollup-starter-lib/tree/buble) — similar, but using [Bublé](https://buble.surge.sh/) which is a faster alternative with less configuration
90
+ * [TypeScript](https://github.com/rollup/rollup-starter-lib/tree/typescript) — uses [TypeScript](https://www.typescriptlang.org/) for type-safe code and transpiling
91
+
92
+
93
+
94
+ ## License
95
+
96
+ [MIT](LICENSE).
@@ -0,0 +1,22 @@
1
+ interface Props {
2
+ title?: string;
3
+ }
4
+ declare function __VLS_template(): {
5
+ attrs: Partial<{}>;
6
+ slots: {
7
+ default?(_: {}): any;
8
+ };
9
+ refs: {};
10
+ rootEl: HTMLDivElement;
11
+ };
12
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
13
+ declare const __VLS_component: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{}>, {
14
+ title: string;
15
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
16
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
17
+ export default _default;
18
+ type __VLS_WithTemplateSlots<T, S> = T & {
19
+ new (): {
20
+ $slots: S;
21
+ };
22
+ };
@@ -0,0 +1,8 @@
1
+ import { App } from 'vue';
2
+ import { default as MyComponent } from './MyComponent.vue';
3
+ import { default as SetupComponent } from './SetupComponent.vue';
4
+ declare const MyPlugin: {
5
+ install(app: App): void;
6
+ };
7
+ export default MyPlugin;
8
+ export { MyComponent, SetupComponent };
@@ -0,0 +1,18 @@
1
+ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
2
+ initialCount: {
3
+ type: NumberConstructor;
4
+ default: number;
5
+ };
6
+ }>, {
7
+ title: import('vue').Ref<string, string>;
8
+ count: import('vue').Ref<number, number>;
9
+ increment: () => void;
10
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
11
+ initialCount: {
12
+ type: NumberConstructor;
13
+ default: number;
14
+ };
15
+ }>> & Readonly<{}>, {
16
+ initialCount: number;
17
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
18
+ export default _default;
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),i={class:"my-component"},a=e.defineComponent({__name:"MyComponent",props:{title:{default:"Hello, Vue 3 with TypeScript!"}},setup(t){const n=t,o=e.ref(n.title);return(r,l)=>(e.openBlock(),e.createElementBlock("div",i,[e.createElementVNode("h2",null,e.toDisplayString(o.value),1),e.renderSlot(r.$slots,"default",{},void 0,!0)]))}}),s=(t,n)=>{const o=t.__vccOpts||t;for(const[r,l]of n)o[r]=l;return o},c=s(a,[["__scopeId","data-v-7649ee09"]]),m=e.defineComponent({name:"SetupComponent",props:{initialCount:{type:Number,default:0}},setup(t){const n=e.ref("Setup API Component"),o=e.ref(t.initialCount);return{title:n,count:o,increment:()=>{o.value++}}}}),d={class:"setup-component"};function f(t,n,o,r,l,C){return e.openBlock(),e.createElementBlock("div",d,[e.createElementVNode("h3",null,e.toDisplayString(t.title),1),e.createElementVNode("p",null,"Count: "+e.toDisplayString(t.count),1),e.createElementVNode("button",{onClick:n[0]||(n[0]=(...u)=>t.increment&&t.increment(...u))},"Increment"),e.renderSlot(t.$slots,"default",{},void 0,!0)])}const p=s(m,[["render",f],["__scopeId","data-v-5f4f20f5"]]),_={install(t){t.component("MyComponent",c),t.component("SetupComponent",p)}};exports.MyComponent=c;exports.SetupComponent=p;exports.default=_;
2
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/MyComponent.vue","../src/SetupComponent.vue","../src/MyPlugin.ts"],"sourcesContent":["<template>\n <div class=\"my-component\">\n <h2>{{ str }}</h2>\n <slot />\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { ref } from 'vue'\n\n// 支持 defineProps, defineEmits 等编译器宏\ninterface Props {\n title?: string\n}\n\nconst props = withDefaults(defineProps<Props>(), {\n title: 'Hello, Vue 3 with TypeScript!'\n})\n\nconst str = ref(props.title)\n</script>\n\n<style scoped>\n.my-component {\n border: 2px solid #42b983;\n padding: 16px;\n border-radius: 8px;\n font-family: sans-serif;\n}\n</style>","<template>\n <div class=\"setup-component\">\n <h3>{{ title }}</h3>\n <p>Count: {{ count }}</p>\n <button @click=\"increment\">Increment</button>\n <slot />\n </div>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent, ref } from 'vue'\n\nexport default defineComponent({\n name: 'SetupComponent',\n props: {\n initialCount: {\n type: Number,\n default: 0\n }\n },\n setup(props) {\n // 这是 <script setup> 的等价写法\n const title = ref('Setup API Component')\n const count = ref(props.initialCount)\n \n const increment = () => {\n count.value++\n }\n \n // 返回模板需要的所有响应式数据和方法\n return {\n title,\n count,\n increment\n }\n }\n})\n</script>\n\n<style scoped>\n.setup-component {\n border: 2px solid #42b983;\n padding: 16px;\n border-radius: 8px;\n font-family: sans-serif;\n margin: 10px 0;\n}\n\nbutton {\n background-color: #42b983;\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n margin-top: 8px;\n}\n\nbutton:hover {\n background-color: #369870;\n}\n</style>\n","import type { App } from 'vue'\nimport MyComponent from './MyComponent.vue'\nimport SetupComponent from './SetupComponent.vue'\n\nconst MyPlugin = {\n install(app: App) {\n app.component('MyComponent', MyComponent)\n app.component('SetupComponent', SetupComponent)\n }\n}\n\nexport default MyPlugin\nexport { MyComponent, SetupComponent }"],"names":["props","__props","str","ref","_openBlock","_createElementBlock","_hoisted_1","_createElementVNode","_renderSlot","_ctx","_sfc_main","defineComponent","title","count","_toDisplayString","_cache","args","MyPlugin","app","MyComponent","SetupComponent"],"mappings":"uQAeA,MAAMA,EAAQC,EAIRC,EAAMC,EAAAA,IAAIH,EAAM,KAAK,gBAlBzBI,YAAA,EAAAC,qBAGM,MAHNC,EAGM,CAFJC,EAAAA,mBAAkB,4BAAXL,EAAA,KAAG,EAAA,CAAA,EACVM,EAAAA,WAAQC,EAAA,OAAA,UAAA,CAAA,EAAA,OAAA,EAAA,CAAA,qHCSZC,EAAeC,kBAAgB,CAC7B,KAAM,iBACN,MAAO,CACL,aAAc,CACZ,KAAM,OACN,QAAS,CAAA,CACX,EAEF,MAAMX,EAAO,CAEX,MAAMY,EAAQT,EAAAA,IAAI,qBAAqB,EACjCU,EAAQV,EAAAA,IAAIH,EAAM,YAAY,EAOpC,MAAO,CACL,MAAAY,EACA,MAAAC,EACA,UARgB,IAAM,CACtBA,EAAM,OACR,CAME,CAEJ,CACF,CAAC,EAnCMP,EAAA,CAAA,MAAM,iBAAA,0BAAX,OAAAF,YAAA,EAAAC,qBAKM,MALNC,EAKM,CAJJC,EAAAA,mBAAoB,4BAAbE,EAAA,KAAK,EAAA,CAAA,EACZF,qBAAyB,IAAA,KAAtB,UAAOO,EAAAA,gBAAGL,EAAA,KAAK,EAAA,CAAA,EAClBF,EAAAA,mBAA6C,SAAA,CAApC,QAAKQ,EAAA,CAAA,IAAAA,EAAA,CAAA,EAAA,IAAAC,IAAEP,EAAA,WAAAA,EAAA,UAAA,GAAAO,CAAA,EAAA,EAAW,WAAS,EACpCR,EAAAA,WAAQC,EAAA,OAAA,UAAA,CAAA,EAAA,OAAA,EAAA,CAAA,CAAA,8DCDNQ,EAAW,CACf,QAAQC,EAAU,CAChBA,EAAI,UAAU,cAAeC,CAAW,EACxCD,EAAI,UAAU,iBAAkBE,CAAc,CAChD,CACF"}
package/dist/index.css ADDED
@@ -0,0 +1 @@
1
+ .my-component[data-v-7649ee09]{border:2px solid #42b983;padding:16px;border-radius:8px;font-family:sans-serif}.setup-component[data-v-5f4f20f5]{border:2px solid #42b983;padding:16px;border-radius:8px;font-family:sans-serif;margin:10px 0}button[data-v-5f4f20f5]{background-color:#42b983;color:#fff;border:none;padding:8px 16px;border-radius:4px;cursor:pointer;margin-top:8px}button[data-v-5f4f20f5]:hover{background-color:#369870}
@@ -0,0 +1,6 @@
1
+ export * from './MyPlugin'
2
+ export {}
3
+ import MyComponentLibrary from './MyPlugin'
4
+ export default MyComponentLibrary
5
+ export * from './MyPlugin'
6
+ export {}
@@ -0,0 +1,58 @@
1
+ import { defineComponent as l, ref as r, createElementBlock as u, openBlock as i, createElementVNode as s, renderSlot as a, toDisplayString as c } from "vue";
2
+ const f = { class: "my-component" }, _ = /* @__PURE__ */ l({
3
+ __name: "MyComponent",
4
+ props: {
5
+ title: { default: "Hello, Vue 3 with TypeScript!" }
6
+ },
7
+ setup(t) {
8
+ const e = r(t.title);
9
+ return (o, p) => (i(), u("div", f, [
10
+ s("h2", null, c(e.value), 1),
11
+ a(o.$slots, "default", {}, void 0, !0)
12
+ ]));
13
+ }
14
+ }), m = (t, n) => {
15
+ const e = t.__vccOpts || t;
16
+ for (const [o, p] of n)
17
+ e[o] = p;
18
+ return e;
19
+ }, C = /* @__PURE__ */ m(_, [["__scopeId", "data-v-7649ee09"]]), v = l({
20
+ name: "SetupComponent",
21
+ props: {
22
+ initialCount: {
23
+ type: Number,
24
+ default: 0
25
+ }
26
+ },
27
+ setup(t) {
28
+ const n = r("Setup API Component"), e = r(t.initialCount);
29
+ return {
30
+ title: n,
31
+ count: e,
32
+ increment: () => {
33
+ e.value++;
34
+ }
35
+ };
36
+ }
37
+ }), y = { class: "setup-component" };
38
+ function $(t, n, e, o, p, h) {
39
+ return i(), u("div", y, [
40
+ s("h3", null, c(t.title), 1),
41
+ s("p", null, "Count: " + c(t.count), 1),
42
+ s("button", {
43
+ onClick: n[0] || (n[0] = (...d) => t.increment && t.increment(...d))
44
+ }, "Increment"),
45
+ a(t.$slots, "default", {}, void 0, !0)
46
+ ]);
47
+ }
48
+ const S = /* @__PURE__ */ m(v, [["render", $], ["__scopeId", "data-v-5f4f20f5"]]), I = {
49
+ install(t) {
50
+ t.component("MyComponent", C), t.component("SetupComponent", S);
51
+ }
52
+ };
53
+ export {
54
+ C as MyComponent,
55
+ S as SetupComponent,
56
+ I as default
57
+ };
58
+ //# sourceMappingURL=index.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.es.js","sources":["../src/MyComponent.vue","../src/SetupComponent.vue","../src/MyPlugin.ts"],"sourcesContent":["<template>\n <div class=\"my-component\">\n <h2>{{ str }}</h2>\n <slot />\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { ref } from 'vue'\n\n// 支持 defineProps, defineEmits 等编译器宏\ninterface Props {\n title?: string\n}\n\nconst props = withDefaults(defineProps<Props>(), {\n title: 'Hello, Vue 3 with TypeScript!'\n})\n\nconst str = ref(props.title)\n</script>\n\n<style scoped>\n.my-component {\n border: 2px solid #42b983;\n padding: 16px;\n border-radius: 8px;\n font-family: sans-serif;\n}\n</style>","<template>\n <div class=\"setup-component\">\n <h3>{{ title }}</h3>\n <p>Count: {{ count }}</p>\n <button @click=\"increment\">Increment</button>\n <slot />\n </div>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent, ref } from 'vue'\n\nexport default defineComponent({\n name: 'SetupComponent',\n props: {\n initialCount: {\n type: Number,\n default: 0\n }\n },\n setup(props) {\n // 这是 <script setup> 的等价写法\n const title = ref('Setup API Component')\n const count = ref(props.initialCount)\n \n const increment = () => {\n count.value++\n }\n \n // 返回模板需要的所有响应式数据和方法\n return {\n title,\n count,\n increment\n }\n }\n})\n</script>\n\n<style scoped>\n.setup-component {\n border: 2px solid #42b983;\n padding: 16px;\n border-radius: 8px;\n font-family: sans-serif;\n margin: 10px 0;\n}\n\nbutton {\n background-color: #42b983;\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n margin-top: 8px;\n}\n\nbutton:hover {\n background-color: #369870;\n}\n</style>\n","import type { App } from 'vue'\nimport MyComponent from './MyComponent.vue'\nimport SetupComponent from './SetupComponent.vue'\n\nconst MyPlugin = {\n install(app: App) {\n app.component('MyComponent', MyComponent)\n app.component('SetupComponent', SetupComponent)\n }\n}\n\nexport default MyPlugin\nexport { MyComponent, SetupComponent }"],"names":["str","ref","__props","_openBlock","_createElementBlock","_hoisted_1","_createElementVNode","_renderSlot","_ctx","_sfc_main","defineComponent","props","title","count","_toDisplayString","_cache","args","MyPlugin","app","MyComponent","SetupComponent"],"mappings":";;;;;;;AAmBA,UAAMA,IAAMC,EAJEC,EAIQ,KAAK;sBAlBzBC,EAAA,GAAAC,EAGM,OAHNC,GAGM;AAAA,MAFJC,EAAkB,cAAXN,EAAA,KAAG,GAAA,CAAA;AAAA,MACVO,EAAQC,EAAA,QAAA,WAAA,CAAA,GAAA,QAAA,EAAA;AAAA,IAAA;;;;;;;iECSZC,IAAeC,EAAgB;AAAA,EAC7B,MAAM;AAAA,EACN,OAAO;AAAA,IACL,cAAc;AAAA,MACZ,MAAM;AAAA,MACN,SAAS;AAAA,IAAA;AAAA,EACX;AAAA,EAEF,MAAMC,GAAO;AAEX,UAAMC,IAAQX,EAAI,qBAAqB,GACjCY,IAAQZ,EAAIU,EAAM,YAAY;AAOpC,WAAO;AAAA,MACL,OAAAC;AAAA,MACA,OAAAC;AAAA,MACA,WARgB,MAAM;AACtB,QAAAA,EAAM;AAAA,MACR;AAAA,IAME;AAAA,EAEJ;AACF,CAAC,GAnCMR,IAAA,EAAA,OAAM,kBAAA;;AAAX,SAAAF,EAAA,GAAAC,EAKM,OALNC,GAKM;AAAA,IAJJC,EAAoB,cAAbE,EAAA,KAAK,GAAA,CAAA;AAAA,IACZF,EAAyB,KAAA,MAAtB,YAAOQ,EAAGN,EAAA,KAAK,GAAA,CAAA;AAAA,IAClBF,EAA6C,UAAA;AAAA,MAApC,SAAKS,EAAA,CAAA,MAAAA,EAAA,CAAA,IAAA,IAAAC,MAAER,EAAA,aAAAA,EAAA,UAAA,GAAAQ,CAAA;AAAA,IAAA,GAAW,WAAS;AAAA,IACpCT,EAAQC,EAAA,QAAA,WAAA,CAAA,GAAA,QAAA,EAAA;AAAA,EAAA,CAAA;;mFCDNS,IAAW;AAAA,EACf,QAAQC,GAAU;AAChB,IAAAA,EAAI,UAAU,eAAeC,CAAW,GACxCD,EAAI,UAAU,kBAAkBE,CAAc;AAAA,EAChD;AACF;"}
@@ -0,0 +1,2 @@
1
+ (function(n,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(n=typeof globalThis<"u"?globalThis:n||self,e(n.MyComponentLibrary={},n.Vue))})(this,function(n,e){"use strict";const d={class:"my-component"},m=e.defineComponent({__name:"MyComponent",props:{title:{default:"Hello, Vue 3 with TypeScript!"}},setup(t){const o=t,i=e.ref(o.title);return(r,s)=>(e.openBlock(),e.createElementBlock("div",d,[e.createElementVNode("h2",null,e.toDisplayString(i.value),1),e.renderSlot(r.$slots,"default",{},void 0,!0)]))}}),l=(t,o)=>{const i=t.__vccOpts||t;for(const[r,s]of o)i[r]=s;return i},p=l(m,[["__scopeId","data-v-7649ee09"]]),u=e.defineComponent({name:"SetupComponent",props:{initialCount:{type:Number,default:0}},setup(t){const o=e.ref("Setup API Component"),i=e.ref(t.initialCount);return{title:o,count:i,increment:()=>{i.value++}}}}),a={class:"setup-component"};function f(t,o,i,r,s,C){return e.openBlock(),e.createElementBlock("div",a,[e.createElementVNode("h3",null,e.toDisplayString(t.title),1),e.createElementVNode("p",null,"Count: "+e.toDisplayString(t.count),1),e.createElementVNode("button",{onClick:o[0]||(o[0]=(...y)=>t.increment&&t.increment(...y))},"Increment"),e.renderSlot(t.$slots,"default",{},void 0,!0)])}const c=l(u,[["render",f],["__scopeId","data-v-5f4f20f5"]]),_={install(t){t.component("MyComponent",p),t.component("SetupComponent",c)}};n.MyComponent=p,n.SetupComponent=c,n.default=_,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
2
+ //# sourceMappingURL=index.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.umd.js","sources":["../src/MyComponent.vue","../src/SetupComponent.vue","../src/MyPlugin.ts"],"sourcesContent":["<template>\n <div class=\"my-component\">\n <h2>{{ str }}</h2>\n <slot />\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { ref } from 'vue'\n\n// 支持 defineProps, defineEmits 等编译器宏\ninterface Props {\n title?: string\n}\n\nconst props = withDefaults(defineProps<Props>(), {\n title: 'Hello, Vue 3 with TypeScript!'\n})\n\nconst str = ref(props.title)\n</script>\n\n<style scoped>\n.my-component {\n border: 2px solid #42b983;\n padding: 16px;\n border-radius: 8px;\n font-family: sans-serif;\n}\n</style>","<template>\n <div class=\"setup-component\">\n <h3>{{ title }}</h3>\n <p>Count: {{ count }}</p>\n <button @click=\"increment\">Increment</button>\n <slot />\n </div>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent, ref } from 'vue'\n\nexport default defineComponent({\n name: 'SetupComponent',\n props: {\n initialCount: {\n type: Number,\n default: 0\n }\n },\n setup(props) {\n // 这是 <script setup> 的等价写法\n const title = ref('Setup API Component')\n const count = ref(props.initialCount)\n \n const increment = () => {\n count.value++\n }\n \n // 返回模板需要的所有响应式数据和方法\n return {\n title,\n count,\n increment\n }\n }\n})\n</script>\n\n<style scoped>\n.setup-component {\n border: 2px solid #42b983;\n padding: 16px;\n border-radius: 8px;\n font-family: sans-serif;\n margin: 10px 0;\n}\n\nbutton {\n background-color: #42b983;\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n margin-top: 8px;\n}\n\nbutton:hover {\n background-color: #369870;\n}\n</style>\n","import type { App } from 'vue'\nimport MyComponent from './MyComponent.vue'\nimport SetupComponent from './SetupComponent.vue'\n\nconst MyPlugin = {\n install(app: App) {\n app.component('MyComponent', MyComponent)\n app.component('SetupComponent', SetupComponent)\n }\n}\n\nexport default MyPlugin\nexport { MyComponent, SetupComponent }"],"names":["props","__props","str","ref","_openBlock","_createElementBlock","_hoisted_1","_createElementVNode","_renderSlot","_ctx","_sfc_main","defineComponent","title","count","_toDisplayString","_cache","args","MyPlugin","app","MyComponent","SetupComponent"],"mappings":"iZAeA,MAAMA,EAAQC,EAIRC,EAAMC,EAAAA,IAAIH,EAAM,KAAK,gBAlBzBI,YAAA,EAAAC,qBAGM,MAHNC,EAGM,CAFJC,EAAAA,mBAAkB,4BAAXL,EAAA,KAAG,EAAA,CAAA,EACVM,EAAAA,WAAQC,EAAA,OAAA,UAAA,CAAA,EAAA,OAAA,EAAA,CAAA,qHCSZC,EAAeC,kBAAgB,CAC7B,KAAM,iBACN,MAAO,CACL,aAAc,CACZ,KAAM,OACN,QAAS,CAAA,CACX,EAEF,MAAMX,EAAO,CAEX,MAAMY,EAAQT,EAAAA,IAAI,qBAAqB,EACjCU,EAAQV,EAAAA,IAAIH,EAAM,YAAY,EAOpC,MAAO,CACL,MAAAY,EACA,MAAAC,EACA,UARgB,IAAM,CACtBA,EAAM,OACR,CAME,CAEJ,CACF,CAAC,EAnCMP,EAAA,CAAA,MAAM,iBAAA,0BAAX,OAAAF,YAAA,EAAAC,qBAKM,MALNC,EAKM,CAJJC,EAAAA,mBAAoB,4BAAbE,EAAA,KAAK,EAAA,CAAA,EACZF,qBAAyB,IAAA,KAAtB,UAAOO,EAAAA,gBAAGL,EAAA,KAAK,EAAA,CAAA,EAClBF,EAAAA,mBAA6C,SAAA,CAApC,QAAKQ,EAAA,CAAA,IAAAA,EAAA,CAAA,EAAA,IAAAC,IAAEP,EAAA,WAAAA,EAAA,UAAA,GAAAO,CAAA,EAAA,EAAW,WAAS,EACpCR,EAAAA,WAAQC,EAAA,OAAA,UAAA,CAAA,EAAA,OAAA,EAAA,CAAA,CAAA,8DCDNQ,EAAW,CACf,QAAQC,EAAU,CAChBA,EAAI,UAAU,cAAeC,CAAW,EACxCD,EAAI,UAAU,iBAAkBE,CAAc,CAChD,CACF"}
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@chase-shao/vue-component-lib",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "main": "dist/index.cjs.js",
6
+ "module": "dist/index.es.js",
7
+ "browser": "dist/index.umd.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.es.js",
13
+ "require": "./dist/index.cjs.js"
14
+ },
15
+ "./dist/style.css": "./dist/index.css"
16
+ },
17
+ "dependencies": {},
18
+ "devDependencies": {
19
+ "@vitejs/plugin-vue": "^6.0.1",
20
+ "@vue/compiler-sfc": "^3.5.18",
21
+ "tslib": "^2.8.1",
22
+ "typescript": "^5.9.2",
23
+ "vite": "^7.0.6",
24
+ "vite-plugin-dts": "^4.5.4",
25
+ "vue": "^3.5.18"
26
+ },
27
+ "scripts": {
28
+ "build": "vite build",
29
+ "dev": "vite build --watch",
30
+ "preview": "vite preview",
31
+ "test": "node test/test.js",
32
+ "pretest": "npm run build"
33
+ },
34
+ "files": [
35
+ "dist"
36
+ ],
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
40
+ "keywords": [
41
+ "vue",
42
+ "vue3",
43
+ "component",
44
+ "library",
45
+ "typescript",
46
+ "vite"
47
+ ],
48
+ "author": "chase-shao",
49
+ "license": "MIT",
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/your-username/vue-component-lib.git"
53
+ },
54
+ "bugs": {
55
+ "url": "https://github.com/your-username/vue-component-lib/issues"
56
+ },
57
+ "homepage": "https://github.com/your-username/vue-component-lib#readme",
58
+ "peerDependencies": {
59
+ "vue": "^3.5.18"
60
+ }
61
+ }