@vuetkit/components 0.0.12 → 0.0.14
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 +8 -0
- package/dist/index.d.ts +56 -5
- package/dist/index.js +98 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -19,3 +19,11 @@ Collection of business development Composable Components for Vue3 + ElementPlus
|
|
|
19
19
|
### Table
|
|
20
20
|
|
|
21
21
|
- [useTable](/components/src/table/useTable/)
|
|
22
|
+
|
|
23
|
+
### Data
|
|
24
|
+
|
|
25
|
+
- [useDescriptions](/components/src/data/useDescriptions/)
|
|
26
|
+
|
|
27
|
+
### Navigation
|
|
28
|
+
|
|
29
|
+
- [useSteps](/components/src/navigation/useSteps/)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
import { RequestService } from "@vuetkit/core";
|
|
2
|
-
import { ComponentSize, DialogProps, FormRules, MessageProps, MessageType, PaginationProps, TableProps } from "element-plus";
|
|
3
|
-
import { CSSProperties, Component, MaybeRef, VNode } from "vue";
|
|
2
|
+
import { ComponentSize, DescriptionItemProps, DescriptionProps, DialogProps, FormRules, MessageProps, MessageType, PaginationProps, StepProps, StepsProps, TableProps } from "element-plus";
|
|
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/useDescriptions/index.d.ts
|
|
7
|
+
interface DescriptionsColumn extends Partial<DescriptionItemProps> {
|
|
8
|
+
value?: string;
|
|
9
|
+
render?: (val: unknown) => VNode;
|
|
10
|
+
renderLabel?: (val: unknown) => VNode;
|
|
11
|
+
}
|
|
12
|
+
interface DescriptionsOptions<T> extends DescriptionProps {
|
|
13
|
+
columns: DescriptionsColumn[];
|
|
14
|
+
service?: RequestService<T>;
|
|
15
|
+
params?: unknown;
|
|
16
|
+
formatData?: (data: T) => DescriptionsColumn[];
|
|
17
|
+
}
|
|
18
|
+
type DescriptionsReturnType = [Component];
|
|
19
|
+
declare function useDescriptions<T>(options: DescriptionsOptions<T>): import("vue").DefineSetupFnComponent<Record<string, any>, {}, {}, Record<string, any> & {}, import("vue").PublicProps>[];
|
|
20
|
+
//#endregion
|
|
6
21
|
//#region src/feedback/useAsyncConfirm/index.d.ts
|
|
7
22
|
interface AsyncConfirmOptions {
|
|
8
23
|
title?: string;
|
|
@@ -15,7 +30,7 @@ interface AsyncConfirmOptions {
|
|
|
15
30
|
confirmSuccess?: () => void;
|
|
16
31
|
confirmError?: (error: unknown) => void;
|
|
17
32
|
}
|
|
18
|
-
declare function useAsyncConfirm(confirmService: RequestService
|
|
33
|
+
declare function useAsyncConfirm<T>(confirmService: RequestService<T>, options: AsyncConfirmOptions): {
|
|
19
34
|
loading: import("vue").Ref<boolean, boolean>;
|
|
20
35
|
confirm: (params?: unknown) => void;
|
|
21
36
|
};
|
|
@@ -90,8 +105,44 @@ declare function setDeepProperty(data: Recordable, propArr: string[], value: unk
|
|
|
90
105
|
declare function useForm(options: undefined): [null, Recordable];
|
|
91
106
|
declare function useForm<T extends object>(options: FormOptions<T>): FormReturnType<T>;
|
|
92
107
|
//#endregion
|
|
108
|
+
//#region src/navigation/useSteps/index.d.ts
|
|
109
|
+
interface StepsColumn extends Partial<StepProps> {
|
|
110
|
+
title?: string;
|
|
111
|
+
description?: string;
|
|
112
|
+
render?: (val: unknown) => VNode;
|
|
113
|
+
renderTitle?: (val: unknown) => VNode;
|
|
114
|
+
renderIcon?: (val: unknown) => VNode;
|
|
115
|
+
}
|
|
116
|
+
interface StepsOptions<T> extends StepsProps {
|
|
117
|
+
steps: StepsColumn[];
|
|
118
|
+
service?: RequestService<T>;
|
|
119
|
+
params?: unknown;
|
|
120
|
+
formatData?: (data: T) => StepsColumn[];
|
|
121
|
+
defaultActive?: number;
|
|
122
|
+
}
|
|
123
|
+
type StepsReturnType = [Component, Ref<number>];
|
|
124
|
+
declare function useSteps<T>(options: StepsOptions<T>): (Ref<number, number> | import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
125
|
+
modelValue: {
|
|
126
|
+
type: NumberConstructor;
|
|
127
|
+
default: undefined;
|
|
128
|
+
};
|
|
129
|
+
}>, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
130
|
+
[key: string]: any;
|
|
131
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
132
|
+
modelValue: {
|
|
133
|
+
type: NumberConstructor;
|
|
134
|
+
default: undefined;
|
|
135
|
+
};
|
|
136
|
+
}>> & Readonly<{}>, {
|
|
137
|
+
modelValue: number;
|
|
138
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>)[];
|
|
139
|
+
//#endregion
|
|
93
140
|
//#region src/table/useTable/index.d.ts
|
|
94
141
|
type DefaultRow = Record<PropertyKey, any>;
|
|
142
|
+
interface PaginationData<T> {
|
|
143
|
+
data: T[];
|
|
144
|
+
total: number;
|
|
145
|
+
}
|
|
95
146
|
interface TableColumnOptions<T extends DefaultRow> extends TableColumnProps<T> {
|
|
96
147
|
render?: (row: T) => VNode | string;
|
|
97
148
|
children?: TableColumnOptions<T>[];
|
|
@@ -102,7 +153,7 @@ interface PaginationOptions extends Partial<PaginationProps> {
|
|
|
102
153
|
}
|
|
103
154
|
interface TableOptions<T extends DefaultRow> extends TableProps<T> {
|
|
104
155
|
columns: TableColumnOptions<T>[];
|
|
105
|
-
service?: RequestService
|
|
156
|
+
service?: RequestService<T[] | PaginationData<T>>;
|
|
106
157
|
params?: MaybeRef<unknown> | unknown;
|
|
107
158
|
formatData?: (res: unknown) => T[];
|
|
108
159
|
align?: 'left' | 'center' | 'right';
|
|
@@ -114,4 +165,4 @@ interface TableOptions<T extends DefaultRow> extends TableProps<T> {
|
|
|
114
165
|
type TableReturn = [Component];
|
|
115
166
|
declare function useTable<T extends DefaultRow>(options: TableOptions<T>): TableReturn;
|
|
116
167
|
//#endregion
|
|
117
|
-
export { AsyncConfirmOptions, CustomRender, DefaultComponentKey, FormItemType, FormOptions, FormReturnType, FormRuleFn, FormSchema, PaginationOptions, Recordable, TableColumnOptions, TableOptions, TableReturn, setDeepProperty, useAsyncConfirm, useDialog, useForm, useMessage, useTable };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,55 @@
|
|
|
1
1
|
import { useRequest } from "@vuetkit/core";
|
|
2
|
-
import { ElButton, ElCascader, ElCheckbox, ElCol, ElColorPicker, ElDatePicker, ElDialog, ElForm, ElFormItem, ElInput, ElInputNumber, ElInputOtp, ElMention, ElMessage, ElMessageBox, ElPagination, ElRadio, ElRate, ElRow, ElScrollbar, ElSelect, ElSelectV2, ElSlider, 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, ElTable, ElTableColumn, 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/useDescriptions/index.ts
|
|
6
|
+
function useDescriptions(options) {
|
|
7
|
+
const { columns = [], service, params, formatData, ...rest } = options;
|
|
8
|
+
const { data, loading } = service ? useRequest(service, {
|
|
9
|
+
defaultParams: params,
|
|
10
|
+
formatData: formatData || void 0
|
|
11
|
+
}) : {};
|
|
12
|
+
const descriptionsColumns = computed(() => (data === null || data === void 0 ? void 0 : data.value) || columns);
|
|
13
|
+
return [defineComponent((props, { slots }) => {
|
|
14
|
+
const renderColumns = () => {
|
|
15
|
+
var _descriptionsColumns$;
|
|
16
|
+
return (_descriptionsColumns$ = descriptionsColumns.value) === null || _descriptionsColumns$ === void 0 ? void 0 : _descriptionsColumns$.map((item) => {
|
|
17
|
+
return h(ElDescriptionsItem, { ...item }, {
|
|
18
|
+
default: () => {
|
|
19
|
+
if (item === null || item === void 0 ? void 0 : item.render) return item.render(item === null || item === void 0 ? void 0 : item.value);
|
|
20
|
+
return (item === null || item === void 0 ? void 0 : item.value) || "";
|
|
21
|
+
},
|
|
22
|
+
label: () => {
|
|
23
|
+
var _item$renderLabel;
|
|
24
|
+
return item === null || item === void 0 || (_item$renderLabel = item.renderLabel) === null || _item$renderLabel === void 0 ? void 0 : _item$renderLabel.call(item, item.label);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
return () => {
|
|
30
|
+
var _loading$value;
|
|
31
|
+
return withDirectives(h(ElDescriptions, {
|
|
32
|
+
...rest,
|
|
33
|
+
...props
|
|
34
|
+
}, {
|
|
35
|
+
default: () => {
|
|
36
|
+
if (slots.default) return slots.default();
|
|
37
|
+
if (!descriptionsColumns.value.length) return "";
|
|
38
|
+
return renderColumns();
|
|
39
|
+
},
|
|
40
|
+
title: () => {
|
|
41
|
+
var _slots$title;
|
|
42
|
+
return (_slots$title = slots.title) === null || _slots$title === void 0 ? void 0 : _slots$title.call(slots);
|
|
43
|
+
},
|
|
44
|
+
extra: () => {
|
|
45
|
+
var _slots$extra;
|
|
46
|
+
return (_slots$extra = slots.extra) === null || _slots$extra === void 0 ? void 0 : _slots$extra.call(slots);
|
|
47
|
+
}
|
|
48
|
+
}), [[vLoading, (_loading$value = loading === null || loading === void 0 ? void 0 : loading.value) !== null && _loading$value !== void 0 ? _loading$value : false]]);
|
|
49
|
+
};
|
|
50
|
+
})];
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
5
53
|
//#region src/feedback/useMessage/index.ts
|
|
6
54
|
const DEFAULT_DURATION = 3e3;
|
|
7
55
|
const DEFAULT_SHOW_CLOSE = true;
|
|
@@ -316,6 +364,54 @@ function useForm(options) {
|
|
|
316
364
|
}];
|
|
317
365
|
}
|
|
318
366
|
//#endregion
|
|
367
|
+
//#region src/navigation/useSteps/index.ts
|
|
368
|
+
function useSteps(options) {
|
|
369
|
+
const { steps = [], service, params, formatData, defaultActive = 0, ...rest } = options;
|
|
370
|
+
const { data, loading } = service ? useRequest(service, {
|
|
371
|
+
defaultParams: params,
|
|
372
|
+
formatData: formatData || void 0
|
|
373
|
+
}) : {};
|
|
374
|
+
const active = ref(defaultActive);
|
|
375
|
+
const stepsColumns = computed(() => (data === null || data === void 0 ? void 0 : data.value) || steps);
|
|
376
|
+
return [defineComponent({
|
|
377
|
+
props: { modelValue: {
|
|
378
|
+
type: Number,
|
|
379
|
+
default: void 0
|
|
380
|
+
} },
|
|
381
|
+
setup(props, { slots }) {
|
|
382
|
+
const renderSteps = () => {
|
|
383
|
+
var _stepsColumns$value;
|
|
384
|
+
return (_stepsColumns$value = stepsColumns.value) === null || _stepsColumns$value === void 0 ? void 0 : _stepsColumns$value.map((item) => {
|
|
385
|
+
return h(ElStep, { ...item }, {
|
|
386
|
+
description: () => {
|
|
387
|
+
if (item === null || item === void 0 ? void 0 : item.render) return item.render(item === null || item === void 0 ? void 0 : item.description);
|
|
388
|
+
return (item === null || item === void 0 ? void 0 : item.description) || "";
|
|
389
|
+
},
|
|
390
|
+
title: (item === null || item === void 0 ? void 0 : item.renderTitle) ? () => item.renderTitle(item.title) : void 0,
|
|
391
|
+
icon: (item === null || item === void 0 ? void 0 : item.renderIcon) ? () => item.renderIcon(item.icon) : void 0
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
};
|
|
395
|
+
return () => {
|
|
396
|
+
var _ref, _props$modelValue, _loading$value;
|
|
397
|
+
const finalActive = (_ref = (_props$modelValue = props.modelValue) !== null && _props$modelValue !== void 0 ? _props$modelValue : rest.active) !== null && _ref !== void 0 ? _ref : active.value;
|
|
398
|
+
return withDirectives(h(ElSteps, {
|
|
399
|
+
...rest,
|
|
400
|
+
...props,
|
|
401
|
+
"active": finalActive,
|
|
402
|
+
"onUpdate:active": (val) => {
|
|
403
|
+
active.value = val;
|
|
404
|
+
}
|
|
405
|
+
}, { default: () => {
|
|
406
|
+
if (slots.default) return slots.default();
|
|
407
|
+
if (!stepsColumns.value.length) return "";
|
|
408
|
+
return renderSteps();
|
|
409
|
+
} }), [[vLoading, (_loading$value = loading === null || loading === void 0 ? void 0 : loading.value) !== null && _loading$value !== void 0 ? _loading$value : false]]);
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
}), active];
|
|
413
|
+
}
|
|
414
|
+
//#endregion
|
|
319
415
|
//#region src/table/useTable/index.ts
|
|
320
416
|
function useTable(options) {
|
|
321
417
|
const { columns = [], service, params, formatData, align, headerAlign, paginationConfig, searchFormConfig, tableWrapStyle = {}, data = [], ...rest } = options;
|
|
@@ -464,4 +560,4 @@ function useTable(options) {
|
|
|
464
560
|
})];
|
|
465
561
|
}
|
|
466
562
|
//#endregion
|
|
467
|
-
export { setDeepProperty, useAsyncConfirm, useDialog, useForm, useMessage, useTable };
|
|
563
|
+
export { setDeepProperty, useAsyncConfirm, useDescriptions, useDialog, useForm, useMessage, useSteps, 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.14",
|
|
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.14",
|
|
25
|
+
"@vuetkit/shared": "0.0.14"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build": "tsdown --config-loader tsx"
|