morghulis 2.0.59 → 2.0.60

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 CHANGED
@@ -1,33 +1,99 @@
1
- # button2
1
+ # Morghulis 按钮组件
2
2
 
3
- This template should help get you started developing with Vue 3 in Vite.
3
+ 一个简单的Vue 3 TypeScript按钮组件库,提供美观且易用的按钮组件。
4
4
 
5
- ## Recommended IDE Setup
5
+ ## 安装
6
6
 
7
- [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
7
+ ```bash
8
+ npm install morghulis
9
+ ```
8
10
 
9
- ## Type Support for `.vue` Imports in TS
11
+ ## 使用
10
12
 
11
- TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
13
+ ### 基本用法
12
14
 
13
- ## Customize configuration
15
+ ```vue
16
+ <template>
17
+ <MButton>默认按钮</MButton>
18
+ <MButton color="success" round>成功按钮</MButton>
19
+ <MButton color="warning" size="large">警告按钮</MButton>
20
+ <MButton color="danger" disabled>危险按钮</MButton>
21
+ </template>
14
22
 
15
- See [Vite Configuration Reference](https://vite.dev/config/).
23
+ <script setup lang="ts">
24
+ import { MButton } from 'morghulis'
25
+ </script>
26
+ ```
16
27
 
17
- ## Project Setup
28
+ ### 导入样式
18
29
 
19
- ```sh
20
- npm install
30
+ ```ts
31
+ // 在main.ts中导入样式
32
+ import 'morghulis/dist/morghulis.css'
21
33
  ```
22
34
 
23
- ### Compile and Hot-Reload for Development
35
+ ### 使用弹窗功能
36
+
37
+ ```vue
38
+ <template>
39
+ <MButton ref="buttonRef" popupMessage="自定义弹窗消息">点击弹窗</MButton>
40
+ <button @click="showCustomPopup">手动调用弹窗</button>
41
+ </template>
42
+
43
+ <script setup lang="ts">
44
+ import { ref } from 'vue'
45
+ import { MButton } from 'morghulis'
24
46
 
25
- ```sh
26
- npm run dev
47
+ const buttonRef = ref()
48
+
49
+ function showCustomPopup() {
50
+ buttonRef.value.popup('这是一个自定义弹窗!')
51
+ }
52
+ </script>
27
53
  ```
28
54
 
29
- ### Type-Check, Compile and Minify for Production
55
+ ## API
56
+
57
+ ### 属性
58
+
59
+ | 属性名 | 类型 | 默认值 | 可选值 | 说明 |
60
+ |-------|------|-------|-------|------|
61
+ | color | string | 'primary' | 'primary', 'success', 'warning', 'danger', 'info' | 按钮颜色 |
62
+ | size | string | 'medium' | 'small', 'medium', 'large' | 按钮尺寸 |
63
+ | round | boolean | false | - | 是否为圆角按钮 |
64
+ | disabled | boolean | false | - | 是否禁用 |
65
+ | popupMessage | string | '按钮被点击!' | - | 自定义弹窗消息 |
66
+
67
+ ### 事件
68
+
69
+ | 事件名 | 参数 | 说明 |
70
+ |-------|------|------|
71
+ | click | MouseEvent | 按钮点击事件 |
72
+ | popup | string | 弹窗显示事件,参数为弹窗消息 |
73
+
74
+ ### 方法
75
+
76
+ | 方法名 | 参数 | 返回值 | 说明 |
77
+ |-------|------|-------|------|
78
+ | popup | message: string | string | 显示弹窗,参数为弹窗消息 |
79
+
80
+ ## Python使用方法
81
+
82
+ 当使用pip安装morghulis包后,您可以在Python项目中使用此组件,并享受自动代码补全功能。
83
+
84
+ ```python
85
+ # 在您的Python项目中使用
86
+ from morghulis import MButton
87
+
88
+ # 创建按钮实例
89
+ button = MButton(
90
+ color="primary",
91
+ size="medium",
92
+ round=True,
93
+ disabled=False,
94
+ popupMessage="这是一个弹窗消息"
95
+ )
30
96
 
31
- ```sh
32
- npm run build
97
+ # 调用按钮方法
98
+ button.popup("显示自定义弹窗")
33
99
  ```
@@ -0,0 +1,46 @@
1
+ import { DefineComponent } from 'vue';
2
+
3
+
4
+ export type ButtonColor = 'primary' | 'success' | 'warning' | 'danger' | 'info'
5
+ export type ButtonSize = 'small' | 'medium' | 'large'
6
+
7
+ export interface ButtonProps {
8
+ /**
9
+ * 按钮颜色
10
+ */
11
+ color?: ButtonColor
12
+ /**
13
+ * 是否为圆角按钮
14
+ */
15
+ round?: boolean
16
+ /**
17
+ * 按钮尺寸
18
+ */
19
+ size?: ButtonSize
20
+ /**
21
+ * 是否禁用
22
+ */
23
+ disabled?: boolean
24
+ /**
25
+ * 自定义弹窗消息
26
+ */
27
+ popupMessage?: string
28
+ }
29
+
30
+ export interface ButtonEmits {
31
+ (e: 'click', event: MouseEvent): void
32
+ (e: 'popup', message: string): void
33
+ }
34
+
35
+ export interface ButtonExpose {
36
+ /**
37
+ * 显示弹窗
38
+ * @param message 弹窗消息
39
+ */
40
+ popup: (message: string) => string
41
+ }
42
+
43
+ declare const MButton: DefineComponent<ButtonProps, {}, {}, {}, {}, {}, {}, ButtonEmits, string, Readonly<ButtonProps>, ButtonExpose>
44
+
45
+ export default MButton
46
+ export function popup(message: string): void
@@ -0,0 +1,4 @@
1
+ import { DefineComponent } from 'vue';
2
+ import { ButtonProps, ButtonEmits, ButtonExpose } from './MButton';
3
+ declare const MButton: DefineComponent<ButtonProps, {}, {}, {}, {}, {}, {}, ButtonEmits, string, Readonly<ButtonProps>, ButtonExpose>;
4
+ export default MButton;
@@ -0,0 +1,5 @@
1
+ import { default as MButton } from './MButton.vue';
2
+
3
+ export type { ButtonColor, ButtonSize, ButtonProps, ButtonEmits, ButtonExpose } from './MButton.d.ts';
4
+ export { MButton };
5
+ export default MButton;
@@ -0,0 +1,6 @@
1
+ export { MButton } from './components/index';
2
+ export type { ButtonColor, ButtonSize, ButtonProps, ButtonEmits, ButtonExpose } from './components/index';
3
+ declare const _default: {
4
+ MButton: any;
5
+ };
6
+ export default _default;
@@ -1 +1 @@
1
- .m-btn[data-v-455b51a7]{border:none;cursor:pointer;padding:.5em 1.2em;font-size:1em;transition:background .2s,color .2s}.m-btn.primary[data-v-455b51a7]{background:#409eff;color:#fff}.m-btn.round[data-v-455b51a7]{border-radius:999px}.m-btn.small[data-v-455b51a7]{font-size:.8em;padding:.3em .8em}.m-btn.medium[data-v-455b51a7]{font-size:1em;padding:.5em 1.2em}.m-btn.large[data-v-455b51a7]{font-size:1.2em;padding:.7em 1.6em}
1
+ .m-btn[data-v-658f9125]{border:none;cursor:pointer;padding:.5em 1.2em;font-size:1em;transition:all .3s;display:inline-block;line-height:1;white-space:nowrap;background:#fff;border:1px solid #dcdfe6;color:#606266;-webkit-appearance:none;text-align:center;box-sizing:border-box;outline:none;margin:0;font-weight:500}.m-btn.round[data-v-658f9125]{border-radius:20px}.m-btn.primary[data-v-658f9125]{background-color:#409eff;border-color:#409eff;color:#fff}.m-btn.success[data-v-658f9125]{background-color:#67c23a;border-color:#67c23a;color:#fff}.m-btn.warning[data-v-658f9125]{background-color:#e6a23c;border-color:#e6a23c;color:#fff}.m-btn.danger[data-v-658f9125]{background-color:#f56c6c;border-color:#f56c6c;color:#fff}.m-btn.info[data-v-658f9125]{background-color:#909399;border-color:#909399;color:#fff}.m-btn.small[data-v-658f9125]{font-size:.8em;padding:.3em .8em}.m-btn.medium[data-v-658f9125]{font-size:1em;padding:.5em 1.2em}.m-btn.large[data-v-658f9125]{font-size:1.2em;padding:.7em 1.6em}.m-btn.disabled[data-v-658f9125]{opacity:.6;cursor:not-allowed;pointer-events:none}.m-btn[data-v-658f9125]:hover:not(.disabled){opacity:.8}
@@ -1,43 +1,85 @@
1
- import { defineComponent as c, createElementBlock as u, openBlock as i, normalizeClass as p, renderSlot as s } from "vue";
2
- const d = /* @__PURE__ */ c({
3
- __name: "MButton",
1
+ import { defineComponent as r, createElementBlock as s, openBlock as i, normalizeClass as u, renderSlot as p } from "vue";
2
+ const c = r({
3
+ name: "MButton",
4
4
  props: {
5
+ /**
6
+ * 按钮颜色
7
+ */
5
8
  color: {
6
9
  type: String,
7
- default: "primary"
10
+ default: "primary",
11
+ validator: (e) => ["primary", "success", "warning", "danger", "info"].includes(e)
8
12
  },
13
+ /**
14
+ * 是否为圆角按钮
15
+ */
9
16
  round: {
10
17
  type: Boolean,
11
18
  default: !1
12
19
  },
20
+ /**
21
+ * 按钮尺寸
22
+ */
13
23
  size: {
14
24
  type: String,
15
25
  default: "medium",
16
- validator: (t) => ["small", "medium", "large"].includes(t)
26
+ validator: (e) => ["small", "medium", "large"].includes(e)
27
+ },
28
+ /**
29
+ * 是否禁用
30
+ */
31
+ disabled: {
32
+ type: Boolean,
33
+ default: !1
34
+ },
35
+ /**
36
+ * 自定义弹窗消息
37
+ */
38
+ popupMessage: {
39
+ type: String,
40
+ default: "按钮被点击!"
17
41
  }
18
42
  },
19
- emits: ["popup"],
20
- setup(t, { expose: r, emit: o }) {
21
- const l = o;
22
- function n(e) {
23
- window.alert(e), l("popup", e);
43
+ emits: ["click", "popup"],
44
+ setup(e, { emit: n, expose: l }) {
45
+ function o(t) {
46
+ return window.alert(t), n("popup", t), t;
24
47
  }
25
- function a(e) {
26
- n("按钮被点击!");
48
+ function a(t) {
49
+ e.disabled || (n("click", t), o(e.popupMessage));
27
50
  }
28
- return r({ popup: n }), (e, f) => (i(), u("button", {
29
- class: p(["m-btn", t.size, t.color, { round: t.round }]),
30
- onClick: a
31
- }, [
32
- s(e.$slots, "default", {}, void 0, !0)
33
- ], 2));
51
+ return l({
52
+ popup: o
53
+ }), {
54
+ popup: o,
55
+ handleClick: a
56
+ };
34
57
  }
35
- }), m = (t, r) => {
36
- const o = t.__vccOpts || t;
37
- for (const [l, n] of r)
38
- o[l] = n;
39
- return o;
40
- }, k = /* @__PURE__ */ m(d, [["__scopeId", "data-v-455b51a7"]]);
58
+ }), f = (e, n) => {
59
+ const l = e.__vccOpts || e;
60
+ for (const [o, a] of n)
61
+ l[o] = a;
62
+ return l;
63
+ }, m = ["disabled"];
64
+ function b(e, n, l, o, a, t) {
65
+ return i(), s("button", {
66
+ class: u([
67
+ "m-btn",
68
+ e.size,
69
+ e.color,
70
+ {
71
+ round: e.round,
72
+ disabled: e.disabled
73
+ }
74
+ ]),
75
+ disabled: e.disabled,
76
+ onClick: n[0] || (n[0] = (...d) => e.handleClick && e.handleClick(...d))
77
+ }, [
78
+ p(e.$slots, "default", {}, void 0, !0)
79
+ ], 10, m);
80
+ }
81
+ const k = /* @__PURE__ */ f(c, [["render", b], ["__scopeId", "data-v-658f9125"]]), B = { MButton: k };
41
82
  export {
42
- k as MButton
83
+ k as MButton,
84
+ B as default
43
85
  };
@@ -1 +1 @@
1
- (function(o,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(o=typeof globalThis<"u"?globalThis:o||self,e(o.Morghulis={},o.Vue))})(this,function(o,e){"use strict";const l=((t,r)=>{const i=t.__vccOpts||t;for(const[s,u]of r)i[s]=u;return i})(e.defineComponent({__name:"MButton",props:{color:{type:String,default:"primary"},round:{type:Boolean,default:!1},size:{type:String,default:"medium",validator:t=>["small","medium","large"].includes(t)}},emits:["popup"],setup(t,{expose:r,emit:i}){const s=i;function u(n){window.alert(n),s("popup",n)}function c(n){u("按钮被点击!")}return r({popup:u}),(n,a)=>(e.openBlock(),e.createElementBlock("button",{class:e.normalizeClass(["m-btn",t.size,t.color,{round:t.round}]),onClick:c},[e.renderSlot(n.$slots,"default",{},void 0,!0)],2))}}),[["__scopeId","data-v-455b51a7"]]);o.MButton=l,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
1
+ (function(t,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],n):(t=typeof globalThis<"u"?globalThis:t||self,n(t.Morghulis={},t.Vue))})(this,function(t,n){"use strict";const r=n.defineComponent({name:"MButton",props:{color:{type:String,default:"primary",validator:e=>["primary","success","warning","danger","info"].includes(e)},round:{type:Boolean,default:!1},size:{type:String,default:"medium",validator:e=>["small","medium","large"].includes(e)},disabled:{type:Boolean,default:!1},popupMessage:{type:String,default:"按钮被点击!"}},emits:["click","popup"],setup(e,{emit:o,expose:l}){function d(i){return window.alert(i),o("popup",i),i}function s(i){e.disabled||(o("click",i),d(e.popupMessage))}return l({popup:d}),{popup:d,handleClick:s}}}),a=(e,o)=>{const l=e.__vccOpts||e;for(const[d,s]of o)l[d]=s;return l},p=["disabled"];function f(e,o,l,d,s,i){return n.openBlock(),n.createElementBlock("button",{class:n.normalizeClass(["m-btn",e.size,e.color,{round:e.round,disabled:e.disabled}]),disabled:e.disabled,onClick:o[0]||(o[0]=(...m)=>e.handleClick&&e.handleClick(...m))},[n.renderSlot(e.$slots,"default",{},void 0,!0)],10,p)}const u=a(r,[["render",f],["__scopeId","data-v-658f9125"]]),c={MButton:u};t.MButton=u,t.default=c,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "morghulis",
3
- "version": "2.0.59",
3
+ "version": "2.0.60",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/morghulis.umd.js",
@@ -16,7 +16,22 @@
16
16
  "preview": "vite preview",
17
17
  "build-only": "vite build",
18
18
  "build-lib": "vite build --config vite.lib.config.ts",
19
- "type-check": "vue-tsc --build"
19
+ "type-check": "vue-tsc --build",
20
+ "prepublishOnly": "npm run build-lib"
21
+ },
22
+ "keywords": [
23
+ "vue",
24
+ "vue3",
25
+ "component",
26
+ "button",
27
+ "ui",
28
+ "typescript"
29
+ ],
30
+ "author": "MorghulisDev",
31
+ "license": "MIT",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/morghulis/morghulis"
20
35
  },
21
36
  "dependencies": {
22
37
  "vue": "^3.5.13"
@@ -29,7 +44,11 @@
29
44
  "npm-run-all2": "^7.0.2",
30
45
  "typescript": "~5.8.0",
31
46
  "vite": "^6.2.4",
47
+ "vite-plugin-dts": "^3.7.3",
32
48
  "vite-plugin-vue-devtools": "^7.7.2",
33
49
  "vue-tsc": "^2.2.8"
50
+ },
51
+ "peerDependencies": {
52
+ "vue": "^3.0.0"
34
53
  }
35
54
  }