@vuetkit/components 0.0.14 → 0.0.16
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 +60 -2
- package/dist/index.js +140 -2
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
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 { CollapseItemProps, CollapseModelValue, CollapseProps, 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
|
|
|
6
|
+
//#region src/data/useCollapse/index.d.ts
|
|
7
|
+
interface CollapseColumn extends Partial<CollapseItemProps> {
|
|
8
|
+
title?: string;
|
|
9
|
+
name?: string | number;
|
|
10
|
+
render?: (val: unknown) => VNode;
|
|
11
|
+
renderTitle?: (val: unknown) => VNode;
|
|
12
|
+
renderIcon?: (val: unknown) => VNode;
|
|
13
|
+
}
|
|
14
|
+
interface CollapseOptions<T> extends Partial<CollapseProps> {
|
|
15
|
+
columns: CollapseColumn[];
|
|
16
|
+
service?: RequestService<T>;
|
|
17
|
+
params?: unknown;
|
|
18
|
+
formatData?: (data: T) => CollapseColumn[];
|
|
19
|
+
defaultActive?: CollapseModelValue;
|
|
20
|
+
onChange?: (activeNames: CollapseModelValue) => void;
|
|
21
|
+
}
|
|
22
|
+
type CollapseReturnType = [Component, Ref<CollapseModelValue>];
|
|
23
|
+
declare function useCollapse<T>(options: CollapseOptions<T>): CollapseReturnType;
|
|
24
|
+
//#endregion
|
|
6
25
|
//#region src/data/useDescriptions/index.d.ts
|
|
7
26
|
interface DescriptionsColumn extends Partial<DescriptionItemProps> {
|
|
8
27
|
value?: string;
|
|
@@ -137,6 +156,45 @@ declare function useSteps<T>(options: StepsOptions<T>): (Ref<number, number> | i
|
|
|
137
156
|
modelValue: number;
|
|
138
157
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>)[];
|
|
139
158
|
//#endregion
|
|
159
|
+
//#region src/navigation/useTabs/index.d.ts
|
|
160
|
+
interface TabsColumn {
|
|
161
|
+
label?: string;
|
|
162
|
+
name?: string | number;
|
|
163
|
+
disabled?: boolean;
|
|
164
|
+
closable?: boolean;
|
|
165
|
+
lazy?: boolean;
|
|
166
|
+
render?: (val: unknown) => VNode;
|
|
167
|
+
renderLabel?: (val: unknown) => VNode;
|
|
168
|
+
}
|
|
169
|
+
interface TabsOptions<T> extends Partial<TabsProps> {
|
|
170
|
+
tabs: TabsColumn[];
|
|
171
|
+
service?: RequestService<T>;
|
|
172
|
+
params?: unknown;
|
|
173
|
+
formatData?: (data: T) => TabsColumn[];
|
|
174
|
+
defaultActive?: string | number;
|
|
175
|
+
onTabClick?: (tab: TabsPaneContext, event: Event) => void;
|
|
176
|
+
onTabChange?: (name: TabPaneName) => void;
|
|
177
|
+
onTabRemove?: (name: TabPaneName) => void;
|
|
178
|
+
onTabAdd?: () => void;
|
|
179
|
+
onEdit?: (targetName: TabPaneName | undefined, action: 'remove' | 'add') => void;
|
|
180
|
+
}
|
|
181
|
+
type TabsReturnType = [Component, Ref<string | number>];
|
|
182
|
+
declare function useTabs<T>(options: TabsOptions<T>): (Ref<string | number, string | number> | import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
183
|
+
modelValue: {
|
|
184
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
185
|
+
default: undefined;
|
|
186
|
+
};
|
|
187
|
+
}>, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
188
|
+
[key: string]: any;
|
|
189
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
190
|
+
modelValue: {
|
|
191
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
192
|
+
default: undefined;
|
|
193
|
+
};
|
|
194
|
+
}>> & Readonly<{}>, {
|
|
195
|
+
modelValue: string | number;
|
|
196
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>)[];
|
|
197
|
+
//#endregion
|
|
140
198
|
//#region src/table/useTable/index.d.ts
|
|
141
199
|
type DefaultRow = Record<PropertyKey, any>;
|
|
142
200
|
interface PaginationData<T> {
|
|
@@ -165,4 +223,4 @@ interface TableOptions<T extends DefaultRow> extends TableProps<T> {
|
|
|
165
223
|
type TableReturn = [Component];
|
|
166
224
|
declare function useTable<T extends DefaultRow>(options: TableOptions<T>): TableReturn;
|
|
167
225
|
//#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 };
|
|
226
|
+
export { AsyncConfirmOptions, CollapseColumn, CollapseOptions, CollapseReturnType, CustomRender, DefaultComponentKey, DescriptionsColumn, DescriptionsOptions, DescriptionsReturnType, FormItemType, FormOptions, FormReturnType, FormRuleFn, FormSchema, PaginationOptions, Recordable, StepsColumn, StepsOptions, StepsReturnType, TableColumnOptions, TableOptions, TableReturn, TabsColumn, TabsOptions, TabsReturnType, setDeepProperty, useAsyncConfirm, useCollapse, useDescriptions, useDialog, useForm, useMessage, useSteps, useTable, useTabs };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,68 @@
|
|
|
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, ElCollapse, ElCollapseItem, 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
|
+
//#region src/data/useCollapse/index.ts
|
|
6
|
+
function useCollapse(options) {
|
|
7
|
+
const { columns = [], service, params, formatData, defaultActive = [], onChange, ...rest } = options;
|
|
8
|
+
const { data, loading } = service ? useRequest(service, {
|
|
9
|
+
defaultParams: params,
|
|
10
|
+
formatData: formatData || void 0
|
|
11
|
+
}) : {};
|
|
12
|
+
const activeNames = ref(defaultActive);
|
|
13
|
+
const collapseColumns = computed(() => (data === null || data === void 0 ? void 0 : data.value) || columns);
|
|
14
|
+
return [defineComponent({
|
|
15
|
+
props: { modelValue: {
|
|
16
|
+
type: [
|
|
17
|
+
String,
|
|
18
|
+
Number,
|
|
19
|
+
Array
|
|
20
|
+
],
|
|
21
|
+
default: void 0
|
|
22
|
+
} },
|
|
23
|
+
setup(props, { slots, emit }) {
|
|
24
|
+
const renderColumns = () => {
|
|
25
|
+
var _collapseColumns$valu;
|
|
26
|
+
return (_collapseColumns$valu = collapseColumns.value) === null || _collapseColumns$valu === void 0 ? void 0 : _collapseColumns$valu.map((item, index) => {
|
|
27
|
+
var _item$name;
|
|
28
|
+
const itemName = (_item$name = item.name) !== null && _item$name !== void 0 ? _item$name : index;
|
|
29
|
+
return h(ElCollapseItem, {
|
|
30
|
+
...item,
|
|
31
|
+
name: itemName
|
|
32
|
+
}, {
|
|
33
|
+
default: () => {
|
|
34
|
+
if (item === null || item === void 0 ? void 0 : item.render) return item.render(item);
|
|
35
|
+
return "";
|
|
36
|
+
},
|
|
37
|
+
title: (item === null || item === void 0 ? void 0 : item.renderTitle) ? () => item.renderTitle(item.title) : void 0,
|
|
38
|
+
icon: (item === null || item === void 0 ? void 0 : item.renderIcon) ? () => item.renderIcon(item.icon) : void 0
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
const handleChange = (val) => {
|
|
43
|
+
activeNames.value = val;
|
|
44
|
+
onChange === null || onChange === void 0 || onChange(val);
|
|
45
|
+
emit("change", val);
|
|
46
|
+
};
|
|
47
|
+
return () => {
|
|
48
|
+
var _ref, _props$modelValue, _loading$value;
|
|
49
|
+
const finalActiveNames = (_ref = (_props$modelValue = props.modelValue) !== null && _props$modelValue !== void 0 ? _props$modelValue : rest.modelValue) !== null && _ref !== void 0 ? _ref : activeNames.value;
|
|
50
|
+
return withDirectives(h(ElCollapse, {
|
|
51
|
+
...rest,
|
|
52
|
+
...props,
|
|
53
|
+
"modelValue": finalActiveNames,
|
|
54
|
+
"onUpdate:modelValue": handleChange,
|
|
55
|
+
"onChange": handleChange
|
|
56
|
+
}, { default: () => {
|
|
57
|
+
if (slots.default) return slots.default();
|
|
58
|
+
if (!collapseColumns.value.length) return "";
|
|
59
|
+
return renderColumns();
|
|
60
|
+
} }), [[vLoading, (_loading$value = loading === null || loading === void 0 ? void 0 : loading.value) !== null && _loading$value !== void 0 ? _loading$value : false]]);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}), activeNames];
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
5
66
|
//#region src/data/useDescriptions/index.ts
|
|
6
67
|
function useDescriptions(options) {
|
|
7
68
|
const { columns = [], service, params, formatData, ...rest } = options;
|
|
@@ -412,6 +473,83 @@ function useSteps(options) {
|
|
|
412
473
|
}), active];
|
|
413
474
|
}
|
|
414
475
|
//#endregion
|
|
476
|
+
//#region src/navigation/useTabs/index.ts
|
|
477
|
+
function useTabs(options) {
|
|
478
|
+
const { tabs = [], service, params, formatData, defaultActive = 0, onTabClick, onTabChange, onTabRemove, onTabAdd, onEdit, ...rest } = options;
|
|
479
|
+
const { data, loading } = service ? useRequest(service, {
|
|
480
|
+
defaultParams: params,
|
|
481
|
+
formatData: formatData || void 0
|
|
482
|
+
}) : {};
|
|
483
|
+
const activeName = ref(defaultActive);
|
|
484
|
+
const tabsColumns = computed(() => (data === null || data === void 0 ? void 0 : data.value) || tabs);
|
|
485
|
+
return [defineComponent({
|
|
486
|
+
props: { modelValue: {
|
|
487
|
+
type: [String, Number],
|
|
488
|
+
default: void 0
|
|
489
|
+
} },
|
|
490
|
+
setup(props, { slots, emit }) {
|
|
491
|
+
const renderTabs = () => {
|
|
492
|
+
var _tabsColumns$value;
|
|
493
|
+
return (_tabsColumns$value = tabsColumns.value) === null || _tabsColumns$value === void 0 ? void 0 : _tabsColumns$value.map((item, index) => {
|
|
494
|
+
var _item$name;
|
|
495
|
+
const tabName = (_item$name = item.name) !== null && _item$name !== void 0 ? _item$name : index;
|
|
496
|
+
return h(ElTabPane, {
|
|
497
|
+
...item,
|
|
498
|
+
name: tabName
|
|
499
|
+
}, {
|
|
500
|
+
label: (item === null || item === void 0 ? void 0 : item.renderLabel) ? () => item.renderLabel(item.label) : void 0,
|
|
501
|
+
default: () => {
|
|
502
|
+
if (item === null || item === void 0 ? void 0 : item.render) return item.render(item);
|
|
503
|
+
return "";
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
});
|
|
507
|
+
};
|
|
508
|
+
const handleTabClick = (tab, event) => {
|
|
509
|
+
onTabClick === null || onTabClick === void 0 || onTabClick(tab, event);
|
|
510
|
+
emit("tab-click", tab, event);
|
|
511
|
+
};
|
|
512
|
+
const handleTabChange = (name) => {
|
|
513
|
+
onTabChange === null || onTabChange === void 0 || onTabChange(name);
|
|
514
|
+
emit("tab-change", name);
|
|
515
|
+
};
|
|
516
|
+
const handleTabRemove = (name) => {
|
|
517
|
+
onTabRemove === null || onTabRemove === void 0 || onTabRemove(name);
|
|
518
|
+
emit("tab-remove", name);
|
|
519
|
+
};
|
|
520
|
+
const handleTabAdd = () => {
|
|
521
|
+
onTabAdd === null || onTabAdd === void 0 || onTabAdd();
|
|
522
|
+
emit("tab-add");
|
|
523
|
+
};
|
|
524
|
+
const handleEdit = (targetName, action) => {
|
|
525
|
+
onEdit === null || onEdit === void 0 || onEdit(targetName, action);
|
|
526
|
+
emit("edit", targetName, action);
|
|
527
|
+
};
|
|
528
|
+
return () => {
|
|
529
|
+
var _ref, _props$modelValue, _loading$value;
|
|
530
|
+
const finalActiveName = (_ref = (_props$modelValue = props.modelValue) !== null && _props$modelValue !== void 0 ? _props$modelValue : rest.modelValue) !== null && _ref !== void 0 ? _ref : activeName.value;
|
|
531
|
+
return withDirectives(h(ElTabs, {
|
|
532
|
+
...rest,
|
|
533
|
+
...props,
|
|
534
|
+
"modelValue": finalActiveName,
|
|
535
|
+
"onUpdate:modelValue": (val) => {
|
|
536
|
+
activeName.value = val;
|
|
537
|
+
},
|
|
538
|
+
"onTabClick": handleTabClick,
|
|
539
|
+
"onTabChange": handleTabChange,
|
|
540
|
+
"onTabRemove": handleTabRemove,
|
|
541
|
+
"onTabAdd": handleTabAdd,
|
|
542
|
+
"onEdit": handleEdit
|
|
543
|
+
}, { default: () => {
|
|
544
|
+
if (slots.default) return slots.default();
|
|
545
|
+
if (!tabsColumns.value.length) return "";
|
|
546
|
+
return renderTabs();
|
|
547
|
+
} }), [[vLoading, (_loading$value = loading === null || loading === void 0 ? void 0 : loading.value) !== null && _loading$value !== void 0 ? _loading$value : false]]);
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
}), activeName];
|
|
551
|
+
}
|
|
552
|
+
//#endregion
|
|
415
553
|
//#region src/table/useTable/index.ts
|
|
416
554
|
function useTable(options) {
|
|
417
555
|
const { columns = [], service, params, formatData, align, headerAlign, paginationConfig, searchFormConfig, tableWrapStyle = {}, data = [], ...rest } = options;
|
|
@@ -560,4 +698,4 @@ function useTable(options) {
|
|
|
560
698
|
})];
|
|
561
699
|
}
|
|
562
700
|
//#endregion
|
|
563
|
-
export { setDeepProperty, useAsyncConfirm, useDescriptions, useDialog, useForm, useMessage, useSteps, useTable };
|
|
701
|
+
export { setDeepProperty, useAsyncConfirm, useCollapse, 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.16",
|
|
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.16",
|
|
25
|
+
"@vuetkit/shared": "0.0.16"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build": "tsdown --config-loader tsx"
|