@hoenergy/hoenergy-template-pc 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/.i18n_extractor.json +13 -0
- package/dist/components/data/table/FormaxTable/index.d.ts +7 -0
- package/dist/components/data/table/FormaxTable/src/BasicTable.d.ts +6 -0
- package/dist/components/data/table/FormaxTable/src/Table.vue.d.ts +99 -0
- package/dist/components/data/table/FormaxTable/src/components/settings/ColumnSetting.vue.d.ts +31 -0
- package/dist/components/data/table/FormaxTable/src/const.d.ts +9 -0
- package/dist/components/data/table/FormaxTable/src/hooks/useColumns.d.ts +10 -0
- package/dist/components/data/table/FormaxTable/src/hooks/useDataSource.d.ts +20 -0
- package/dist/components/data/table/FormaxTable/src/hooks/useLoading.d.ts +6 -0
- package/dist/components/data/table/FormaxTable/src/hooks/usePagination.d.ts +10 -0
- package/dist/components/data/table/FormaxTable/src/hooks/useTableContext.d.ts +13 -0
- package/dist/components/data/table/FormaxTable/src/props.d.ts +1 -0
- package/dist/components/data/table/FormaxTable/src/types/componentType.d.ts +1 -0
- package/dist/components/data/table/FormaxTable/src/types/pagination.d.ts +10 -0
- package/dist/components/data/table/FormaxTable/src/types/table.d.ts +36 -0
- package/dist/components/data/table/FormaxTable/src/types/tableAction.d.ts +23 -0
- package/dist/components/data/table/FormaxTable/src/utils.d.ts +11 -0
- package/dist/components/general/button/FormaxButton/index.d.ts +2 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.js +37 -0
- package/dist/index.mjs +1862 -0
- package/dist/mock.d.ts +13 -0
- package/dist/style.css +1 -0
- package/dist/types.d.ts +34 -0
- package/docs/i18n-stub.mjs +12 -0
- package/docs/index.html +314 -0
- package/docs/index.js +658 -0
- package/docs/index.mjs +113892 -0
- package/docs/tailwind.css +4 -0
- package/docs/tailwind.generated.css +1 -0
- package/package.json +51 -0
- package/playground/App.vue +60 -0
- package/playground/index.html +12 -0
- package/playground/main.ts +12 -0
- package/src/components/data/table/FormaxTable/index.ts +143 -0
- package/src/components/data/table/FormaxTable/src/BasicTable.ts +12 -0
- package/src/components/data/table/FormaxTable/src/Table.vue +412 -0
- package/src/components/data/table/FormaxTable/src/components/TableAction.vue +155 -0
- package/src/components/data/table/FormaxTable/src/components/settings/ColumnSetting.vue +248 -0
- package/src/components/data/table/FormaxTable/src/const.ts +11 -0
- package/src/components/data/table/FormaxTable/src/hooks/useColumns.ts +147 -0
- package/src/components/data/table/FormaxTable/src/hooks/useDataSource.ts +238 -0
- package/src/components/data/table/FormaxTable/src/hooks/useLoading.ts +21 -0
- package/src/components/data/table/FormaxTable/src/hooks/usePagination.ts +65 -0
- package/src/components/data/table/FormaxTable/src/hooks/useTableContext.ts +23 -0
- package/src/components/data/table/FormaxTable/src/props.ts +77 -0
- package/src/components/data/table/FormaxTable/src/types/componentType.ts +9 -0
- package/src/components/data/table/FormaxTable/src/types/pagination.ts +10 -0
- package/src/components/data/table/FormaxTable/src/types/table.ts +45 -0
- package/src/components/data/table/FormaxTable/src/types/tableAction.ts +25 -0
- package/src/components/data/table/FormaxTable/src/utils.ts +65 -0
- package/src/components/general/button/FormaxButton/index.ts +70 -0
- package/src/index.ts +66 -0
- package/src/locales/en.json +13 -0
- package/src/locales/zh-CN.json +13 -0
- package/src/mock.ts +17 -0
- package/src/shims-vue.d.ts +6 -0
- package/src/types/i18n-auto-extractor.d.ts +3 -0
- package/src/types.ts +40 -0
- package/tailwind.config.cjs +12 -0
- package/tsconfig.json +16 -0
- package/tsup.config.ts +16 -0
- package/vite.config.ts +59 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { PaginationProps } from '../types/pagination'
|
|
2
|
+
import type { BasicTableProps } from '../types/table'
|
|
3
|
+
import { computed, unref, ref, ComputedRef, watch } from 'vue'
|
|
4
|
+
import { DEFAULTPAGESIZE, PAGESIZES } from '../const'
|
|
5
|
+
|
|
6
|
+
const isBoolean = (val: unknown): val is boolean => typeof val === 'boolean'
|
|
7
|
+
|
|
8
|
+
export function usePagination(refProps: ComputedRef<BasicTableProps>) {
|
|
9
|
+
const configRef = ref<PaginationProps>({})
|
|
10
|
+
const show = ref(true)
|
|
11
|
+
|
|
12
|
+
watch(
|
|
13
|
+
() => unref(refProps).pagination,
|
|
14
|
+
(pagination) => {
|
|
15
|
+
if (!isBoolean(pagination) && pagination) {
|
|
16
|
+
configRef.value = {
|
|
17
|
+
...unref(configRef),
|
|
18
|
+
...(pagination ?? {}),
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
deep: true,
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
const getPaginationInfo = computed((): PaginationProps | boolean => {
|
|
28
|
+
const { pagination } = unref(refProps)
|
|
29
|
+
if (!unref(show) || (isBoolean(pagination) && !pagination)) {
|
|
30
|
+
return false
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
page: 1,
|
|
34
|
+
pageSize: DEFAULTPAGESIZE,
|
|
35
|
+
pageSizes: PAGESIZES,
|
|
36
|
+
showSizePicker: true,
|
|
37
|
+
showQuickJumper: true,
|
|
38
|
+
prefix: (pagingInfo: any) => `共 ${pagingInfo.itemCount} 条`,
|
|
39
|
+
...(isBoolean(pagination) ? {} : pagination),
|
|
40
|
+
...unref(configRef),
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
function setPagination(info: Partial<PaginationProps>) {
|
|
45
|
+
const paginationInfo = unref(getPaginationInfo)
|
|
46
|
+
configRef.value = {
|
|
47
|
+
...(!isBoolean(paginationInfo) ? paginationInfo : {}),
|
|
48
|
+
...info,
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function getPagination() {
|
|
53
|
+
return unref(getPaginationInfo)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function getShowPagination() {
|
|
57
|
+
return unref(show)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function setShowPagination(flag: boolean) {
|
|
61
|
+
show.value = flag
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return { getPagination, getPaginationInfo, setShowPagination, getShowPagination, setPagination }
|
|
65
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Ref } from 'vue'
|
|
2
|
+
import type { BasicTableProps, TableActionType } from '../types/table'
|
|
3
|
+
import { provide, inject, ComputedRef } from 'vue'
|
|
4
|
+
import type { Nullable, Recordable } from '../../../types'
|
|
5
|
+
|
|
6
|
+
const key = Symbol('s-table')
|
|
7
|
+
|
|
8
|
+
type Instance = TableActionType & {
|
|
9
|
+
wrapRef: Ref<Nullable<HTMLElement>>
|
|
10
|
+
getBindValues: ComputedRef<Recordable>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type RetInstance = Omit<Instance, 'getBindValues'> & {
|
|
14
|
+
getBindValues: ComputedRef<BasicTableProps>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function createTableContext(instance: Instance) {
|
|
18
|
+
provide(key, instance)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function useTableContext(): RetInstance {
|
|
22
|
+
return inject(key) as RetInstance
|
|
23
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { PropType } from 'vue'
|
|
2
|
+
import { NDataTable } from 'naive-ui'
|
|
3
|
+
import { BasicColumn } from './types/table'
|
|
4
|
+
|
|
5
|
+
export const basicProps = {
|
|
6
|
+
...NDataTable.props,
|
|
7
|
+
title: {
|
|
8
|
+
type: String,
|
|
9
|
+
default: null,
|
|
10
|
+
},
|
|
11
|
+
titleTooltip: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: null,
|
|
14
|
+
},
|
|
15
|
+
size: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: 'medium',
|
|
18
|
+
},
|
|
19
|
+
dataSource: {
|
|
20
|
+
type: [Object],
|
|
21
|
+
default: () => [],
|
|
22
|
+
},
|
|
23
|
+
columns: {
|
|
24
|
+
type: [Array] as PropType<BasicColumn[]>,
|
|
25
|
+
default: () => [],
|
|
26
|
+
required: true,
|
|
27
|
+
},
|
|
28
|
+
beforeRequest: {
|
|
29
|
+
type: Function as PropType<(...arg: any[]) => void | Promise<any>>,
|
|
30
|
+
default: null,
|
|
31
|
+
},
|
|
32
|
+
request: {
|
|
33
|
+
type: Function as PropType<(...arg: any[]) => Promise<any>>,
|
|
34
|
+
default: null,
|
|
35
|
+
},
|
|
36
|
+
toolbarShow: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: false,
|
|
39
|
+
},
|
|
40
|
+
afterRequest: {
|
|
41
|
+
type: Function as PropType<(...arg: any[]) => void | Promise<any>>,
|
|
42
|
+
default: null,
|
|
43
|
+
},
|
|
44
|
+
rowKey: {
|
|
45
|
+
type: [String, Function] as PropType<string | ((record: any) => string)>,
|
|
46
|
+
default: undefined,
|
|
47
|
+
},
|
|
48
|
+
hasForm: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: true,
|
|
51
|
+
},
|
|
52
|
+
pagination: {
|
|
53
|
+
type: [Object, Boolean],
|
|
54
|
+
default: () => ({}),
|
|
55
|
+
},
|
|
56
|
+
// 废弃
|
|
57
|
+
showPagination: {
|
|
58
|
+
type: [String, Boolean],
|
|
59
|
+
default: 'auto',
|
|
60
|
+
},
|
|
61
|
+
actionColumn: {
|
|
62
|
+
type: Object as PropType<BasicColumn>,
|
|
63
|
+
default: null,
|
|
64
|
+
},
|
|
65
|
+
canResize: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
default: true,
|
|
68
|
+
},
|
|
69
|
+
canExpand: {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
default: false,
|
|
72
|
+
},
|
|
73
|
+
resizeHeightOffset: {
|
|
74
|
+
type: Number,
|
|
75
|
+
default: 0,
|
|
76
|
+
},
|
|
77
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface PaginationProps {
|
|
2
|
+
page?: number; //�ܿ�ģʽ�µĵ�ǰҳ
|
|
3
|
+
itemCount?: number; //������
|
|
4
|
+
pageCount?: number; //��ҳ��
|
|
5
|
+
pageSize?: number; //�ܿ�ģʽ�µķ�ҳ��С
|
|
6
|
+
pageSizes?: number[]; //ÿҳ������ ���Զ���
|
|
7
|
+
showSizePicker?: boolean; //�Ƿ���ʾÿҳ������ѡ����
|
|
8
|
+
showQuickJumper?: boolean; //�Ƿ���ʾ������ת
|
|
9
|
+
prefix?: any; //��ҳǰ
|
|
10
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
InternalRowData,
|
|
3
|
+
TableBaseColumn,
|
|
4
|
+
} from 'naive-ui/lib/data-table/src/interface'
|
|
5
|
+
import { ComponentType } from './componentType'
|
|
6
|
+
export interface BasicColumn<T = InternalRowData> extends TableBaseColumn<T> {
|
|
7
|
+
//编辑表格
|
|
8
|
+
edit?: boolean
|
|
9
|
+
editRow?: boolean
|
|
10
|
+
editable?: boolean
|
|
11
|
+
editComponent?: ComponentType
|
|
12
|
+
editComponentProps?: any
|
|
13
|
+
editRule?: boolean | ((text: string, record: any) => Promise<string>)
|
|
14
|
+
editValueMap?: (value: any) => string
|
|
15
|
+
onEditRow?: () => void
|
|
16
|
+
// 权限编码控制是否显示
|
|
17
|
+
auth?: string[]
|
|
18
|
+
// 业务控制是否显示
|
|
19
|
+
ifShow?: boolean | ((column: BasicColumn) => boolean)
|
|
20
|
+
// 控制是否支持拖拽,默认支持
|
|
21
|
+
draggable?: boolean
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface TableActionType {
|
|
25
|
+
reload: (opt: any) => Promise<void>
|
|
26
|
+
emit?: any
|
|
27
|
+
getColumns: (opt?: any) => BasicColumn[]
|
|
28
|
+
setColumns: (columns: BasicColumn[] | string[]) => void
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface BasicTableProps {
|
|
32
|
+
title?: string
|
|
33
|
+
dataSource: Function
|
|
34
|
+
columns: any[]
|
|
35
|
+
pagination: object
|
|
36
|
+
showPagination: boolean
|
|
37
|
+
actionColumn: any
|
|
38
|
+
canResize: boolean
|
|
39
|
+
resizeHeightOffset: number
|
|
40
|
+
loading: boolean
|
|
41
|
+
maxHeight?: number
|
|
42
|
+
titleTooltip?: string
|
|
43
|
+
toolbarShow?: boolean
|
|
44
|
+
bordered?: boolean
|
|
45
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { NButton } from 'naive-ui'
|
|
2
|
+
import type { Component } from 'vue'
|
|
3
|
+
|
|
4
|
+
export interface ActionItem extends Partial<InstanceType<typeof NButton>> {
|
|
5
|
+
onClick?: any
|
|
6
|
+
label?: string
|
|
7
|
+
type?: 'success' | 'error' | 'warning' | 'info' | 'primary' | 'default'
|
|
8
|
+
color?: string
|
|
9
|
+
icon?: Component
|
|
10
|
+
popConfirm?: PopConfirm
|
|
11
|
+
disabled?: boolean
|
|
12
|
+
divider?: boolean
|
|
13
|
+
isPopConfirm?: boolean
|
|
14
|
+
auth?: string | string[]
|
|
15
|
+
ifShow?: boolean | ((action: ActionItem) => boolean)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface PopConfirm {
|
|
19
|
+
title: string
|
|
20
|
+
okText?: string
|
|
21
|
+
cancelText?: string
|
|
22
|
+
confirm: any
|
|
23
|
+
cancel?: any
|
|
24
|
+
confirmIcon?: Component
|
|
25
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
|
|
2
|
+
import { onMounted, onUnmounted } from 'vue';
|
|
3
|
+
|
|
4
|
+
export function isBoolean(val: unknown): val is boolean {
|
|
5
|
+
return typeof val === 'boolean';
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function useWindowSizeFn(fn: () => void, wait = 150) {
|
|
9
|
+
let timer: any = null;
|
|
10
|
+
const handler = () => {
|
|
11
|
+
if (timer) clearTimeout(timer);
|
|
12
|
+
timer = setTimeout(fn, wait);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
onMounted(() => {
|
|
16
|
+
window.addEventListener('resize', handler);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
onUnmounted(() => {
|
|
20
|
+
window.removeEventListener('resize', handler);
|
|
21
|
+
if (timer) clearTimeout(timer);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface ViewportOffsetResult {
|
|
26
|
+
left: number;
|
|
27
|
+
top: number;
|
|
28
|
+
right: number;
|
|
29
|
+
bottom: number;
|
|
30
|
+
rightIncludeBody: number;
|
|
31
|
+
bottomIncludeBody: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function getViewportOffset(element: Element): ViewportOffsetResult {
|
|
35
|
+
const doc = document.documentElement;
|
|
36
|
+
|
|
37
|
+
const docScrollLeft = doc.scrollLeft;
|
|
38
|
+
const docScrollTop = doc.scrollTop;
|
|
39
|
+
const docClientLeft = doc.clientLeft;
|
|
40
|
+
const docClientTop = doc.clientTop;
|
|
41
|
+
|
|
42
|
+
const pageXOffset = window.pageXOffset;
|
|
43
|
+
const pageYOffset = window.pageYOffset;
|
|
44
|
+
|
|
45
|
+
const box = element.getBoundingClientRect();
|
|
46
|
+
|
|
47
|
+
const { left: retLeft, top: rectTop, width: rectWidth, height: rectHeight } = box as DOMRect;
|
|
48
|
+
|
|
49
|
+
const scrollLeft = (pageXOffset || docScrollLeft) - (docClientLeft || 0);
|
|
50
|
+
const scrollTop = (pageYOffset || docScrollTop) - (docClientTop || 0);
|
|
51
|
+
const offsetLeft = retLeft + pageXOffset;
|
|
52
|
+
const offsetTop = rectTop + pageYOffset;
|
|
53
|
+
|
|
54
|
+
const left = offsetLeft - scrollLeft;
|
|
55
|
+
const top = offsetTop - scrollTop;
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
left,
|
|
59
|
+
top,
|
|
60
|
+
right: doc.clientWidth - rectWidth - left,
|
|
61
|
+
bottom: doc.clientHeight - rectHeight - top,
|
|
62
|
+
rightIncludeBody: doc.clientWidth - left,
|
|
63
|
+
bottomIncludeBody: doc.clientHeight - top,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { defineComponent, h } from 'vue'
|
|
2
|
+
import { FormaxComponent, ComponentMeta } from '../../../../types'
|
|
3
|
+
|
|
4
|
+
export const FormaxButton = defineComponent({
|
|
5
|
+
name: 'FormaxButton',
|
|
6
|
+
props: {
|
|
7
|
+
label: {
|
|
8
|
+
type: String,
|
|
9
|
+
default: 'Button',
|
|
10
|
+
},
|
|
11
|
+
type: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: 'default', // primary, danger, default
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
setup(props: any, { emit, slots }: any) {
|
|
17
|
+
return () => {
|
|
18
|
+
const style = {
|
|
19
|
+
padding: '8px 16px',
|
|
20
|
+
borderRadius: '4px',
|
|
21
|
+
border: 0,
|
|
22
|
+
cursor: 'pointer',
|
|
23
|
+
backgroundColor:
|
|
24
|
+
props.type === 'primary'
|
|
25
|
+
? '#007bff'
|
|
26
|
+
: props.type === 'danger'
|
|
27
|
+
? '#dc3545'
|
|
28
|
+
: '#007bff',
|
|
29
|
+
color: '#fff',
|
|
30
|
+
fontSize: '14px',
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const label = slots.default ? slots.default() : props.label
|
|
34
|
+
|
|
35
|
+
return h(
|
|
36
|
+
'button',
|
|
37
|
+
{
|
|
38
|
+
style,
|
|
39
|
+
onClick: (event: Event) => emit('click', event),
|
|
40
|
+
},
|
|
41
|
+
label
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
}) as FormaxComponent
|
|
46
|
+
|
|
47
|
+
const meta: ComponentMeta = {
|
|
48
|
+
name: 'FormaxButton',
|
|
49
|
+
label: '通用按钮',
|
|
50
|
+
description: '一个基础按钮组件',
|
|
51
|
+
props: {
|
|
52
|
+
label: { type: 'string', default: 'Button', description: '按钮文本' },
|
|
53
|
+
type: {
|
|
54
|
+
type: 'string',
|
|
55
|
+
default: 'default',
|
|
56
|
+
description: '按钮类型',
|
|
57
|
+
options: ['default', 'primary', 'danger'],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
events: [{ name: 'click', description: '点击按钮时触发', payload: 'Event' }],
|
|
61
|
+
slots: [{ name: 'default', description: '按钮文本内容' }],
|
|
62
|
+
usage: `<FormaxButton type="primary" label="Click Me" @click="handleClick" />`,
|
|
63
|
+
package: 'general',
|
|
64
|
+
category: 'button',
|
|
65
|
+
key: 'FormaxButton',
|
|
66
|
+
conKey: 'GCFormaxButton',
|
|
67
|
+
image: 'GCFormaxButton.png',
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
FormaxButton.__doc_meta__ = meta
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { FormaxButton } from './components/general/button/FormaxButton'
|
|
2
|
+
import { FormaxTableComponent as FormaxTable } from './components/data/table/FormaxTable'
|
|
3
|
+
import { ComponentMeta, FormaxComponent } from './types'
|
|
4
|
+
// 动态导入语言包,减少首次加载体积
|
|
5
|
+
import enUSJSON from './locales/en.json'
|
|
6
|
+
import zhCNJSON from './locales/zh-CN.json'
|
|
7
|
+
|
|
8
|
+
export const localesObj = {
|
|
9
|
+
enUS: enUSJSON,
|
|
10
|
+
zhCN: zhCNJSON,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const components: Record<string, FormaxComponent> = {
|
|
14
|
+
FormaxButton,
|
|
15
|
+
FormaxTable,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function install(app: any) {
|
|
19
|
+
Object.keys(components).forEach((key) => {
|
|
20
|
+
app.component(key, components[key])
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Extract metadata for low-code platform
|
|
25
|
+
export const componentList: ComponentMeta[] = Object.values(components)
|
|
26
|
+
.map((comp) => comp.__doc_meta__)
|
|
27
|
+
.filter((meta): meta is ComponentMeta => !!meta)
|
|
28
|
+
export { FormaxButton, FormaxTable }
|
|
29
|
+
export * from './types'
|
|
30
|
+
|
|
31
|
+
export default {
|
|
32
|
+
install,
|
|
33
|
+
componentList,
|
|
34
|
+
...components,
|
|
35
|
+
}
|
|
36
|
+
const __pkgLabelMap: Record<string, string> = {
|
|
37
|
+
general: '通用组件',
|
|
38
|
+
data: '数据组件',
|
|
39
|
+
}
|
|
40
|
+
const __catLabelMap: Record<string, string> = { button: '按钮', table: '表格' }
|
|
41
|
+
|
|
42
|
+
export const componentGoList: any[] = Object.values(components).reduce(
|
|
43
|
+
(acc: any[], comp: any) => {
|
|
44
|
+
const meta = comp.__doc_meta__ as ComponentMeta | undefined
|
|
45
|
+
if (!meta || !meta.package || !meta.category) return acc
|
|
46
|
+
const pkg = meta.package
|
|
47
|
+
const cat = meta.category
|
|
48
|
+
const key = meta.key || meta.name
|
|
49
|
+
let group = acc.find((g: any) => g.key === pkg)
|
|
50
|
+
if (!group) {
|
|
51
|
+
group = { key: pkg, label: __pkgLabelMap[pkg] || pkg, list: [] }
|
|
52
|
+
acc.push(group)
|
|
53
|
+
}
|
|
54
|
+
group.list.push({
|
|
55
|
+
key: cat,
|
|
56
|
+
title: meta.label,
|
|
57
|
+
package: pkg,
|
|
58
|
+
category: `${pkg[0].toUpperCase()}${cat}`,
|
|
59
|
+
categoryName: __catLabelMap[cat] || cat,
|
|
60
|
+
conKey: `${pkg[0].toUpperCase()}C${key}`,
|
|
61
|
+
image: `${pkg[0].toUpperCase()}C${key}.png`,
|
|
62
|
+
})
|
|
63
|
+
return acc
|
|
64
|
+
},
|
|
65
|
+
[]
|
|
66
|
+
)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"152ad41b95": "column display",
|
|
3
|
+
"4b9c3271dc": "reset",
|
|
4
|
+
"949a8b7bd2": "Column Settings",
|
|
5
|
+
"2b6bc0f293": "operation",
|
|
6
|
+
"0ec9eaf9c3": "more",
|
|
7
|
+
"63b6c98032": "Zebra Pattern Table",
|
|
8
|
+
"694fc5efa9": "refresh",
|
|
9
|
+
"1cdb193303": "density",
|
|
10
|
+
"03e59bb33c": "compact",
|
|
11
|
+
"18c63459a2": "default",
|
|
12
|
+
"43e534acf9": "loose"
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"152ad41b95": "列展示",
|
|
3
|
+
"4b9c3271dc": "重置",
|
|
4
|
+
"949a8b7bd2": "列设置",
|
|
5
|
+
"2b6bc0f293": "操作",
|
|
6
|
+
"0ec9eaf9c3": "更多",
|
|
7
|
+
"63b6c98032": "表格斑马纹",
|
|
8
|
+
"694fc5efa9": "刷新",
|
|
9
|
+
"1cdb193303": "密度",
|
|
10
|
+
"03e59bb33c": "紧凑",
|
|
11
|
+
"18c63459a2": "默认",
|
|
12
|
+
"43e534acf9": "宽松"
|
|
13
|
+
}
|
package/src/mock.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const componentGoList = [
|
|
2
|
+
{
|
|
3
|
+
key: 'general',
|
|
4
|
+
label: '通用组件',
|
|
5
|
+
list: [
|
|
6
|
+
{
|
|
7
|
+
key: 'button',
|
|
8
|
+
title: '通用按钮',
|
|
9
|
+
package: 'general',
|
|
10
|
+
category: 'Gbutton',
|
|
11
|
+
categoryName: '按钮',
|
|
12
|
+
conKey: "GCFormaxButton",
|
|
13
|
+
image: "GCFormaxButton.png"
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
]
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface PropMeta {
|
|
2
|
+
type: string
|
|
3
|
+
default?: any
|
|
4
|
+
description: string
|
|
5
|
+
options?: string[] // For enum types
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface EventMeta {
|
|
9
|
+
name: string
|
|
10
|
+
description: string
|
|
11
|
+
payload?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface SlotMeta {
|
|
15
|
+
name: string
|
|
16
|
+
description: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type Nullable<T> = T | null
|
|
20
|
+
export type Recordable<T = any> = Record<string, T>
|
|
21
|
+
|
|
22
|
+
export interface ComponentMeta {
|
|
23
|
+
name: string
|
|
24
|
+
label: string
|
|
25
|
+
description: string
|
|
26
|
+
props: Record<string, PropMeta>
|
|
27
|
+
events: EventMeta[]
|
|
28
|
+
slots?: SlotMeta[]
|
|
29
|
+
usage: string
|
|
30
|
+
package?: string
|
|
31
|
+
category?: string
|
|
32
|
+
key?: string
|
|
33
|
+
conKey?: string
|
|
34
|
+
image?: string
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Type for the component with attached metadata
|
|
38
|
+
export type FormaxComponent = any & {
|
|
39
|
+
__doc_meta__?: ComponentMeta
|
|
40
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2016",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"jsx": "preserve",
|
|
11
|
+
// 原有配置保留,新增/修改以下项
|
|
12
|
+
"resolveJsonModule": true, // 核心:开启 JSON 模块解析
|
|
13
|
+
"allowSyntheticDefaultImports": true // 可选:兼容默认导出
|
|
14
|
+
},
|
|
15
|
+
"include": ["src/**/*"]
|
|
16
|
+
}
|
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineConfig } from 'tsup'
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
esbuildPlugins: [
|
|
5
|
+
{
|
|
6
|
+
name: 'external-vue',
|
|
7
|
+
setup(build) {
|
|
8
|
+
build.onResolve({ filter: /\.vue$/ }, (args) => ({
|
|
9
|
+
path: args.path,
|
|
10
|
+
external: true,
|
|
11
|
+
}))
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
external: ['naive-ui', 'vue', '@vicons/antd', 'i18n-auto-extractor'],
|
|
16
|
+
})
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { defineConfig } from 'vite'
|
|
2
|
+
import vue from '@vitejs/plugin-vue'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
import dts from 'vite-plugin-dts'
|
|
5
|
+
|
|
6
|
+
export default defineConfig(({ mode }) => {
|
|
7
|
+
const isLibrary = mode === 'library'
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
root: isLibrary ? '.' : 'playground',
|
|
11
|
+
plugins: [
|
|
12
|
+
vue(),
|
|
13
|
+
isLibrary &&
|
|
14
|
+
dts({
|
|
15
|
+
include: ['src/**/*.ts', 'src/**/*.vue'],
|
|
16
|
+
outputDir: 'dist',
|
|
17
|
+
}),
|
|
18
|
+
],
|
|
19
|
+
resolve: {
|
|
20
|
+
alias: {
|
|
21
|
+
'@': path.resolve(__dirname, 'src'),
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
build: isLibrary
|
|
25
|
+
? {
|
|
26
|
+
lib: {
|
|
27
|
+
entry: path.resolve(__dirname, 'src/index.ts'),
|
|
28
|
+
name: 'FormaxUI',
|
|
29
|
+
fileName: (format) => `index.${format === 'es' ? 'mjs' : 'js'}`,
|
|
30
|
+
formats: ['es', 'cjs', 'umd'],
|
|
31
|
+
},
|
|
32
|
+
rollupOptions: {
|
|
33
|
+
external: [
|
|
34
|
+
'vue',
|
|
35
|
+
'naive-ui',
|
|
36
|
+
'@vicons/antd',
|
|
37
|
+
'i18n-auto-extractor',
|
|
38
|
+
],
|
|
39
|
+
output: {
|
|
40
|
+
globals: {
|
|
41
|
+
vue: 'Vue',
|
|
42
|
+
'naive-ui': 'naive',
|
|
43
|
+
'@vicons/antd': 'vicons',
|
|
44
|
+
'i18n-auto-extractor': 'i18nAutoExtractor',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
outDir: 'dist',
|
|
49
|
+
emptyOutDir: true,
|
|
50
|
+
}
|
|
51
|
+
: {
|
|
52
|
+
outDir: path.resolve(__dirname, 'dist-playground'),
|
|
53
|
+
},
|
|
54
|
+
server: {
|
|
55
|
+
port: 3001,
|
|
56
|
+
open: true,
|
|
57
|
+
},
|
|
58
|
+
}
|
|
59
|
+
})
|