@vuetkit/components 0.0.9 → 0.0.10
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 +4 -0
- package/dist/index.d.ts +37 -3
- package/dist/index.js +46 -2
- package/package.json +2 -2
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RequestService } from "@vuetkit/core";
|
|
2
|
-
import { ComponentSize, FormRules, MessageProps, MessageType } from "element-plus";
|
|
3
|
-
import { Component } from "vue";
|
|
2
|
+
import { ComponentSize, FormRules, MessageProps, MessageType, TableColumnCtx, TableProps } from "element-plus";
|
|
3
|
+
import { Component, VNode } from "vue";
|
|
4
4
|
|
|
5
5
|
//#region src/feedback/useAsyncConfirm/index.d.ts
|
|
6
6
|
interface AsyncConfirmOptions {
|
|
@@ -78,4 +78,38 @@ type FormReturnType<T extends object> = [Component, {
|
|
|
78
78
|
declare function setDeepProperty(data: Recordable, propArr: string[], value: unknown): void;
|
|
79
79
|
declare function useForm<T extends object>(options: FormOptions<T>): FormReturnType<T>;
|
|
80
80
|
//#endregion
|
|
81
|
-
|
|
81
|
+
//#region src/table/useTable/index.d.ts
|
|
82
|
+
type DefaultRow = Record<PropertyKey, any>;
|
|
83
|
+
interface TableColumn<T extends DefaultRow> {
|
|
84
|
+
render?: (row: T) => VNode | string;
|
|
85
|
+
children?: TableColumn<T>[];
|
|
86
|
+
prop?: string;
|
|
87
|
+
label?: string;
|
|
88
|
+
width?: string | number;
|
|
89
|
+
minWidth?: string | number;
|
|
90
|
+
fixed?: boolean | 'left' | 'right';
|
|
91
|
+
align?: 'left' | 'center' | 'right';
|
|
92
|
+
headerAlign?: 'left' | 'center' | 'right';
|
|
93
|
+
className?: string;
|
|
94
|
+
labelClassName?: string;
|
|
95
|
+
showOverflowTooltip?: boolean;
|
|
96
|
+
sortable?: boolean | string;
|
|
97
|
+
sortMethod?: (a: T, b: T) => number;
|
|
98
|
+
sortBy?: string | string[];
|
|
99
|
+
sortOrders?: ('ascending' | 'descending')[];
|
|
100
|
+
resizable?: boolean;
|
|
101
|
+
formatter?: (row: T, column: TableColumnCtx<T>, cellValue: any, index: number) => any;
|
|
102
|
+
type?: 'selection' | 'index' | 'expand';
|
|
103
|
+
selectable?: (row: T, index: number) => boolean;
|
|
104
|
+
reserveSelection?: boolean;
|
|
105
|
+
index?: number | ((index: number) => number);
|
|
106
|
+
}
|
|
107
|
+
interface TableOptions<T extends DefaultRow> extends TableProps<T> {
|
|
108
|
+
columns: TableColumn<T>[];
|
|
109
|
+
align?: 'left' | 'center' | 'right';
|
|
110
|
+
headerAlign?: 'left' | 'center' | 'right';
|
|
111
|
+
}
|
|
112
|
+
type TableReturn = [Component];
|
|
113
|
+
declare function useTable<T extends DefaultRow>(options: TableOptions<T>): TableReturn;
|
|
114
|
+
//#endregion
|
|
115
|
+
export { AsyncConfirmOptions, CustomRender, DefaultComponentKey, FormItemType, FormOptions, FormReturnType, FormRuleFn, FormSchema, Recordable, TableColumn, TableOptions, TableReturn, setDeepProperty, useAsyncConfirm, useForm, useMessage, useTable };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useRequest } from "@vuetkit/core";
|
|
2
|
-
import { ElCascader, ElCheckbox, ElCol, ElColorPicker, ElDatePicker, ElForm, ElFormItem, ElInput, ElInputNumber, ElInputOtp, ElMention, ElMessage, ElMessageBox, ElRadio, ElRate, ElRow, ElSelect, ElSelectV2, ElSlider, ElSwitch, ElTimePicker, ElTimeSelect, ElTransfer, ElTreeSelect, ElUpload } from "element-plus";
|
|
2
|
+
import { ElCascader, ElCheckbox, ElCol, ElColorPicker, ElDatePicker, ElForm, ElFormItem, ElInput, ElInputNumber, ElInputOtp, ElMention, ElMessage, ElMessageBox, ElRadio, ElRate, ElRow, ElSelect, ElSelectV2, ElSlider, ElSwitch, ElTable, ElTableColumn, ElTimePicker, ElTimeSelect, ElTransfer, ElTreeSelect, ElUpload } from "element-plus";
|
|
3
3
|
import { isFunc } from "@vuetkit/shared";
|
|
4
4
|
import { computed, defineComponent, h, nextTick, onMounted, ref, useTemplateRef } from "vue";
|
|
5
5
|
//#region src/feedback/useMessage/index.ts
|
|
@@ -270,4 +270,48 @@ function useForm(options) {
|
|
|
270
270
|
}];
|
|
271
271
|
}
|
|
272
272
|
//#endregion
|
|
273
|
-
|
|
273
|
+
//#region src/table/useTable/index.ts
|
|
274
|
+
function useTable(options) {
|
|
275
|
+
const { columns, align, headerAlign, ...rest } = options;
|
|
276
|
+
return [defineComponent((props, { slots }) => {
|
|
277
|
+
const renderTableItemNodes = (column) => {
|
|
278
|
+
var _column$children;
|
|
279
|
+
if (isFunc(column.render)) return { default: ({ row }) => column.render(row) };
|
|
280
|
+
const tableItemNodes = [];
|
|
281
|
+
if (column === null || column === void 0 || (_column$children = column.children) === null || _column$children === void 0 ? void 0 : _column$children.length) tableItemNodes.push(...renderTableItems(column.children));
|
|
282
|
+
return () => tableItemNodes;
|
|
283
|
+
};
|
|
284
|
+
const renderTableItem = (column) => {
|
|
285
|
+
const { align: columnAlign, headerAlign: columnHeaderAlign } = column;
|
|
286
|
+
const tableItemAlign = columnAlign || align || "left";
|
|
287
|
+
const tableItemHeaderAlign = columnHeaderAlign || headerAlign || "left";
|
|
288
|
+
return h(ElTableColumn, {
|
|
289
|
+
...column,
|
|
290
|
+
align: tableItemAlign,
|
|
291
|
+
headerAlign: tableItemHeaderAlign
|
|
292
|
+
}, renderTableItemNodes(column));
|
|
293
|
+
};
|
|
294
|
+
const renderTableItems = (columns) => {
|
|
295
|
+
return columns.filter(Boolean).map((column) => {
|
|
296
|
+
return renderTableItem(column);
|
|
297
|
+
});
|
|
298
|
+
};
|
|
299
|
+
return () => {
|
|
300
|
+
return h(ElTable, {
|
|
301
|
+
...rest,
|
|
302
|
+
...props
|
|
303
|
+
}, {
|
|
304
|
+
default: () => {
|
|
305
|
+
const tableNodes = [];
|
|
306
|
+
if (columns.length) tableNodes.push(...renderTableItems(columns));
|
|
307
|
+
if (slots.actions) tableNodes.push(slots.actions());
|
|
308
|
+
return tableNodes;
|
|
309
|
+
},
|
|
310
|
+
append: slots === null || slots === void 0 ? void 0 : slots.append,
|
|
311
|
+
empty: slots === null || slots === void 0 ? void 0 : slots.empty
|
|
312
|
+
});
|
|
313
|
+
};
|
|
314
|
+
})];
|
|
315
|
+
}
|
|
316
|
+
//#endregion
|
|
317
|
+
export { setDeepProperty, useAsyncConfirm, useForm, useMessage, useTable };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuetkit/components",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.10",
|
|
5
5
|
"description": "Collection of business development components for Vue3 projects",
|
|
6
6
|
"author": "Kalu5",
|
|
7
7
|
"license": "MIT",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"vue": "^3.5.35"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@vuetkit/shared": "0.0.
|
|
24
|
+
"@vuetkit/shared": "0.0.10"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "tsdown --config-loader tsx"
|