morghulis 2.0.55 → 2.0.56

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/mbutton.d.ts CHANGED
@@ -1,27 +1,50 @@
1
1
  // 直接声明类型,不使用任何模块语法
2
2
  // 这是最简单直接的方式,对IDE最友好
3
3
 
4
- /**
5
- * 按钮类型
6
- */
7
- type MButtonType = 'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text';
4
+ declare namespace MorgulisButton {
5
+ /**
6
+ * 按钮类型
7
+ */
8
+ export type MButtonType = 'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text';
8
9
 
9
- /**
10
- * 按钮尺寸
11
- */
12
- type MButtonSize = 'large' | 'default' | 'small';
10
+ /**
11
+ * 按钮尺寸
12
+ */
13
+ export type MButtonSize = 'large' | 'default' | 'small';
13
14
 
14
- /**
15
- * 按钮组件
16
- */
17
- type MButton = {
18
- type?: MButtonType;
19
- size?: MButtonSize;
20
- plain?: boolean;
21
- round?: boolean;
22
- circle?: boolean;
23
- disabled?: boolean;
24
- loading?: boolean;
25
- icon?: string;
26
- text?: string;
27
- };
15
+ /**
16
+ * 按钮组件
17
+ */
18
+ export interface MButtonProps {
19
+ type?: MButtonType;
20
+ size?: MButtonSize;
21
+ plain?: boolean;
22
+ round?: boolean;
23
+ circle?: boolean;
24
+ disabled?: boolean;
25
+ loading?: boolean;
26
+ icon?: string;
27
+ text?: string;
28
+ }
29
+ }
30
+
31
+ declare module 'morghulis' {
32
+ import { App, Component } from 'vue';
33
+
34
+ // 导出类型
35
+ export type MButtonType = MorgulisButton.MButtonType;
36
+ export type MButtonSize = MorgulisButton.MButtonSize;
37
+ export type MButtonProps = MorgulisButton.MButtonProps;
38
+
39
+ // 导出组件
40
+ export const MButton: Component<MButtonProps>;
41
+
42
+ // 安装函数
43
+ export function install(app: App): void;
44
+
45
+ // 默认导出
46
+ export default {
47
+ MButton,
48
+ install
49
+ };
50
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "morghulis",
3
- "version": "2.0.55",
3
+ "version": "2.0.56",
4
4
  "description": "一个Vue 3按钮组件库,支持TypeScript和IDE自动补全",
5
5
  "type": "module",
6
6
  "main": "dist/morghulis.es.js",
package/src/global.d.ts CHANGED
@@ -1,11 +1,32 @@
1
- // 使用全局 HTML 元素扩展方式声明组件
2
- // 这种方式对 PyCharm 更友好
1
+ // 使用声明合并 (Declaration Merging) 技术提供全局类型
3
2
 
3
+ // 从morghulis模块导入类型
4
+ import { MButtonType, MButtonSize } from 'morghulis';
5
+
6
+ // Vue全局组件
7
+ declare module '@vue/runtime-core' {
8
+ interface GlobalComponents {
9
+ MButton: {
10
+ // 属性
11
+ type?: MButtonType;
12
+ size?: MButtonSize;
13
+ plain?: boolean;
14
+ round?: boolean;
15
+ circle?: boolean;
16
+ disabled?: boolean;
17
+ loading?: boolean;
18
+ icon?: string;
19
+ text?: string;
20
+ }
21
+ }
22
+ }
23
+
24
+ // HTML元素映射扩展
4
25
  interface HTMLElementTagNameMap {
5
26
  'MButton': {
6
27
  // 属性
7
- type: 'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text';
8
- size: 'large' | 'default' | 'small';
28
+ type: MButtonType;
29
+ size: MButtonSize;
9
30
  plain: boolean;
10
31
  round: boolean;
11
32
  circle: boolean;
@@ -13,9 +34,6 @@ interface HTMLElementTagNameMap {
13
34
  loading: boolean;
14
35
  icon: string;
15
36
  text: string;
16
-
17
- // 事件
18
- onclick: (event: MouseEvent) => void;
19
37
  }
20
38
  }
21
39
 
@@ -23,8 +41,8 @@ interface HTMLElementTagNameMap {
23
41
  declare namespace JSX {
24
42
  interface IntrinsicElements {
25
43
  MButton: {
26
- type?: 'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text';
27
- size?: 'large' | 'default' | 'small';
44
+ type?: MButtonType;
45
+ size?: MButtonSize;
28
46
  plain?: boolean;
29
47
  round?: boolean;
30
48
  circle?: boolean;
@@ -1,14 +1,16 @@
1
1
  declare module '*.vue' {
2
- import { ComponentOptions } from 'vue';
3
- const component: ComponentOptions;
2
+ import { Component } from 'vue';
3
+ const component: Component;
4
4
  export default component;
5
5
  }
6
6
 
7
+ import { MButtonType, MButtonSize } from 'morghulis';
8
+
7
9
  declare module 'vue' {
8
10
  interface GlobalComponents {
9
11
  MButton: {
10
- type?: 'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text';
11
- size?: 'large' | 'default' | 'small';
12
+ type?: MButtonType;
13
+ size?: MButtonSize;
12
14
  plain?: boolean;
13
15
  round?: boolean;
14
16
  circle?: boolean;
@@ -23,8 +25,8 @@ declare module 'vue' {
23
25
  declare module '@vue/runtime-core' {
24
26
  interface ComponentCustomProperties {
25
27
  $MButton: {
26
- type: 'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text';
27
- size: 'large' | 'default' | 'small';
28
+ type: MButtonType;
29
+ size: MButtonSize;
28
30
  plain: boolean;
29
31
  round: boolean;
30
32
  circle: boolean;