gi-component 0.0.36 → 0.0.38

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.
@@ -1,6 +1,6 @@
1
1
  type AllKeys<T> = T extends any ? keyof T : never;
2
2
  type UnionType<T, K extends PropertyKey> = T extends any ? K extends keyof T ? T[K] : never : never;
3
3
  export type MergeMultiple<T extends any[]> = {
4
- [K in AllKeys<T[number]>]: UnionType<T[number], K>;
4
+ [K in AllKeys<T[number]>]?: UnionType<T[number], K>;
5
5
  };
6
6
  export {};
package/package.json CHANGED
@@ -1,72 +1,72 @@
1
- {
2
- "name": "gi-component",
3
- "type": "module",
4
- "version": "0.0.36",
5
- "description": "Vue3中基于Element Plus二次封装基础组件库",
6
- "author": "lin",
7
- "license": "MIT",
8
- "repository": {
9
- "type": "git",
10
- "url": "https://github.com/lin-97/gi-component.git"
11
- },
12
- "keywords": [
13
- "element-plus",
14
- "vitepress",
15
- "vue3",
16
- "gi-component",
17
- "二次封装组件",
18
- "封装组件"
19
- ],
20
- "sideEffects": [
21
- "packages/components/dialog/src/dialog.ts"
22
- ],
23
- "exports": {
24
- ".": {
25
- "types": "./dist/index.d.ts",
26
- "import": "./dist/index.es.js",
27
- "require": "./dist/index.umd.js"
28
- },
29
- "./dist/gi.css": "./dist/gi.css",
30
- "./dist/components.d.ts": "./packages/components.d.ts"
31
- },
32
- "main": "dist/index.umd.js",
33
- "module": "dist/index.es.js",
34
- "types": "dist/index.d.ts",
35
- "files": [
36
- "dist",
37
- "packages"
38
- ],
39
- "scripts": {
40
- "dev": "vite --host",
41
- "docs:dev": "cd docs && pnpm dev",
42
- "docs:build": "cd docs && pnpm build",
43
- "docs:preview": "cd docs && pnpm preview",
44
- "build:lib": "vite build",
45
- "build:docs": "cd docs && pnpm build",
46
- "lint": "eslint .",
47
- "lint:fix": "eslint . --fix"
48
- },
49
- "peerDependencies": {
50
- "element-plus": "^2.11.0",
51
- "vue": "^3.4.0"
52
- },
53
- "devDependencies": {
54
- "@antfu/eslint-config": "^7.2.0",
55
- "@element-plus/icons-vue": "^2.3.1",
56
- "@types/node": "^24.2.0",
57
- "@vitejs/plugin-vue": "^5.2.4",
58
- "@vitejs/plugin-vue-jsx": "^4.2.0",
59
- "element-plus": "^2.11.2",
60
- "eslint": "^9.39.2",
61
- "sass": "^1.89.0",
62
- "sass-loader": "^16.0.5",
63
- "terser": "^5.44.0",
64
- "typescript": "^5.8.3",
65
- "unplugin-vue-components": "^28.8.0",
66
- "vite": "6.3.5",
67
- "vite-plugin-dts": "^4.5.4",
68
- "vue": "^3.5.15",
69
- "vue-tsc": "^2.2.10",
70
- "xe-utils": "^3.7.9"
71
- }
72
- }
1
+ {
2
+ "name": "gi-component",
3
+ "type": "module",
4
+ "version": "0.0.38",
5
+ "description": "Vue3中基于Element Plus二次封装基础组件库",
6
+ "author": "lin",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/lin-97/gi-component.git"
11
+ },
12
+ "keywords": [
13
+ "element-plus",
14
+ "vitepress",
15
+ "vue3",
16
+ "gi-component",
17
+ "二次封装组件",
18
+ "封装组件"
19
+ ],
20
+ "sideEffects": [
21
+ "packages/components/dialog/src/dialog.ts"
22
+ ],
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "import": "./dist/index.es.js",
27
+ "require": "./dist/index.umd.js"
28
+ },
29
+ "./dist/gi.css": "./dist/gi.css",
30
+ "./dist/components.d.ts": "./packages/components.d.ts"
31
+ },
32
+ "main": "dist/index.umd.js",
33
+ "module": "dist/index.es.js",
34
+ "types": "dist/index.d.ts",
35
+ "files": [
36
+ "dist",
37
+ "packages"
38
+ ],
39
+ "scripts": {
40
+ "dev": "vite --host",
41
+ "docs:dev": "cd docs && pnpm dev",
42
+ "docs:build": "cd docs && pnpm build",
43
+ "docs:preview": "cd docs && pnpm preview",
44
+ "build:lib": "vite build",
45
+ "build:docs": "cd docs && pnpm build",
46
+ "lint": "eslint .",
47
+ "lint:fix": "eslint . --fix"
48
+ },
49
+ "peerDependencies": {
50
+ "element-plus": "^2.11.0",
51
+ "vue": "^3.4.0"
52
+ },
53
+ "devDependencies": {
54
+ "@antfu/eslint-config": "^7.2.0",
55
+ "@element-plus/icons-vue": "^2.3.1",
56
+ "@types/node": "^24.2.0",
57
+ "@vitejs/plugin-vue": "^5.2.4",
58
+ "@vitejs/plugin-vue-jsx": "^4.2.0",
59
+ "element-plus": "^2.11.2",
60
+ "eslint": "^9.39.2",
61
+ "sass": "^1.89.0",
62
+ "sass-loader": "^16.0.5",
63
+ "terser": "^5.44.0",
64
+ "typescript": "^5.8.3",
65
+ "unplugin-vue-components": "^28.8.0",
66
+ "vite": "6.3.5",
67
+ "vite-plugin-dts": "^4.5.4",
68
+ "vue": "^3.5.15",
69
+ "vue-tsc": "^2.2.10",
70
+ "xe-utils": "^3.7.9"
71
+ }
72
+ }
@@ -1,60 +1,60 @@
1
- <template>
2
- <ElButton :class="b('button')" v-bind="bindProps" @click="(e: MouseEvent) => emit('click', e)">
3
- <slot>{{ btnText }}</slot>
4
- </ElButton>
5
- </template>
6
-
7
- <script setup lang="ts">
8
- import type { ButtonProps as ElButtonProps } from 'element-plus'
9
- import type { ButtonProps } from './type.ts'
10
- import {
11
- Delete,
12
- Download,
13
- Edit,
14
- Plus,
15
- Printer,
16
- Search,
17
- Upload
18
- } from '@element-plus/icons-vue'
19
- import { ElButton } from 'element-plus'
20
- import { computed, useAttrs } from 'vue'
21
- import { useBemClass } from '../../../hooks'
22
-
23
- const props = withDefaults(defineProps<ButtonProps>(), {
24
- type: ''
25
- })
26
-
27
- const emit = defineEmits<{
28
- (e: 'click', event: MouseEvent): void
29
- }>()
30
-
31
- const attrs = useAttrs()
32
-
33
- const { b } = useBemClass()
34
-
35
- const obj: Record<string, { btnProps: Partial<ButtonProps>, btnText: string }>
36
- = {
37
- add: { btnProps: { icon: Plus, type: 'primary' }, btnText: '新增' },
38
- edit: { btnProps: { icon: Edit, type: 'primary' }, btnText: '编辑' },
39
- delete: { btnProps: { icon: Delete, type: 'danger' }, btnText: '删除' },
40
- search: { btnProps: { icon: Search, type: 'primary' }, btnText: '搜索' },
41
- reset: { btnProps: { type: undefined }, btnText: '重置' },
42
- upload: { btnProps: { icon: Upload }, btnText: '上传' },
43
- download: {
44
- btnProps: { icon: Download },
45
- btnText: '下载'
46
- },
47
- print: { btnProps: { icon: Printer }, btnText: '打印' }
48
- }
49
-
50
- const bindProps = computed(() => {
51
- const btnProps = obj?.[props.type]?.btnProps || { type: props.type }
52
- return { ...attrs, ...props, ...btnProps } as Omit<ElButtonProps, 'type'>
53
- })
54
-
55
- const btnText = computed(() => {
56
- return obj[props.type].btnText
57
- })
58
- </script>
59
-
60
- <style lang="scss" scoped></style>
1
+ <template>
2
+ <ElButton :class="b('button')" v-bind="bindProps" @click="(e: MouseEvent) => emit('click', e)">
3
+ <slot>{{ btnText }}</slot>
4
+ </ElButton>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import type { ButtonProps as ElButtonProps } from 'element-plus'
9
+ import type { ButtonProps } from './type.ts'
10
+ import {
11
+ Delete,
12
+ Download,
13
+ Edit,
14
+ Plus,
15
+ Printer,
16
+ Search,
17
+ Upload
18
+ } from '@element-plus/icons-vue'
19
+ import { ElButton } from 'element-plus'
20
+ import { computed, useAttrs } from 'vue'
21
+ import { useBemClass } from '../../../hooks'
22
+
23
+ const props = withDefaults(defineProps<ButtonProps>(), {
24
+ type: ''
25
+ })
26
+
27
+ const emit = defineEmits<{
28
+ (e: 'click', event: MouseEvent): void
29
+ }>()
30
+
31
+ const attrs = useAttrs()
32
+
33
+ const { b } = useBemClass()
34
+
35
+ const obj: Record<string, { btnProps: Partial<ButtonProps>, btnText: string }>
36
+ = {
37
+ add: { btnProps: { icon: Plus, type: 'primary' }, btnText: '新增' },
38
+ edit: { btnProps: { icon: Edit, type: 'primary' }, btnText: '编辑' },
39
+ delete: { btnProps: { icon: Delete, type: 'danger' }, btnText: '删除' },
40
+ search: { btnProps: { icon: Search, type: 'primary' }, btnText: '搜索' },
41
+ reset: { btnProps: { type: undefined }, btnText: '重置' },
42
+ upload: { btnProps: { icon: Upload }, btnText: '上传' },
43
+ download: {
44
+ btnProps: { icon: Download },
45
+ btnText: '下载'
46
+ },
47
+ print: { btnProps: { icon: Printer }, btnText: '打印' }
48
+ }
49
+
50
+ const bindProps = computed(() => {
51
+ const btnProps = obj?.[props.type]?.btnProps || { type: props.type }
52
+ return { ...attrs, ...props, ...btnProps } as Omit<ElButtonProps, 'type'>
53
+ })
54
+
55
+ const btnText = computed(() => {
56
+ return obj[props.type].btnText
57
+ })
58
+ </script>
59
+
60
+ <style lang="scss" scoped></style>
@@ -0,0 +1,5 @@
1
+ import Flex from './src/flex.vue'
2
+
3
+ export type FlexInstance = InstanceType<typeof Flex>
4
+ export * from './src/type'
5
+ export default Flex
@@ -0,0 +1,72 @@
1
+ <template>
2
+ <div :class="classNames" :style="style">
3
+ <slot />
4
+ </div>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import type { CSSProperties } from 'vue'
9
+ import type { FlexProps } from './type'
10
+ import { computed } from 'vue'
11
+ import { useBemClass } from '../../../hooks'
12
+
13
+ const props = withDefaults(defineProps<FlexProps>(), {
14
+ vertical: false,
15
+ wrap: false,
16
+ justify: 'normal',
17
+ align: 'normal',
18
+ flex: 'normal'
19
+ })
20
+
21
+ const { b } = useBemClass()
22
+
23
+ const classNames = computed(() => [b('flex')])
24
+
25
+ const gapMap: Record<string, string> = {
26
+ small: '8px',
27
+ middle: '16px',
28
+ large: '24px'
29
+ }
30
+
31
+ const resolvedGap = computed(() => {
32
+ if (props.gap === undefined || props.gap === null || props.gap === '')
33
+ return undefined
34
+ if (typeof props.gap === 'number')
35
+ return `${props.gap}px`
36
+ if (gapMap[props.gap])
37
+ return gapMap[props.gap]
38
+ return String(props.gap)
39
+ })
40
+
41
+ const resolvedWrap = computed(() => {
42
+ if (typeof props.wrap === 'boolean')
43
+ return props.wrap ? 'wrap' : 'nowrap'
44
+ // 模板中写 wrap 无值时 Vue 传空字符串,视为开启换行
45
+ if (props.wrap === '')
46
+ return 'wrap'
47
+ return props.wrap
48
+ })
49
+
50
+ const style = computed<CSSProperties>(() => {
51
+ const obj: CSSProperties = {
52
+ display: 'flex',
53
+ flexDirection: props.vertical ? 'column' : 'row',
54
+ flexWrap: resolvedWrap.value,
55
+ justifyContent: props.justify,
56
+ alignItems: props.align
57
+ }
58
+ if (props.flex !== 'normal') {
59
+ obj.flex = props.flex
60
+ }
61
+ if (resolvedGap.value) {
62
+ obj.gap = resolvedGap.value
63
+ }
64
+ return obj
65
+ })
66
+ </script>
67
+
68
+ <style scoped lang="scss">
69
+ :deep(.el-button+.el-button) {
70
+ margin-left: 0;
71
+ }
72
+ </style>
@@ -0,0 +1,14 @@
1
+ export interface FlexProps {
2
+ /** Flex 主轴的方向是否垂直,使用 flex-direction: column */
3
+ vertical?: boolean
4
+ /** 设置元素单行显示还是多行显示,参考 flex-wrap;支持布尔值,true 为 wrap,false 为 nowrap */
5
+ wrap?: 'nowrap' | 'wrap' | 'wrap-reverse' | boolean | ''
6
+ /** 设置元素在主轴方向上的对齐方式,参考 justify-content */
7
+ justify?: 'normal' | 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly'
8
+ /** 设置元素在交叉轴方向上的对齐方式,参考 align-items */
9
+ align?: 'normal' | 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline'
10
+ /** flex CSS 简写属性 */
11
+ flex?: string
12
+ /** 设置网格之间的间隙,可选预设 small / middle / large 或 string / number */
13
+ gap?: 'small' | 'middle' | 'large' | string | number
14
+ }
@@ -1,5 +1,5 @@
1
- import Table from './src/table.vue'
2
-
3
- export type TableInstance = InstanceType<typeof Table>
4
- export * from './src/type'
5
- export default Table
1
+ import Table from './src/table.vue'
2
+
3
+ export type TableInstance = InstanceType<typeof Table>
4
+ export * from './src/type'
5
+ export default Table
@@ -1,30 +1,31 @@
1
- /* eslint-disable */
2
- // @ts-nocheck
3
- // Generated by unplugin-vue-components
4
- // Read more: https://github.com/vuejs/core/pull/3399
5
- // biome-ignore lint: disable
6
- export {}
7
-
8
- /* prettier-ignore */
9
- declare module 'vue' {
10
- export interface GlobalComponents {
11
- GiButton: typeof import('./components/button/src/button.vue')['default']
12
- GiCard: typeof import('./components/card/src/card.vue')['default']
13
- GiDialog: typeof import('./components/dialog/src/dialog.vue')['default']
14
- GiDialogContent: typeof import('./components/dialog/src/dialog-content.vue')['default']
15
- GiDot: typeof import('./components/dot/src/dot.vue')['default']
16
- GiDrawer: typeof import('./components/drawer/src/drawer.vue')['default']
17
- GiEditTable: typeof import('./components/edit-table/src/edit-table.vue')['default']
18
- GiForm: typeof import('./components/form/src/form.vue')['default']
19
- GiGrid: typeof import('./components/grid/src/grid.vue')['default']
20
- GiGridItem: typeof import('./components/grid/src/grid-item.vue')['default']
21
- GiInputGroup: typeof import('./components/input-group/src/input-group.vue')['default']
22
- GiInputSearch: typeof import('./components/input-search/src/input-search.vue')['default']
23
- GiPageLayout: typeof import('./components/page-layout/src/page-layout.vue')['default']
24
- GiSplitButton: typeof import('./components/page-layout/src/split-button.vue')['default']
25
- GiTable: typeof import('./components/table/src/table.vue')['default']
26
- GiTableColumn: typeof import('./components/table/src/TableColumn.vue')['default']
27
- GiTabs: typeof import('./components/tabs/src/tabs.vue')['default']
28
- GiTreeTransfer: typeof import('./components/tree-transfer/src/tree-transfer.vue')['default']
29
- }
30
- }
1
+ /* eslint-disable */
2
+ // @ts-nocheck
3
+ // Generated by unplugin-vue-components
4
+ // Read more: https://github.com/vuejs/core/pull/3399
5
+ // biome-ignore lint: disable
6
+ export {}
7
+
8
+ /* prettier-ignore */
9
+ declare module 'vue' {
10
+ export interface GlobalComponents {
11
+ GiButton: typeof import('./components/button/src/button.vue')['default']
12
+ GiCard: typeof import('./components/card/src/card.vue')['default']
13
+ GiDialog: typeof import('./components/dialog/src/dialog.vue')['default']
14
+ GiDialogContent: typeof import('./components/dialog/src/dialog-content.vue')['default']
15
+ GiDot: typeof import('./components/dot/src/dot.vue')['default']
16
+ GiDrawer: typeof import('./components/drawer/src/drawer.vue')['default']
17
+ GiEditTable: typeof import('./components/edit-table/src/edit-table.vue')['default']
18
+ GiFlex: typeof import('./components/flex/src/flex.vue')['default']
19
+ GiForm: typeof import('./components/form/src/form.vue')['default']
20
+ GiGrid: typeof import('./components/grid/src/grid.vue')['default']
21
+ GiGridItem: typeof import('./components/grid/src/grid-item.vue')['default']
22
+ GiInputGroup: typeof import('./components/input-group/src/input-group.vue')['default']
23
+ GiInputSearch: typeof import('./components/input-search/src/input-search.vue')['default']
24
+ GiPageLayout: typeof import('./components/page-layout/src/page-layout.vue')['default']
25
+ GiSplitButton: typeof import('./components/page-layout/src/split-button.vue')['default']
26
+ GiTable: typeof import('./components/table/src/table.vue')['default']
27
+ GiTableColumn: typeof import('./components/table/src/TableColumn.vue')['default']
28
+ GiTabs: typeof import('./components/tabs/src/tabs.vue')['default']
29
+ GiTreeTransfer: typeof import('./components/tree-transfer/src/tree-transfer.vue')['default']
30
+ }
31
+ }