nbb-component-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.
package/dist/index.css ADDED
@@ -0,0 +1,2 @@
1
+ .my-btn[data-v-8e812d17]{color:#fff;cursor:pointer;border:none;border-radius:4px;padding:8px 16px}
2
+ /*$vite$:1*/
package/dist/index.mjs ADDED
@@ -0,0 +1,25 @@
1
+ import { createElementBlock as e, normalizeStyle as t, openBlock as n, renderSlot as r } from "vue";
2
+ var i = /* @__PURE__ */ ((e, t) => {
3
+ let n = e.__vccOpts || e;
4
+ for (let [e, r] of t) n[e] = r;
5
+ return n;
6
+ })({
7
+ __name: "MyButton",
8
+ props: { bgColor: {
9
+ type: String,
10
+ default: "#409eff"
11
+ } },
12
+ emits: ["click"],
13
+ setup(i, { emit: a }) {
14
+ let o = a, s = () => o("click");
15
+ return (a, o) => (n(), e("button", {
16
+ class: "my-btn",
17
+ style: t({ backgroundColor: i.bgColor }),
18
+ onClick: s
19
+ }, [r(a.$slots, "default", {}, void 0, !0)], 4));
20
+ }
21
+ }, [["__scopeId", "data-v-8e812d17"]]), a = { install: (e) => {
22
+ e.component("MyButton", i);
23
+ } };
24
+ //#endregion
25
+ export { i as MyButton, a as default };
@@ -0,0 +1 @@
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`vue`)):typeof define==`function`&&define.amd?define([`exports`,`vue`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.MyComponent={},e.Vue))})(this,function(e,t){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var n=((e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n})({__name:`MyButton`,props:{bgColor:{type:String,default:`#409eff`}},emits:[`click`],setup(e,{emit:n}){let r=n,i=()=>r(`click`);return(n,r)=>((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{class:`my-btn`,style:(0,t.normalizeStyle)({backgroundColor:e.bgColor}),onClick:i},[(0,t.renderSlot)(n.$slots,`default`,{},void 0,!0)],4))}},[[`__scopeId`,`data-v-8e812d17`]]);e.MyButton=n,e.default={install:e=>{e.component(`MyButton`,n)}}});
package/index.js ADDED
@@ -0,0 +1,9 @@
1
+ import MyButton from './src/MyButton.vue'
2
+ // 支持全局注册
3
+ const install = (app) => {
4
+ app.component('MyButton', MyButton)
5
+ }
6
+ // 支持按需引入
7
+ export { MyButton }
8
+ // 默认导出(全局注册用)
9
+ export default { install }
package/package.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "nbb-component-ui",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "scripts": {
6
+ "build": "vite build"
7
+ },
8
+ "author": "",
9
+ "license": "ISC",
10
+ "description": "",
11
+ "devDependencies": {
12
+ "@vitejs/plugin-vue": "^6.0.5",
13
+ "vite": "^8.0.3"
14
+ }
15
+ }
@@ -0,0 +1,29 @@
1
+ <template>
2
+ <button class="my-btn" :style="{ backgroundColor: bgColor }" @click="handleClick">
3
+ <slot></slot>
4
+ </button>
5
+ </template>
6
+
7
+ <script setup>
8
+ import { defineProps, defineEmits } from 'vue'
9
+ // 定义props
10
+ const props = defineProps({
11
+ bgColor: {
12
+ type: String,
13
+ default: '#409eff'
14
+ }
15
+ })
16
+ // 定义事件
17
+ const emit = defineEmits(['click'])
18
+ const handleClick = () => emit('click')
19
+ </script>
20
+
21
+ <style scoped>
22
+ .my-btn {
23
+ padding: 8px 16px;
24
+ border: none;
25
+ border-radius: 4px;
26
+ color: white;
27
+ cursor: pointer;
28
+ }
29
+ </style>
package/vite.config.js ADDED
@@ -0,0 +1,20 @@
1
+ import { defineConfig } from 'vite'
2
+ import vue from '@vitejs/plugin-vue'
3
+
4
+ export default defineConfig({
5
+ plugins: [vue()],
6
+
7
+ build: {
8
+ lib: {
9
+ entry: 'index.js',
10
+ name: 'MyComponent',
11
+ fileName: 'index'
12
+ },
13
+ rollupOptions: {
14
+ external: ['vue'],
15
+ output: {
16
+ globals: { vue: 'Vue' }
17
+ }
18
+ }
19
+ }
20
+ })