@vuetkit/components 0.0.14 → 0.0.15
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/dist/index.d.ts +41 -2
- package/dist/index.js +79 -2
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RequestService } from "@vuetkit/core";
|
|
2
|
-
import { ComponentSize, DescriptionItemProps, DescriptionProps, DialogProps, FormRules, MessageProps, MessageType, PaginationProps, StepProps, StepsProps, TableProps } from "element-plus";
|
|
2
|
+
import { ComponentSize, DescriptionItemProps, DescriptionProps, DialogProps, FormRules, MessageProps, MessageType, PaginationProps, StepProps, StepsProps, TabPaneName, TableProps, TabsPaneContext, TabsProps } from "element-plus";
|
|
3
3
|
import { CSSProperties, Component, MaybeRef, Ref, VNode } from "vue";
|
|
4
4
|
import { TableColumnProps } from "element-plus/es/components/table/src/table-column/defaults.mjs";
|
|
5
5
|
|
|
@@ -137,6 +137,45 @@ declare function useSteps<T>(options: StepsOptions<T>): (Ref<number, number> | i
|
|
|
137
137
|
modelValue: number;
|
|
138
138
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>)[];
|
|
139
139
|
//#endregion
|
|
140
|
+
//#region src/navigation/useTabs/index.d.ts
|
|
141
|
+
interface TabsColumn {
|
|
142
|
+
label?: string;
|
|
143
|
+
name?: string | number;
|
|
144
|
+
disabled?: boolean;
|
|
145
|
+
closable?: boolean;
|
|
146
|
+
lazy?: boolean;
|
|
147
|
+
render?: (val: unknown) => VNode;
|
|
148
|
+
renderLabel?: (val: unknown) => VNode;
|
|
149
|
+
}
|
|
150
|
+
interface TabsOptions<T> extends Partial<TabsProps> {
|
|
151
|
+
tabs: TabsColumn[];
|
|
152
|
+
service?: RequestService<T>;
|
|
153
|
+
params?: unknown;
|
|
154
|
+
formatData?: (data: T) => TabsColumn[];
|
|
155
|
+
defaultActive?: string | number;
|
|
156
|
+
onTabClick?: (tab: TabsPaneContext, event: Event) => void;
|
|
157
|
+
onTabChange?: (name: TabPaneName) => void;
|
|
158
|
+
onTabRemove?: (name: TabPaneName) => void;
|
|
159
|
+
onTabAdd?: () => void;
|
|
160
|
+
onEdit?: (targetName: TabPaneName | undefined, action: 'remove' | 'add') => void;
|
|
161
|
+
}
|
|
162
|
+
type TabsReturnType = [Component, Ref<string | number>];
|
|
163
|
+
declare function useTabs<T>(options: TabsOptions<T>): (Ref<string | number, string | number> | import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
164
|
+
modelValue: {
|
|
165
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
166
|
+
default: undefined;
|
|
167
|
+
};
|
|
168
|
+
}>, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
169
|
+
[key: string]: any;
|
|
170
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
171
|
+
modelValue: {
|
|
172
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
173
|
+
default: undefined;
|
|
174
|
+
};
|
|
175
|
+
}>> & Readonly<{}>, {
|
|
176
|
+
modelValue: string | number;
|
|
177
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>)[];
|
|
178
|
+
//#endregion
|
|
140
179
|
//#region src/table/useTable/index.d.ts
|
|
141
180
|
type DefaultRow = Record<PropertyKey, any>;
|
|
142
181
|
interface PaginationData<T> {
|
|
@@ -165,4 +204,4 @@ interface TableOptions<T extends DefaultRow> extends TableProps<T> {
|
|
|
165
204
|
type TableReturn = [Component];
|
|
166
205
|
declare function useTable<T extends DefaultRow>(options: TableOptions<T>): TableReturn;
|
|
167
206
|
//#endregion
|
|
168
|
-
export { AsyncConfirmOptions, CustomRender, DefaultComponentKey, DescriptionsColumn, DescriptionsOptions, DescriptionsReturnType, FormItemType, FormOptions, FormReturnType, FormRuleFn, FormSchema, PaginationOptions, Recordable, StepsColumn, StepsOptions, StepsReturnType, TableColumnOptions, TableOptions, TableReturn, setDeepProperty, useAsyncConfirm, useDescriptions, useDialog, useForm, useMessage, useSteps, useTable };
|
|
207
|
+
export { AsyncConfirmOptions, CustomRender, DefaultComponentKey, DescriptionsColumn, DescriptionsOptions, DescriptionsReturnType, FormItemType, FormOptions, FormReturnType, FormRuleFn, FormSchema, PaginationOptions, Recordable, StepsColumn, StepsOptions, StepsReturnType, TableColumnOptions, TableOptions, TableReturn, TabsColumn, TabsOptions, TabsReturnType, setDeepProperty, useAsyncConfirm, useDescriptions, useDialog, useForm, useMessage, useSteps, useTable, useTabs };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useRequest } from "@vuetkit/core";
|
|
2
|
-
import { ElButton, ElCascader, ElCheckbox, ElCol, ElColorPicker, ElDatePicker, ElDescriptions, ElDescriptionsItem, ElDialog, ElForm, ElFormItem, ElInput, ElInputNumber, ElInputOtp, ElMention, ElMessage, ElMessageBox, ElPagination, ElRadio, ElRate, ElRow, ElScrollbar, ElSelect, ElSelectV2, ElSlider, ElStep, ElSteps, ElSwitch, ElTable, ElTableColumn, ElTimePicker, ElTimeSelect, ElTransfer, ElTreeSelect, ElUpload, vLoading } from "element-plus";
|
|
2
|
+
import { ElButton, ElCascader, ElCheckbox, ElCol, ElColorPicker, ElDatePicker, ElDescriptions, ElDescriptionsItem, ElDialog, ElForm, ElFormItem, ElInput, ElInputNumber, ElInputOtp, ElMention, ElMessage, ElMessageBox, ElPagination, ElRadio, ElRate, ElRow, ElScrollbar, ElSelect, ElSelectV2, ElSlider, ElStep, ElSteps, ElSwitch, ElTabPane, ElTable, ElTableColumn, ElTabs, ElTimePicker, ElTimeSelect, ElTransfer, ElTreeSelect, ElUpload, vLoading } from "element-plus";
|
|
3
3
|
import { computed, defineComponent, h, nextTick, onMounted, reactive, ref, toValue, useTemplateRef, watch, withDirectives } from "vue";
|
|
4
4
|
import { isFunc, realObj } from "@vuetkit/shared";
|
|
5
5
|
//#region src/data/useDescriptions/index.ts
|
|
@@ -412,6 +412,83 @@ function useSteps(options) {
|
|
|
412
412
|
}), active];
|
|
413
413
|
}
|
|
414
414
|
//#endregion
|
|
415
|
+
//#region src/navigation/useTabs/index.ts
|
|
416
|
+
function useTabs(options) {
|
|
417
|
+
const { tabs = [], service, params, formatData, defaultActive = 0, onTabClick, onTabChange, onTabRemove, onTabAdd, onEdit, ...rest } = options;
|
|
418
|
+
const { data, loading } = service ? useRequest(service, {
|
|
419
|
+
defaultParams: params,
|
|
420
|
+
formatData: formatData || void 0
|
|
421
|
+
}) : {};
|
|
422
|
+
const activeName = ref(defaultActive);
|
|
423
|
+
const tabsColumns = computed(() => (data === null || data === void 0 ? void 0 : data.value) || tabs);
|
|
424
|
+
return [defineComponent({
|
|
425
|
+
props: { modelValue: {
|
|
426
|
+
type: [String, Number],
|
|
427
|
+
default: void 0
|
|
428
|
+
} },
|
|
429
|
+
setup(props, { slots, emit }) {
|
|
430
|
+
const renderTabs = () => {
|
|
431
|
+
var _tabsColumns$value;
|
|
432
|
+
return (_tabsColumns$value = tabsColumns.value) === null || _tabsColumns$value === void 0 ? void 0 : _tabsColumns$value.map((item, index) => {
|
|
433
|
+
var _item$name;
|
|
434
|
+
const tabName = (_item$name = item.name) !== null && _item$name !== void 0 ? _item$name : index;
|
|
435
|
+
return h(ElTabPane, {
|
|
436
|
+
...item,
|
|
437
|
+
name: tabName
|
|
438
|
+
}, {
|
|
439
|
+
label: (item === null || item === void 0 ? void 0 : item.renderLabel) ? () => item.renderLabel(item.label) : void 0,
|
|
440
|
+
default: () => {
|
|
441
|
+
if (item === null || item === void 0 ? void 0 : item.render) return item.render(item);
|
|
442
|
+
return "";
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
});
|
|
446
|
+
};
|
|
447
|
+
const handleTabClick = (tab, event) => {
|
|
448
|
+
onTabClick === null || onTabClick === void 0 || onTabClick(tab, event);
|
|
449
|
+
emit("tab-click", tab, event);
|
|
450
|
+
};
|
|
451
|
+
const handleTabChange = (name) => {
|
|
452
|
+
onTabChange === null || onTabChange === void 0 || onTabChange(name);
|
|
453
|
+
emit("tab-change", name);
|
|
454
|
+
};
|
|
455
|
+
const handleTabRemove = (name) => {
|
|
456
|
+
onTabRemove === null || onTabRemove === void 0 || onTabRemove(name);
|
|
457
|
+
emit("tab-remove", name);
|
|
458
|
+
};
|
|
459
|
+
const handleTabAdd = () => {
|
|
460
|
+
onTabAdd === null || onTabAdd === void 0 || onTabAdd();
|
|
461
|
+
emit("tab-add");
|
|
462
|
+
};
|
|
463
|
+
const handleEdit = (targetName, action) => {
|
|
464
|
+
onEdit === null || onEdit === void 0 || onEdit(targetName, action);
|
|
465
|
+
emit("edit", targetName, action);
|
|
466
|
+
};
|
|
467
|
+
return () => {
|
|
468
|
+
var _ref, _props$modelValue, _loading$value;
|
|
469
|
+
const finalActiveName = (_ref = (_props$modelValue = props.modelValue) !== null && _props$modelValue !== void 0 ? _props$modelValue : rest.modelValue) !== null && _ref !== void 0 ? _ref : activeName.value;
|
|
470
|
+
return withDirectives(h(ElTabs, {
|
|
471
|
+
...rest,
|
|
472
|
+
...props,
|
|
473
|
+
"modelValue": finalActiveName,
|
|
474
|
+
"onUpdate:modelValue": (val) => {
|
|
475
|
+
activeName.value = val;
|
|
476
|
+
},
|
|
477
|
+
"onTabClick": handleTabClick,
|
|
478
|
+
"onTabChange": handleTabChange,
|
|
479
|
+
"onTabRemove": handleTabRemove,
|
|
480
|
+
"onTabAdd": handleTabAdd,
|
|
481
|
+
"onEdit": handleEdit
|
|
482
|
+
}, { default: () => {
|
|
483
|
+
if (slots.default) return slots.default();
|
|
484
|
+
if (!tabsColumns.value.length) return "";
|
|
485
|
+
return renderTabs();
|
|
486
|
+
} }), [[vLoading, (_loading$value = loading === null || loading === void 0 ? void 0 : loading.value) !== null && _loading$value !== void 0 ? _loading$value : false]]);
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
}), activeName];
|
|
490
|
+
}
|
|
491
|
+
//#endregion
|
|
415
492
|
//#region src/table/useTable/index.ts
|
|
416
493
|
function useTable(options) {
|
|
417
494
|
const { columns = [], service, params, formatData, align, headerAlign, paginationConfig, searchFormConfig, tableWrapStyle = {}, data = [], ...rest } = options;
|
|
@@ -560,4 +637,4 @@ function useTable(options) {
|
|
|
560
637
|
})];
|
|
561
638
|
}
|
|
562
639
|
//#endregion
|
|
563
|
-
export { setDeepProperty, useAsyncConfirm, useDescriptions, useDialog, useForm, useMessage, useSteps, useTable };
|
|
640
|
+
export { setDeepProperty, useAsyncConfirm, useDescriptions, useDialog, useForm, useMessage, useSteps, useTable, useTabs };
|
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.15",
|
|
5
5
|
"description": "Collection of business development components for Vue3 projects",
|
|
6
6
|
"author": "Kalu5",
|
|
7
7
|
"license": "MIT",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"vue": "^3.5.35"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@vuetkit/core": "0.0.
|
|
25
|
-
"@vuetkit/shared": "0.0.
|
|
24
|
+
"@vuetkit/core": "0.0.15",
|
|
25
|
+
"@vuetkit/shared": "0.0.15"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build": "tsdown --config-loader tsx"
|