@vuetkit/components 0.0.11 → 0.0.13

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 CHANGED
@@ -10,6 +10,7 @@ Collection of business development Composable Components for Vue3 + ElementPlus
10
10
 
11
11
  - [useMessage](/components/src/feedback/useMessage/)
12
12
  - [useAsyncConfirm](/components/src/feedback/useAsyncConfirm/)
13
+ - [useDialog](/components/src/feedback/useDialog/)
13
14
 
14
15
  ### Form
15
16
 
@@ -18,3 +19,7 @@ Collection of business development Composable Components for Vue3 + ElementPlus
18
19
  ### Table
19
20
 
20
21
  - [useTable](/components/src/table/useTable/)
22
+
23
+ ### Data
24
+
25
+ - [useDescriptions](/components/src/data/useDescriptions/)
package/dist/index.d.ts CHANGED
@@ -1,8 +1,23 @@
1
1
  import { RequestService } from "@vuetkit/core";
2
- import { ComponentSize, FormRules, MessageProps, MessageType, PaginationProps, TableProps } from "element-plus";
2
+ import { ComponentSize, DescriptionItemProps, DescriptionProps, DialogProps, FormRules, MessageProps, MessageType, PaginationProps, TableProps } from "element-plus";
3
3
  import { CSSProperties, Component, MaybeRef, 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,11 +30,21 @@ interface AsyncConfirmOptions {
15
30
  confirmSuccess?: () => void;
16
31
  confirmError?: (error: unknown) => void;
17
32
  }
18
- declare function useAsyncConfirm(confirmService: RequestService, options: AsyncConfirmOptions): {
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
  };
22
37
  //#endregion
38
+ //#region src/feedback/useDialog/index.d.ts
39
+ interface DialogOptions extends DialogProps {
40
+ title?: string;
41
+ }
42
+ type DialogReturn = [Component, {
43
+ open: () => void;
44
+ close: () => void;
45
+ }];
46
+ declare function useDialog(options: DialogOptions): DialogReturn;
47
+ //#endregion
23
48
  //#region src/feedback/useMessage/index.d.ts
24
49
  declare function useMessage(options?: MessageProps): {
25
50
  success: (message: string) => import("element-plus").MessageHandler;
@@ -82,6 +107,10 @@ declare function useForm<T extends object>(options: FormOptions<T>): FormReturnT
82
107
  //#endregion
83
108
  //#region src/table/useTable/index.d.ts
84
109
  type DefaultRow = Record<PropertyKey, any>;
110
+ interface PaginationData<T> {
111
+ data: T[];
112
+ total: number;
113
+ }
85
114
  interface TableColumnOptions<T extends DefaultRow> extends TableColumnProps<T> {
86
115
  render?: (row: T) => VNode | string;
87
116
  children?: TableColumnOptions<T>[];
@@ -92,7 +121,7 @@ interface PaginationOptions extends Partial<PaginationProps> {
92
121
  }
93
122
  interface TableOptions<T extends DefaultRow> extends TableProps<T> {
94
123
  columns: TableColumnOptions<T>[];
95
- service?: RequestService;
124
+ service?: RequestService<T[] | PaginationData<T>>;
96
125
  params?: MaybeRef<unknown> | unknown;
97
126
  formatData?: (res: unknown) => T[];
98
127
  align?: 'left' | 'center' | 'right';
@@ -104,4 +133,4 @@ interface TableOptions<T extends DefaultRow> extends TableProps<T> {
104
133
  type TableReturn = [Component];
105
134
  declare function useTable<T extends DefaultRow>(options: TableOptions<T>): TableReturn;
106
135
  //#endregion
107
- export { AsyncConfirmOptions, CustomRender, DefaultComponentKey, FormItemType, FormOptions, FormReturnType, FormRuleFn, FormSchema, PaginationOptions, Recordable, TableColumnOptions, TableOptions, TableReturn, setDeepProperty, useAsyncConfirm, useForm, useMessage, useTable };
136
+ export { AsyncConfirmOptions, CustomRender, DefaultComponentKey, DescriptionsColumn, DescriptionsOptions, DescriptionsReturnType, FormItemType, FormOptions, FormReturnType, FormRuleFn, FormSchema, PaginationOptions, Recordable, TableColumnOptions, TableOptions, TableReturn, setDeepProperty, useAsyncConfirm, useDescriptions, useDialog, useForm, useMessage, 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, ElForm, ElFormItem, ElInput, ElInputNumber, ElInputOtp, ElMention, ElMessage, ElMessageBox, ElPagination, ElRadio, ElRate, ElRow, ElSelect, ElSelectV2, ElSlider, ElSwitch, ElTable, ElTableColumn, ElTimePicker, ElTimeSelect, ElTransfer, ElTreeSelect, ElUpload, vLoading } from "element-plus";
3
- import { isFunc, realObj } from "@vuetkit/shared";
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, ElSwitch, ElTable, ElTableColumn, ElTimePicker, ElTimeSelect, ElTransfer, ElTreeSelect, ElUpload, vLoading } from "element-plus";
4
3
  import { computed, defineComponent, h, nextTick, onMounted, reactive, ref, toValue, useTemplateRef, watch, withDirectives } from "vue";
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;
@@ -80,6 +128,50 @@ function useAsyncConfirm(confirmService, options) {
80
128
  };
81
129
  }
82
130
  //#endregion
131
+ //#region src/feedback/useDialog/index.ts
132
+ function useDialog(options) {
133
+ const { title = "Dialog Title" } = options;
134
+ const showDialog = ref(false);
135
+ const DialogComp = defineComponent((props, { slots }) => {
136
+ return () => {
137
+ return h(ElDialog, {
138
+ title,
139
+ "modelValue": showDialog.value,
140
+ "update:modelValue": (val) => showDialog.value = val,
141
+ ...props,
142
+ "before-close": () => {
143
+ showDialog.value = false;
144
+ }
145
+ }, {
146
+ default: () => {
147
+ return h(ElScrollbar, { maxHeight: "60vh" }, () => {
148
+ var _slots$default;
149
+ return h("div", { style: { marginRight: "15px" } }, (_slots$default = slots.default) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots));
150
+ });
151
+ },
152
+ footer: () => {
153
+ var _slots$footer;
154
+ return (_slots$footer = slots.footer) === null || _slots$footer === void 0 ? void 0 : _slots$footer.call(slots);
155
+ },
156
+ header: () => {
157
+ var _slots$header;
158
+ return (_slots$header = slots.header) === null || _slots$header === void 0 ? void 0 : _slots$header.call(slots);
159
+ }
160
+ });
161
+ };
162
+ });
163
+ const open = () => {
164
+ showDialog.value = true;
165
+ };
166
+ const close = () => {
167
+ showDialog.value = false;
168
+ };
169
+ return [DialogComp, {
170
+ open,
171
+ close
172
+ }];
173
+ }
174
+ //#endregion
83
175
  //#region src/form/useForm/index.ts
84
176
  const defaultComponent = {
85
177
  "input": ElInput,
@@ -420,4 +512,4 @@ function useTable(options) {
420
512
  })];
421
513
  }
422
514
  //#endregion
423
- export { setDeepProperty, useAsyncConfirm, useForm, useMessage, useTable };
515
+ export { setDeepProperty, useAsyncConfirm, useDescriptions, useDialog, 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.11",
4
+ "version": "0.0.13",
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.11",
25
- "@vuetkit/shared": "0.0.11"
24
+ "@vuetkit/core": "0.0.13",
25
+ "@vuetkit/shared": "0.0.13"
26
26
  },
27
27
  "scripts": {
28
28
  "build": "tsdown --config-loader tsx"