@vuetkit/components 0.0.20 → 0.0.22
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 +39 -4
- package/dist/index.js +93 -2
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RequestService } from "@vuetkit/core";
|
|
2
|
-
import { CollapseItemProps, CollapseModelValue, CollapseProps, ComponentSize, DescriptionItemProps, DescriptionProps, DialogProps, ElBreadcrumb, ElDropdown, ElMenu, FormRules, MessageProps, MessageType, NotificationOptions, PaginationProps, StepProps, StepsProps, TabPaneName, TableProps, TabsPaneContext, TabsProps } from "element-plus";
|
|
2
|
+
import { CollapseItemProps, CollapseModelValue, CollapseProps, ComponentSize, DescriptionItemProps, DescriptionProps, DialogProps, ElBreadcrumb, ElDropdown, ElMenu, FormRules, MessageProps, MessageType, NotificationOptions, PaginationProps, SegmentedProps, StepProps, StepsProps, TabPaneName, TableProps, TabsPaneContext, TabsProps, TreeV2Instance } from "element-plus";
|
|
3
3
|
import { CSSProperties, Component, MaybeRef, Ref, VNode } from "vue";
|
|
4
|
+
import { TreeNode, TreeNodeData, TreeProps } from "element-plus/es/components/tree-v2/src/types";
|
|
4
5
|
import { TableColumnProps } from "element-plus/es/components/table/src/table-column/defaults.mjs";
|
|
5
6
|
|
|
6
7
|
//#region src/data/useCollapse/index.d.ts
|
|
@@ -37,6 +38,40 @@ interface DescriptionsOptions<T> extends DescriptionProps {
|
|
|
37
38
|
type DescriptionsReturnType = [Component];
|
|
38
39
|
declare function useDescriptions<T>(options: DescriptionsOptions<T>): import("vue").DefineSetupFnComponent<Record<string, any>, {}, {}, Record<string, any> & {}, import("vue").PublicProps>[];
|
|
39
40
|
//#endregion
|
|
41
|
+
//#region src/data/useSegmented/index.d.ts
|
|
42
|
+
type SegmentedOptionValue = string | number | boolean;
|
|
43
|
+
interface SegmentedColumn {
|
|
44
|
+
value?: SegmentedOptionValue;
|
|
45
|
+
label?: string;
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
render?: (item: SegmentedColumn) => VNode;
|
|
48
|
+
}
|
|
49
|
+
interface SegmentedOptions<T> extends Partial<SegmentedProps> {
|
|
50
|
+
columns?: SegmentedColumn[];
|
|
51
|
+
service?: RequestService<T>;
|
|
52
|
+
params?: unknown;
|
|
53
|
+
formatData?: (data: T) => SegmentedColumn[];
|
|
54
|
+
defaultValue?: SegmentedOptionValue;
|
|
55
|
+
onChange?: (val: SegmentedOptionValue) => void;
|
|
56
|
+
}
|
|
57
|
+
type SegmentedReturnType = [Component, Ref<SegmentedOptionValue | undefined>];
|
|
58
|
+
declare function useSegmented<T>(options: SegmentedOptions<T>): SegmentedReturnType;
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/data/useTreeV2/index.d.ts
|
|
61
|
+
interface TreeV2Column extends TreeNodeData {
|
|
62
|
+
children?: TreeV2Column[];
|
|
63
|
+
render?: (node: TreeNode, data: TreeNodeData) => VNode;
|
|
64
|
+
}
|
|
65
|
+
interface TreeV2Options<T> extends Omit<TreeProps, 'data'> {
|
|
66
|
+
data?: TreeV2Column[];
|
|
67
|
+
service?: RequestService<T>;
|
|
68
|
+
params?: unknown;
|
|
69
|
+
formatData?: (data: T) => TreeV2Column[];
|
|
70
|
+
render?: (node: TreeNode, data: TreeNodeData) => VNode;
|
|
71
|
+
}
|
|
72
|
+
type TreeV2ReturnType = [Component, Ref<TreeV2Instance | undefined>];
|
|
73
|
+
declare function useTreeV2<T>(options: TreeV2Options<T>): TreeV2ReturnType;
|
|
74
|
+
//#endregion
|
|
40
75
|
//#region src/feedback/useAsyncConfirm/index.d.ts
|
|
41
76
|
interface AsyncConfirmOptions {
|
|
42
77
|
title?: string;
|
|
@@ -266,14 +301,14 @@ interface TabsOptions<T> extends Partial<TabsProps> {
|
|
|
266
301
|
type TabsReturnType = [Component, Ref<string | number>];
|
|
267
302
|
declare function useTabs<T>(options: TabsOptions<T>): (Ref<string | number, string | number> | import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
268
303
|
modelValue: {
|
|
269
|
-
type: (
|
|
304
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
270
305
|
default: undefined;
|
|
271
306
|
};
|
|
272
307
|
}>, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
273
308
|
[key: string]: any;
|
|
274
309
|
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
275
310
|
modelValue: {
|
|
276
|
-
type: (
|
|
311
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
277
312
|
default: undefined;
|
|
278
313
|
};
|
|
279
314
|
}>> & Readonly<{}>, {
|
|
@@ -308,4 +343,4 @@ interface TableOptions<T extends DefaultRow> extends TableProps<T> {
|
|
|
308
343
|
type TableReturn = [Component];
|
|
309
344
|
declare function useTable<T extends DefaultRow>(options: TableOptions<T>): TableReturn;
|
|
310
345
|
//#endregion
|
|
311
|
-
export { AsyncConfirmOptions, BreadcrumbColumn, BreadcrumbOptions, BreadcrumbReturnType, CollapseColumn, CollapseOptions, CollapseReturnType, CustomRender, DefaultComponentKey, DescriptionsColumn, DescriptionsOptions, DescriptionsReturnType, DropdownItem, DropdownOptions, DropdownReturnType, FormItemType, FormOptions, FormReturnType, FormRuleFn, FormSchema, MenuColumn, MenuOptions, MenuReturnType, PaginationOptions, Recordable, StepsColumn, StepsOptions, StepsReturnType, TableColumnOptions, TableOptions, TableReturn, TabsColumn, TabsOptions, TabsReturnType, setDeepProperty, useAsyncConfirm, useBreadcrumb, useCollapse, useDescriptions, useDialog, useDropdown, useForm, useMenu, useMessage, useNotification, useSteps, useTable, useTabs };
|
|
346
|
+
export { AsyncConfirmOptions, BreadcrumbColumn, BreadcrumbOptions, BreadcrumbReturnType, CollapseColumn, CollapseOptions, CollapseReturnType, CustomRender, DefaultComponentKey, DescriptionsColumn, DescriptionsOptions, DescriptionsReturnType, DropdownItem, DropdownOptions, DropdownReturnType, FormItemType, FormOptions, FormReturnType, FormRuleFn, FormSchema, MenuColumn, MenuOptions, MenuReturnType, PaginationOptions, Recordable, SegmentedColumn, SegmentedOptionValue, SegmentedOptions, SegmentedReturnType, StepsColumn, StepsOptions, StepsReturnType, TableColumnOptions, TableOptions, TableReturn, TabsColumn, TabsOptions, TabsReturnType, TreeV2Column, TreeV2Options, TreeV2ReturnType, setDeepProperty, useAsyncConfirm, useBreadcrumb, useCollapse, useDescriptions, useDialog, useDropdown, useForm, useMenu, useMessage, useNotification, useSegmented, useSteps, useTable, useTabs, useTreeV2 };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useRequest } from "@vuetkit/core";
|
|
2
|
-
import { ElBreadcrumb, ElBreadcrumbItem, ElButton, ElCascader, ElCheckbox, ElCol, ElCollapse, ElCollapseItem, ElColorPicker, ElDatePicker, ElDescriptions, ElDescriptionsItem, ElDialog, ElDropdown, ElDropdownItem, ElDropdownMenu, ElForm, ElFormItem, ElInput, ElInputNumber, ElInputOtp, ElMention, ElMenu, ElMenuItem, ElMenuItemGroup, ElMessage, ElMessageBox, ElNotification, ElPagination, ElRadio, ElRate, ElRow, ElScrollbar, ElSelect, ElSelectV2, ElSlider, ElStep, ElSteps, ElSubMenu, ElSwitch, ElTabPane, ElTable, ElTableColumn, ElTabs, ElTimePicker, ElTimeSelect, ElTransfer, ElTreeSelect, ElUpload, vLoading } from "element-plus";
|
|
2
|
+
import { ElBreadcrumb, ElBreadcrumbItem, ElButton, ElCascader, ElCheckbox, ElCol, ElCollapse, ElCollapseItem, ElColorPicker, ElDatePicker, ElDescriptions, ElDescriptionsItem, ElDialog, ElDropdown, ElDropdownItem, ElDropdownMenu, ElForm, ElFormItem, ElInput, ElInputNumber, ElInputOtp, ElMention, ElMenu, ElMenuItem, ElMenuItemGroup, ElMessage, ElMessageBox, ElNotification, ElPagination, ElRadio, ElRate, ElRow, ElScrollbar, ElSegmented, ElSelect, ElSelectV2, ElSlider, ElStep, ElSteps, ElSubMenu, ElSwitch, ElTabPane, ElTable, ElTableColumn, ElTabs, ElTimePicker, ElTimeSelect, ElTransfer, ElTreeSelect, ElTreeV2, 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/useCollapse/index.ts
|
|
@@ -111,6 +111,97 @@ function useDescriptions(options) {
|
|
|
111
111
|
})];
|
|
112
112
|
}
|
|
113
113
|
//#endregion
|
|
114
|
+
//#region src/data/useSegmented/index.ts
|
|
115
|
+
function useSegmented(options) {
|
|
116
|
+
const { columns = [], service, params, formatData, defaultValue, onChange, ...rest } = options;
|
|
117
|
+
const { data, loading } = service ? useRequest(service, {
|
|
118
|
+
defaultParams: params,
|
|
119
|
+
formatData: formatData || void 0
|
|
120
|
+
}) : {};
|
|
121
|
+
const modelValue = ref(defaultValue);
|
|
122
|
+
const segmentedColumns = computed(() => (data === null || data === void 0 ? void 0 : data.value) || columns);
|
|
123
|
+
return [defineComponent({
|
|
124
|
+
props: { modelValue: {
|
|
125
|
+
type: [
|
|
126
|
+
String,
|
|
127
|
+
Number,
|
|
128
|
+
Boolean
|
|
129
|
+
],
|
|
130
|
+
default: void 0
|
|
131
|
+
} },
|
|
132
|
+
setup(props, { slots, emit }) {
|
|
133
|
+
const hasCustomRender = computed(() => segmentedColumns.value.some((col) => col && typeof col === "object" && typeof col.render === "function"));
|
|
134
|
+
const renderDefault = (scope) => {
|
|
135
|
+
var _slots$default;
|
|
136
|
+
const item = scope === null || scope === void 0 ? void 0 : scope.item;
|
|
137
|
+
if (item && typeof item === "object" && typeof item.render === "function") return item.render(item);
|
|
138
|
+
return (_slots$default = slots.default) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots, scope);
|
|
139
|
+
};
|
|
140
|
+
const handleChange = (val) => {
|
|
141
|
+
modelValue.value = val;
|
|
142
|
+
onChange === null || onChange === void 0 || onChange(val);
|
|
143
|
+
emit("change", val);
|
|
144
|
+
emit("update:modelValue", val);
|
|
145
|
+
};
|
|
146
|
+
return () => {
|
|
147
|
+
var _ref, _props$modelValue, _loading$value;
|
|
148
|
+
const finalModelValue = (_ref = (_props$modelValue = props.modelValue) !== null && _props$modelValue !== void 0 ? _props$modelValue : rest.modelValue) !== null && _ref !== void 0 ? _ref : modelValue.value;
|
|
149
|
+
const slotsObj = {};
|
|
150
|
+
if (hasCustomRender.value || slots.default) slotsObj.default = renderDefault;
|
|
151
|
+
return withDirectives(h(ElSegmented, {
|
|
152
|
+
...rest,
|
|
153
|
+
...props,
|
|
154
|
+
"options": segmentedColumns.value,
|
|
155
|
+
"modelValue": finalModelValue,
|
|
156
|
+
"onUpdate:modelValue": handleChange,
|
|
157
|
+
"onChange": handleChange
|
|
158
|
+
}, slotsObj), [[vLoading, (_loading$value = loading === null || loading === void 0 ? void 0 : loading.value) !== null && _loading$value !== void 0 ? _loading$value : false]]);
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}), modelValue];
|
|
162
|
+
}
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/data/useTreeV2/index.ts
|
|
165
|
+
function useTreeV2(options) {
|
|
166
|
+
const { data = [], service, params, formatData, render, ...rest } = options;
|
|
167
|
+
const { data: resData, loading } = service ? useRequest(service, {
|
|
168
|
+
defaultParams: params,
|
|
169
|
+
formatData: formatData || void 0
|
|
170
|
+
}) : {};
|
|
171
|
+
const treeData = computed(() => (resData === null || resData === void 0 ? void 0 : resData.value) || data);
|
|
172
|
+
const treeRef = ref();
|
|
173
|
+
return [defineComponent((props, { slots }) => {
|
|
174
|
+
const renderNodeContent = (node, nodeData) => {
|
|
175
|
+
const columnRender = nodeData.render;
|
|
176
|
+
if (typeof columnRender === "function") return columnRender(node, nodeData);
|
|
177
|
+
if (typeof render === "function") return render(node, nodeData);
|
|
178
|
+
};
|
|
179
|
+
return () => {
|
|
180
|
+
var _loading$value;
|
|
181
|
+
return withDirectives(h(ElTreeV2, {
|
|
182
|
+
...rest,
|
|
183
|
+
...props,
|
|
184
|
+
ref: treeRef,
|
|
185
|
+
data: treeData.value
|
|
186
|
+
}, {
|
|
187
|
+
default: ({ node, data: nodeData }) => {
|
|
188
|
+
if (slots.default) return slots.default({
|
|
189
|
+
node,
|
|
190
|
+
data: nodeData
|
|
191
|
+
});
|
|
192
|
+
const content = renderNodeContent(node, nodeData);
|
|
193
|
+
if (content) return content;
|
|
194
|
+
return h("span", {}, node.label);
|
|
195
|
+
},
|
|
196
|
+
empty: () => {
|
|
197
|
+
var _slots$empty;
|
|
198
|
+
return (_slots$empty = slots.empty) === null || _slots$empty === void 0 ? void 0 : _slots$empty.call(slots);
|
|
199
|
+
}
|
|
200
|
+
}), [[vLoading, (_loading$value = loading === null || loading === void 0 ? void 0 : loading.value) !== null && _loading$value !== void 0 ? _loading$value : false]]);
|
|
201
|
+
};
|
|
202
|
+
}), treeRef];
|
|
203
|
+
}
|
|
204
|
+
//#endregion
|
|
114
205
|
//#region src/feedback/useMessage/index.ts
|
|
115
206
|
const DEFAULT_DURATION$1 = 3e3;
|
|
116
207
|
const DEFAULT_SHOW_CLOSE$1 = true;
|
|
@@ -908,4 +999,4 @@ function useTable(options) {
|
|
|
908
999
|
})];
|
|
909
1000
|
}
|
|
910
1001
|
//#endregion
|
|
911
|
-
export { setDeepProperty, useAsyncConfirm, useBreadcrumb, useCollapse, useDescriptions, useDialog, useDropdown, useForm, useMenu, useMessage, useNotification, useSteps, useTable, useTabs };
|
|
1002
|
+
export { setDeepProperty, useAsyncConfirm, useBreadcrumb, useCollapse, useDescriptions, useDialog, useDropdown, useForm, useMenu, useMessage, useNotification, useSegmented, useSteps, useTable, useTabs, useTreeV2 };
|
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.22",
|
|
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/
|
|
25
|
-
"@vuetkit/
|
|
24
|
+
"@vuetkit/shared": "0.0.22",
|
|
25
|
+
"@vuetkit/core": "0.0.22"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build": "tsdown --config-loader tsx"
|