rayyy-vue-table-components 1.0.15 → 1.0.17

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
@@ -94,6 +94,117 @@ const handleSortChange = (sortInfo: SortChangValue<User>) => {
94
94
  </script>
95
95
  ```
96
96
 
97
+ ## TypeScript 類型支持
98
+
99
+ 本庫提供完整的 TypeScript 類型定義,包括:
100
+
101
+ ### 組件類型
102
+
103
+ ```typescript
104
+ import type {
105
+ // BaseTable 組件類型
106
+ BaseTableProps,
107
+ BaseTableEmits,
108
+ BaseTableInstance,
109
+
110
+ // BaseBtn 組件類型
111
+ BaseBtnProps,
112
+ BaseBtnEmits,
113
+ BaseBtnInstance,
114
+
115
+ // BaseDialog 組件類型
116
+ BaseDialogProps,
117
+ BaseDialogEmits,
118
+ BaseDialogInstance,
119
+
120
+ // 插件類型
121
+ PluginOptions,
122
+ VueTableComponentsPlugin
123
+ } from 'rayyy-vue-table-components/types/components'
124
+ ```
125
+
126
+ ### 數據類型
127
+
128
+ ```typescript
129
+ import type {
130
+ TableColumn,
131
+ SortChangValue,
132
+ TableListReq,
133
+ Pager,
134
+ MenuItemType,
135
+ QRCodeResult
136
+ } from 'rayyy-vue-table-components/types'
137
+ ```
138
+
139
+ ### 使用示例
140
+
141
+ ```typescript
142
+ // 定義數據類型
143
+ interface User extends Record<string, unknown> {
144
+ id: number
145
+ name: string
146
+ email: string
147
+ age: number
148
+ status: 'active' | 'inactive'
149
+ }
150
+
151
+ // 定義表格列配置
152
+ const userColumns: TableColumn<User>[] = [
153
+ {
154
+ prop: 'id',
155
+ label: 'ID',
156
+ width: 80,
157
+ align: 'center'
158
+ },
159
+ {
160
+ prop: 'name',
161
+ label: '姓名',
162
+ width: 120
163
+ },
164
+ {
165
+ prop: 'email',
166
+ label: '郵箱',
167
+ width: 200
168
+ },
169
+ {
170
+ prop: 'age',
171
+ label: '年齡',
172
+ width: 80,
173
+ align: 'center',
174
+ sortable: true
175
+ },
176
+ {
177
+ prop: 'status',
178
+ label: '狀態',
179
+ width: 100,
180
+ align: 'center',
181
+ formatter: (row: User) => row.status === 'active' ? '啟用' : '停用'
182
+ }
183
+ ]
184
+
185
+ // 表格數據
186
+ const userData: User[] = [
187
+ { id: 1, name: '張三', email: 'zhangsan@example.com', age: 25, status: 'active' },
188
+ { id: 2, name: '李四', email: 'lisi@example.com', age: 30, status: 'inactive' }
189
+ ]
190
+
191
+ // BaseTable Props 類型示例
192
+ const tableProps: BaseTableProps<User> = {
193
+ loading: false,
194
+ data: userData,
195
+ columns: userColumns,
196
+ showSelection: true,
197
+ showSummary: true,
198
+ showOverFlowTooltip: true,
199
+ summaryMethod: ({ columns, data }) => {
200
+ return ['總計', '', '', data.reduce((sum, user) => sum + user.age, 0).toString(), '']
201
+ },
202
+ baseTableRowClassName: ({ row, rowIndex }) => {
203
+ return row.status === 'active' ? 'active-row' : 'inactive-row'
204
+ }
205
+ }
206
+ ```
207
+
97
208
  ## API
98
209
 
99
210
  ### BaseTable Props
package/dist/index.d.ts CHANGED
@@ -1 +1,6 @@
1
+ export * from './src/index'
2
+ export {}
3
+ import VueTableComponents from './src/index'
4
+ export default VueTableComponents
5
+ export * from './src/index'
1
6
  export {}
@@ -0,0 +1,2 @@
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLDivElement>;
2
+ export default _default;
@@ -0,0 +1,35 @@
1
+ type __VLS_Props = {
2
+ text?: string;
3
+ type?: 'default' | 'primary' | 'success' | 'warning' | 'info' | 'danger';
4
+ size?: 'default' | 'small' | 'large';
5
+ plain?: boolean;
6
+ class?: string;
7
+ disabled?: boolean;
8
+ textBtn?: boolean;
9
+ icon?: object;
10
+ link?: boolean;
11
+ isFill?: boolean;
12
+ loading?: boolean;
13
+ dataCy?: string;
14
+ };
15
+ declare function __VLS_template(): {
16
+ attrs: Partial<{}>;
17
+ slots: {
18
+ default?(_: {}): any;
19
+ };
20
+ refs: {};
21
+ rootEl: any;
22
+ };
23
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
24
+ declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
25
+ click: (evt: MouseEvent) => any;
26
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
27
+ onClick?: ((evt: MouseEvent) => any) | undefined;
28
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
29
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
30
+ export default _default;
31
+ type __VLS_WithTemplateSlots<T, S> = T & {
32
+ new (): {
33
+ $slots: S;
34
+ };
35
+ };
@@ -0,0 +1,36 @@
1
+ type __VLS_Props = {
2
+ modelValue: boolean;
3
+ title?: string;
4
+ subTitle?: string;
5
+ beforeClose?: () => void;
6
+ customWidth?: string;
7
+ isWaring?: boolean;
8
+ isPrimary?: boolean;
9
+ bodyLoading?: boolean;
10
+ submitLoading?: boolean;
11
+ };
12
+ declare function __VLS_template(): {
13
+ attrs: Partial<{}>;
14
+ slots: {
15
+ customHeader?(_: {}): any;
16
+ default?(_: {}): any;
17
+ customFooter?(_: {}): any;
18
+ };
19
+ refs: {};
20
+ rootEl: any;
21
+ };
22
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
23
+ declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
24
+ "update:modelValue": (data: boolean) => any;
25
+ "click:submit": () => any;
26
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
27
+ "onUpdate:modelValue"?: ((data: boolean) => any) | undefined;
28
+ "onClick:submit"?: (() => any) | undefined;
29
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
30
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
31
+ export default _default;
32
+ type __VLS_WithTemplateSlots<T, S> = T & {
33
+ new (): {
34
+ $slots: S;
35
+ };
36
+ };
@@ -0,0 +1,41 @@
1
+ import { VNode } from 'vue';
2
+ import { TableColumnCtx } from 'element-plus';
3
+ import { SortChangValue, TableColumn } from 'src/types';
4
+ declare const _default: <T extends Record<string, unknown> = Record<string, unknown>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
5
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
6
+ readonly "onSelection-change"?: ((selection: T[]) => any) | undefined;
7
+ readonly "onCurrent-change"?: ((currentRow: T) => any) | undefined;
8
+ readonly "onColumn-sort-change"?: ((value: SortChangValue<T>) => any) | undefined;
9
+ readonly "onCell-click"?: ((column: TableColumn<T>, row: T) => any) | undefined;
10
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onSelection-change" | "onCurrent-change" | "onColumn-sort-change" | "onCell-click"> & {
11
+ loading?: boolean;
12
+ data: T[];
13
+ columns: TableColumn<T>[];
14
+ showSelection?: boolean;
15
+ showSummary?: boolean;
16
+ showOverFlowTooltip?: boolean;
17
+ summaryMethod?: ((param: {
18
+ columns: TableColumnCtx<Record<string, unknown>>[];
19
+ data: T[];
20
+ }) => (string | VNode)[]) | undefined;
21
+ baseTableRowClassName?: ((data: {
22
+ row: T;
23
+ rowIndex: number;
24
+ }) => string) | undefined;
25
+ } & Partial<{}>> & import('vue').PublicProps;
26
+ expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
27
+ attrs: any;
28
+ slots: {};
29
+ emit: {
30
+ (e: "selection-change", selection: T[]): void;
31
+ (e: "current-change", currentRow: T): void;
32
+ (e: "cell-click", column: TableColumn<T>, row: T): void;
33
+ (e: "column-sort-change", value: SortChangValue<T>): void;
34
+ };
35
+ }>) => import('vue').VNode & {
36
+ __ctx?: Awaited<typeof __VLS_setup>;
37
+ };
38
+ export default _default;
39
+ type __VLS_PrettifyLocal<T> = {
40
+ [K in keyof T]: T[K];
41
+ } & {};
@@ -0,0 +1,7 @@
1
+ export { default as BaseTable } from './BaseTable.vue';
2
+ export { default as BaseBtn } from './BaseBtn.vue';
3
+ export { default as BaseDialog } from './BaseDialog.vue';
4
+ export type { BaseTableProps, BaseTableEmits, BaseTableInstance, BaseBtnProps, BaseBtnEmits, BaseBtnInstance, BaseDialogProps, BaseDialogEmits, BaseDialogInstance, PluginOptions, VueTableComponentsPlugin } from '../types/components';
5
+ export type { default as BaseTableType } from './BaseTable.vue';
6
+ export type { default as BaseBtnType } from './BaseBtn.vue';
7
+ export type { default as BaseDialogType } from './BaseDialog.vue';
@@ -0,0 +1,18 @@
1
+ declare module 'rayyy-vue-table-components' {
2
+ import type { App } from 'vue'
3
+ import type { DefineComponent } from 'vue'
4
+
5
+ export function install(app: App, options?: Record<string, unknown>): void
6
+
7
+ export const BaseTable: DefineComponent
8
+ export const BaseBtn: DefineComponent
9
+ export const BaseDialog: DefineComponent
10
+
11
+ export * from './types'
12
+
13
+ const plugin: {
14
+ install: typeof install
15
+ }
16
+
17
+ export default plugin
18
+ }