g-ui-core 0.0.2 → 0.0.4

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/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "g-ui-core",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "G-UI Web Components built with Stencil",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",
7
7
  "es2015": "dist/esm/index.js",
8
8
  "es2017": "dist/esm/index.js",
9
- "types": "dist/types/index.d.ts",
9
+ "types": "vue/main.d.ts",
10
10
  "collection": "dist/collection/collection-manifest.json",
11
11
  "collection:main": "dist/collection/index.js",
12
12
  "unpkg": "dist/g-ui/g-ui.esm.js",
@@ -19,10 +19,10 @@
19
19
  ".": {
20
20
  "import": "./dist/index.js",
21
21
  "require": "./dist/index.cjs.js",
22
- "types": "./dist/types/index.d.ts"
22
+ "types": "./vue/main.d.ts"
23
23
  },
24
24
  "./vue": {
25
- "types": "./vue/global.d.ts",
25
+ "types": "./vue/index.d.ts",
26
26
  "import": "./vue/index.ts",
27
27
  "default": "./vue/index.ts"
28
28
  }
@@ -0,0 +1,45 @@
1
+ import { defineComponent, h, type PropType } from 'vue'
2
+
3
+ import '../dist/components/g-button.js'
4
+
5
+ export type ButtonType = 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'secondary'
6
+ export type ButtonSize = 'sm' | 'md' | 'lg'
7
+ export type NativeButtonType = 'button' | 'submit' | 'reset'
8
+
9
+ export default defineComponent({
10
+ name: 'GButton',
11
+ props: {
12
+ type: { type: String as PropType<ButtonType>, default: 'primary' },
13
+ size: { type: String as PropType<ButtonSize>, default: 'md' },
14
+ plain: Boolean,
15
+ text: Boolean,
16
+ bg: Boolean,
17
+ link: Boolean,
18
+ round: Boolean,
19
+ circle: Boolean,
20
+ dashed: Boolean,
21
+ loading: Boolean,
22
+ loadingIcon: { type: String, default: '●' },
23
+ disabled: Boolean,
24
+ icon: String,
25
+ autofocus: Boolean,
26
+ nativeType: { type: String as PropType<NativeButtonType>, default: 'button' },
27
+ autoInsertSpace: Boolean,
28
+ color: String,
29
+ dark: Boolean,
30
+ tag: { type: String, default: 'button' },
31
+ label: String
32
+ },
33
+ emits: ['click'],
34
+ setup(props, { slots, emit }) {
35
+ return () =>
36
+ h(
37
+ 'g-button',
38
+ {
39
+ ...props,
40
+ onClick: (e: MouseEvent) => emit('click', e)
41
+ },
42
+ slots.default?.()
43
+ )
44
+ }
45
+ })
package/vue/global.d.ts CHANGED
@@ -1,35 +0,0 @@
1
- /* eslint-disable */
2
- import type {
3
- ButtonType,
4
- ButtonSize,
5
- NativeButtonType
6
- } from '../dist/types/components/my-button/my-button'
7
-
8
- declare module '@vue/runtime-core' {
9
- export interface GlobalComponents {
10
- GButton: {
11
- type?: ButtonType
12
- size?: ButtonSize
13
- plain?: boolean | string
14
- text?: boolean | string
15
- bg?: boolean | string
16
- link?: boolean | string
17
- round?: boolean | string
18
- circle?: boolean | string
19
- dashed?: boolean | string
20
- loading?: boolean | string
21
- loadingIcon?: string
22
- disabled?: boolean | string
23
- icon?: string
24
- autofocus?: boolean | string
25
- nativeType?: NativeButtonType
26
- autoInsertSpace?: boolean | string
27
- color?: string
28
- dark?: boolean | string
29
- tag?: string
30
- label?: string
31
- }
32
- }
33
- }
34
-
35
- export {}
package/vue/index.d.ts ADDED
@@ -0,0 +1,42 @@
1
+ import type { AllowedComponentProps, ComponentCustomProps, VNodeProps } from 'vue'
2
+
3
+ // MyButton Vue 组件的 props 类型
4
+ export interface GButtonProps {
5
+ type?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'secondary'
6
+ size?: 'sm' | 'md' | 'lg'
7
+ plain?: boolean
8
+ text?: boolean
9
+ bg?: boolean
10
+ link?: boolean
11
+ round?: boolean
12
+ circle?: boolean
13
+ dashed?: boolean
14
+ loading?: boolean
15
+ loadingIcon?: string
16
+ disabled?: boolean
17
+ icon?: string
18
+ autofocus?: boolean
19
+ nativeType?: 'button' | 'submit' | 'reset'
20
+ autoInsertSpace?: boolean
21
+ color?: string
22
+ dark?: boolean
23
+ tag?: string
24
+ label?: string
25
+ onClick?: (e: MouseEvent) => void
26
+ }
27
+
28
+ export declare const MyButton: new () => {
29
+ $props: AllowedComponentProps & ComponentCustomProps & VNodeProps & GButtonProps
30
+ }
31
+
32
+ // Vue 插件
33
+ declare const plugin: { install: (app: any) => void }
34
+ export default plugin
35
+
36
+ // 增强 Vue 全局组件类型(Volar 智能提示)
37
+ declare module '@vue/runtime-core' {
38
+ export interface GlobalComponents {
39
+ GButton: GButtonProps
40
+ MyButton: GButtonProps
41
+ }
42
+ }
package/vue/index.ts CHANGED
@@ -1,12 +1,13 @@
1
- import type { App } from 'vue'
1
+ import './MyButton'
2
+ import MyButton from './MyButton'
3
+ export { MyButton }
2
4
 
3
- // 导入 Stencil 组件(auto-define 会自动注册)
4
- import '../dist/components/g-button.js'
5
-
6
- export default {
7
- install(app: App) {
8
- const original = app.config.compilerOptions.isCustomElement
5
+ const plugin = {
6
+ install(app: any) {
7
+ const original = app.config?.compilerOptions?.isCustomElement
9
8
  app.config.compilerOptions.isCustomElement = (tag: string) =>
10
9
  tag.startsWith('g-') || (typeof original === 'function' && original(tag))
11
10
  }
12
11
  }
12
+
13
+ export default plugin
package/vue/main.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ /// <reference path="./index.d.ts" />
2
+ export * from '../dist/types/index'