@vuetkit/components 0.0.17 → 0.0.19

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RequestService } from "@vuetkit/core";
2
- import { CollapseItemProps, CollapseModelValue, CollapseProps, ComponentSize, DescriptionItemProps, DescriptionProps, DialogProps, ElDropdown, FormRules, MessageProps, MessageType, PaginationProps, StepProps, StepsProps, TabPaneName, TableProps, TabsPaneContext, TabsProps } from "element-plus";
2
+ import { CollapseItemProps, CollapseModelValue, CollapseProps, ComponentSize, DescriptionItemProps, DescriptionProps, DialogProps, ElDropdown, ElMenu, FormRules, MessageProps, MessageType, NotificationOptions, 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
 
@@ -73,6 +73,16 @@ declare function useMessage(options?: MessageProps): {
73
73
  closeAll: () => void;
74
74
  };
75
75
  //#endregion
76
+ //#region src/feedback/useNotification/index.d.ts
77
+ declare function useNotification(options?: NotificationOptions): {
78
+ primary: (message: string, title?: string) => import("element-plus").NotificationHandle;
79
+ success: (message: string, title?: string) => import("element-plus").NotificationHandle;
80
+ error: (message: string, title?: string) => import("element-plus").NotificationHandle;
81
+ warning: (message: string, title?: string) => import("element-plus").NotificationHandle;
82
+ info: (message: string, title?: string) => import("element-plus").NotificationHandle;
83
+ closeAll: () => void;
84
+ };
85
+ //#endregion
76
86
  //#region src/form/useForm/index.d.ts
77
87
  type CustomRender = (...args: unknown[]) => unknown;
78
88
  type Recordable = Record<string, unknown>;
@@ -147,6 +157,41 @@ interface DropdownOptions<T> extends Partial<ElDropdownProps> {
147
157
  type DropdownReturnType = [Component, Ref<string | number | object | undefined>];
148
158
  declare function useDropdown<T>(options: DropdownOptions<T>): DropdownReturnType;
149
159
  //#endregion
160
+ //#region src/navigation/useMenu/index.d.ts
161
+ type ElMenuProps = InstanceType<typeof ElMenu>['$props'];
162
+ interface MenuColumn {
163
+ index: string;
164
+ label?: string;
165
+ disabled?: boolean;
166
+ route?: unknown;
167
+ children?: MenuColumn[];
168
+ render?: (val: unknown) => VNode;
169
+ renderTitle?: (val: unknown) => VNode;
170
+ groupTitle?: string;
171
+ popperClass?: string;
172
+ popperStyle?: string | CSSProperties;
173
+ showTimeout?: number;
174
+ hideTimeout?: number;
175
+ teleported?: boolean;
176
+ popperOffset?: number;
177
+ expandCloseIcon?: string | Component;
178
+ expandOpenIcon?: string | Component;
179
+ collapseCloseIcon?: string | Component;
180
+ collapseOpenIcon?: string | Component;
181
+ }
182
+ interface MenuOptions<T> extends Partial<ElMenuProps> {
183
+ items?: MenuColumn[];
184
+ service?: RequestService<T>;
185
+ params?: unknown;
186
+ formatData?: (data: T) => MenuColumn[];
187
+ defaultActive?: string;
188
+ onSelect?: (index: string, indexPath: string[], item: unknown, routerResult?: Promise<unknown>) => void;
189
+ onOpen?: (index: string, indexPath: string[]) => void;
190
+ onClose?: (index: string, indexPath: string[]) => void;
191
+ }
192
+ type MenuReturnType = [Component, Ref<string>];
193
+ declare function useMenu<T>(options: MenuOptions<T>): MenuReturnType;
194
+ //#endregion
150
195
  //#region src/navigation/useSteps/index.d.ts
151
196
  interface StepsColumn extends Partial<StepProps> {
152
197
  title?: string;
@@ -246,4 +291,4 @@ interface TableOptions<T extends DefaultRow> extends TableProps<T> {
246
291
  type TableReturn = [Component];
247
292
  declare function useTable<T extends DefaultRow>(options: TableOptions<T>): TableReturn;
248
293
  //#endregion
249
- export { AsyncConfirmOptions, CollapseColumn, CollapseOptions, CollapseReturnType, CustomRender, DefaultComponentKey, DescriptionsColumn, DescriptionsOptions, DescriptionsReturnType, DropdownItem, DropdownOptions, DropdownReturnType, FormItemType, FormOptions, FormReturnType, FormRuleFn, FormSchema, PaginationOptions, Recordable, StepsColumn, StepsOptions, StepsReturnType, TableColumnOptions, TableOptions, TableReturn, TabsColumn, TabsOptions, TabsReturnType, setDeepProperty, useAsyncConfirm, useCollapse, useDescriptions, useDialog, useDropdown, useForm, useMessage, useSteps, useTable, useTabs };
294
+ export { AsyncConfirmOptions, 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, useCollapse, useDescriptions, useDialog, useDropdown, useForm, useMenu, useMessage, useNotification, 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, ElCollapse, ElCollapseItem, ElColorPicker, ElDatePicker, ElDescriptions, ElDescriptionsItem, ElDialog, ElDropdown, ElDropdownItem, ElDropdownMenu, 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";
2
+ import { 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";
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
@@ -112,16 +112,16 @@ function useDescriptions(options) {
112
112
  }
113
113
  //#endregion
114
114
  //#region src/feedback/useMessage/index.ts
115
- const DEFAULT_DURATION = 3e3;
116
- const DEFAULT_SHOW_CLOSE = true;
115
+ const DEFAULT_DURATION$1 = 3e3;
116
+ const DEFAULT_SHOW_CLOSE$1 = true;
117
117
  const DEFAULT_PLAIN = true;
118
118
  const DEFAULT_GROUPING = true;
119
119
  function useMessage(options = {}) {
120
120
  var _options$duration, _options$showClose, _options$plain, _options$grouping;
121
121
  const mergedOptions = {
122
122
  ...options,
123
- duration: (_options$duration = options.duration) !== null && _options$duration !== void 0 ? _options$duration : DEFAULT_DURATION,
124
- showClose: (_options$showClose = options.showClose) !== null && _options$showClose !== void 0 ? _options$showClose : DEFAULT_SHOW_CLOSE,
123
+ duration: (_options$duration = options.duration) !== null && _options$duration !== void 0 ? _options$duration : DEFAULT_DURATION$1,
124
+ showClose: (_options$showClose = options.showClose) !== null && _options$showClose !== void 0 ? _options$showClose : DEFAULT_SHOW_CLOSE$1,
125
125
  plain: (_options$plain = options.plain) !== null && _options$plain !== void 0 ? _options$plain : DEFAULT_PLAIN,
126
126
  grouping: (_options$grouping = options.grouping) !== null && _options$grouping !== void 0 ? _options$grouping : DEFAULT_GROUPING
127
127
  };
@@ -233,6 +233,54 @@ function useDialog(options) {
233
233
  }];
234
234
  }
235
235
  //#endregion
236
+ //#region src/feedback/useNotification/index.ts
237
+ const DEFAULT_DURATION = 4500;
238
+ const DEFAULT_SHOW_CLOSE = true;
239
+ const DEFAULT_POSITION = "top-right";
240
+ function useNotification(options = {}) {
241
+ var _options$duration, _options$showClose, _options$position;
242
+ const mergedOptions = {
243
+ ...options,
244
+ duration: (_options$duration = options.duration) !== null && _options$duration !== void 0 ? _options$duration : DEFAULT_DURATION,
245
+ showClose: (_options$showClose = options.showClose) !== null && _options$showClose !== void 0 ? _options$showClose : DEFAULT_SHOW_CLOSE,
246
+ position: (_options$position = options.position) !== null && _options$position !== void 0 ? _options$position : DEFAULT_POSITION
247
+ };
248
+ function createNotification(message, type, title) {
249
+ return ElNotification({
250
+ ...mergedOptions,
251
+ message,
252
+ type,
253
+ title: title !== null && title !== void 0 ? title : mergedOptions.title
254
+ });
255
+ }
256
+ function closeAll() {
257
+ ElNotification.closeAll();
258
+ }
259
+ function primary(message, title) {
260
+ return createNotification(message, "primary", title);
261
+ }
262
+ function success(message, title) {
263
+ return createNotification(message, "success", title);
264
+ }
265
+ function error(message, title) {
266
+ return createNotification(message, "error", title);
267
+ }
268
+ function warning(message, title) {
269
+ return createNotification(message, "warning", title);
270
+ }
271
+ function info(message, title) {
272
+ return createNotification(message, "info", title);
273
+ }
274
+ return {
275
+ primary,
276
+ success,
277
+ error,
278
+ warning,
279
+ info,
280
+ closeAll
281
+ };
282
+ }
283
+ //#endregion
236
284
  //#region src/form/useForm/index.ts
237
285
  const defaultComponent = {
238
286
  "input": ElInput,
@@ -486,6 +534,78 @@ function useDropdown(options) {
486
534
  } }), command];
487
535
  }
488
536
  //#endregion
537
+ //#region src/navigation/useMenu/index.ts
538
+ function useMenu(options) {
539
+ const { items = [], service, params, formatData, defaultActive = "", onSelect, onOpen, onClose, ...rest } = options;
540
+ const { data, loading } = service ? useRequest(service, {
541
+ defaultParams: params,
542
+ formatData: formatData || void 0
543
+ }) : {};
544
+ const activeIndex = ref(defaultActive);
545
+ const menuColumns = computed(() => (data === null || data === void 0 ? void 0 : data.value) || items);
546
+ const renderMenuItem = (item) => {
547
+ var _item$children, _item$children2;
548
+ if (((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) && item.groupTitle) return h(ElMenuItemGroup, { title: item.groupTitle }, { default: () => item.children.map((child) => renderMenuItem(child)) });
549
+ if ((_item$children2 = item.children) === null || _item$children2 === void 0 ? void 0 : _item$children2.length) return h(ElSubMenu, {
550
+ index: item.index,
551
+ disabled: item.disabled,
552
+ popperClass: item.popperClass,
553
+ popperStyle: item.popperStyle,
554
+ showTimeout: item.showTimeout,
555
+ hideTimeout: item.hideTimeout,
556
+ teleported: item.teleported,
557
+ popperOffset: item.popperOffset,
558
+ expandCloseIcon: item.expandCloseIcon,
559
+ expandOpenIcon: item.expandOpenIcon,
560
+ collapseCloseIcon: item.collapseCloseIcon,
561
+ collapseOpenIcon: item.collapseOpenIcon
562
+ }, {
563
+ title: () => {
564
+ if (item === null || item === void 0 ? void 0 : item.renderTitle) return item.renderTitle(item);
565
+ return item.label || "";
566
+ },
567
+ default: () => item.children.map((child) => renderMenuItem(child))
568
+ });
569
+ return h(ElMenuItem, {
570
+ index: item.index,
571
+ disabled: item.disabled,
572
+ route: item.route
573
+ }, { default: () => {
574
+ if (item === null || item === void 0 ? void 0 : item.render) return item.render(item);
575
+ return item.label || "";
576
+ } });
577
+ };
578
+ return [defineComponent({ setup(_, { slots, emit }) {
579
+ const handleSelect = (index, indexPath, item, routerResult) => {
580
+ activeIndex.value = index;
581
+ onSelect === null || onSelect === void 0 || onSelect(index, indexPath, item, routerResult);
582
+ emit("select", index, indexPath, item, routerResult);
583
+ };
584
+ const handleOpen = (index, indexPath) => {
585
+ onOpen === null || onOpen === void 0 || onOpen(index, indexPath);
586
+ emit("open", index, indexPath);
587
+ };
588
+ const handleClose = (index, indexPath) => {
589
+ onClose === null || onClose === void 0 || onClose(index, indexPath);
590
+ emit("close", index, indexPath);
591
+ };
592
+ return () => {
593
+ var _loading$value;
594
+ return withDirectives(h(ElMenu, {
595
+ ...rest,
596
+ defaultActive: activeIndex.value,
597
+ onSelect: handleSelect,
598
+ onOpen: handleOpen,
599
+ onClose: handleClose
600
+ }, { default: () => {
601
+ if (slots.default) return slots.default();
602
+ if (!menuColumns.value.length) return "";
603
+ return menuColumns.value.map((item) => renderMenuItem(item));
604
+ } }), [[vLoading, (_loading$value = loading === null || loading === void 0 ? void 0 : loading.value) !== null && _loading$value !== void 0 ? _loading$value : false]]);
605
+ };
606
+ } }), activeIndex];
607
+ }
608
+ //#endregion
489
609
  //#region src/navigation/useSteps/index.ts
490
610
  function useSteps(options) {
491
611
  const { steps = [], service, params, formatData, defaultActive = 0, ...rest } = options;
@@ -759,4 +879,4 @@ function useTable(options) {
759
879
  })];
760
880
  }
761
881
  //#endregion
762
- export { setDeepProperty, useAsyncConfirm, useCollapse, useDescriptions, useDialog, useDropdown, useForm, useMessage, useSteps, useTable, useTabs };
882
+ export { setDeepProperty, useAsyncConfirm, useCollapse, useDescriptions, useDialog, useDropdown, useForm, useMenu, useMessage, useNotification, 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.17",
4
+ "version": "0.0.19",
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.17",
25
- "@vuetkit/shared": "0.0.17"
24
+ "@vuetkit/core": "0.0.19",
25
+ "@vuetkit/shared": "0.0.19"
26
26
  },
27
27
  "scripts": {
28
28
  "build": "tsdown --config-loader tsx"