@kine-design/core 0.0.1-beta.1 → 0.0.1-beta.2
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/assets/style/global.css +1 -0
- package/assets/style/var/Wuxing.css +71 -0
- package/assets/style/var.css +23 -0
- package/components/base/affix/api.ts +16 -0
- package/components/base/affix/index.ts +15 -0
- package/components/base/affix/props.d.ts +34 -0
- package/components/base/affix/useAffix.ts +123 -0
- package/components/base/alert/api.ts +18 -0
- package/components/base/alert/index.ts +15 -0
- package/components/base/alert/props.d.ts +50 -0
- package/components/base/anchor/api.ts +20 -0
- package/components/base/anchor/index.ts +16 -0
- package/components/base/anchor/props.d.ts +46 -0
- package/components/base/anchor/useAnchor.ts +83 -0
- package/components/base/autoComplete/api.ts +24 -0
- package/components/base/autoComplete/index.ts +17 -0
- package/components/base/autoComplete/props.d.ts +75 -0
- package/components/base/autoComplete/useAutoComplete.ts +149 -0
- package/components/base/avatar/api.ts +17 -0
- package/components/base/avatar/avatar.css +61 -0
- package/components/base/avatar/index.ts +14 -0
- package/components/base/avatar/props.d.ts +37 -0
- package/components/base/backTop/api.ts +17 -0
- package/components/base/backTop/index.ts +15 -0
- package/components/base/backTop/props.d.ts +38 -0
- package/components/base/backTop/useBackTop.ts +62 -0
- package/components/base/badge/api.ts +22 -0
- package/components/base/badge/index.ts +15 -0
- package/components/base/badge/props.d.ts +50 -0
- package/components/base/button/api.ts +28 -0
- package/components/base/button/button.css +34 -0
- package/components/base/button/index.ts +16 -0
- package/components/base/button/props.d.ts +64 -0
- package/components/base/button/useButton.ts +37 -0
- package/components/base/card/api.ts +17 -0
- package/components/base/card/index.ts +15 -0
- package/components/base/card/props.d.ts +37 -0
- package/components/base/carousel/api.ts +28 -0
- package/components/base/carousel/index.ts +17 -0
- package/components/base/carousel/props.d.ts +72 -0
- package/components/base/carousel/useCarousel.ts +151 -0
- package/components/base/cascader/api.ts +23 -0
- package/components/base/cascader/index.ts +18 -0
- package/components/base/cascader/props.d.ts +103 -0
- package/components/base/cascader/useCascader.ts +334 -0
- package/components/base/checkbox/api.ts +24 -0
- package/components/base/checkbox/checkbox.css +0 -0
- package/components/base/checkbox/index.ts +16 -0
- package/components/base/checkbox/props.d.ts +77 -0
- package/components/base/checkbox/useCheckbox.ts +42 -0
- package/components/base/collapse/api.ts +21 -0
- package/components/base/collapse/index.ts +16 -0
- package/components/base/collapse/props.d.ts +45 -0
- package/components/base/collapse/useCollapse.ts +80 -0
- package/components/base/datePicker/api.ts +18 -0
- package/components/base/datePicker/index.ts +19 -0
- package/components/base/datePicker/props.d.ts +60 -0
- package/components/base/datePicker/useDatePicker.ts +392 -0
- package/components/base/divider/api.ts +15 -0
- package/components/base/divider/divider.css +11 -0
- package/components/base/divider/index.ts +15 -0
- package/components/base/divider/props.d.ts +30 -0
- package/components/base/dropdown/api.ts +33 -0
- package/components/base/dropdown/index.ts +16 -0
- package/components/base/dropdown/props.d.ts +60 -0
- package/components/base/dropdown/useDropdown.ts +123 -0
- package/components/base/empty/api.ts +15 -0
- package/components/base/empty/index.ts +15 -0
- package/components/base/empty/props.d.ts +26 -0
- package/components/base/image/api.ts +25 -0
- package/components/base/image/index.ts +18 -0
- package/components/base/image/props.d.ts +67 -0
- package/components/base/image/useImage.ts +119 -0
- package/components/base/input/api.ts +19 -0
- package/components/base/input/index.ts +16 -0
- package/components/base/input/input.css +19 -0
- package/components/base/input/props.d.ts +60 -0
- package/components/base/input/useInput.ts +53 -0
- package/components/base/inputNumber/api.ts +21 -0
- package/components/base/inputNumber/index.ts +15 -0
- package/components/base/inputNumber/props.d.ts +64 -0
- package/components/base/inputNumber/useInputNumber.ts +140 -0
- package/components/base/li/api.ts +15 -0
- package/components/base/li/index.ts +13 -0
- package/components/base/li/props.d.ts +30 -0
- package/components/base/list/api.ts +16 -0
- package/components/base/list/index.ts +15 -0
- package/components/base/list/props.d.ts +33 -0
- package/components/base/list/useList.ts +36 -0
- package/components/base/loading/api.ts +17 -0
- package/components/base/loading/index.ts +15 -0
- package/components/base/loading/props.d.ts +38 -0
- package/components/base/popover/api.ts +28 -0
- package/components/base/popover/index.ts +15 -0
- package/components/base/popover/props.d.ts +73 -0
- package/components/base/popover/usePopover.ts +188 -0
- package/components/base/progress/api.ts +18 -0
- package/components/base/progress/index.ts +15 -0
- package/components/base/progress/props.d.ts +53 -0
- package/components/base/progress/useProgress.ts +28 -0
- package/components/base/radio/api.ts +19 -0
- package/components/base/radio/index.ts +19 -0
- package/components/base/radio/props.d.ts +59 -0
- package/components/base/radio/useRadio.ts +11 -0
- package/components/base/rate/api.ts +18 -0
- package/components/base/rate/index.ts +15 -0
- package/components/base/rate/props.d.ts +49 -0
- package/components/base/rate/useRate.ts +75 -0
- package/components/base/result/api.ts +20 -0
- package/components/base/result/index.ts +15 -0
- package/components/base/result/props.d.ts +36 -0
- package/components/base/select/api.ts +31 -0
- package/components/base/select/index.ts +18 -0
- package/components/base/select/props.d.ts +132 -0
- package/components/base/select/select.css +7 -0
- package/components/base/select/useSelect.ts +280 -0
- package/components/base/select/useSelectTools.ts +60 -0
- package/components/base/skeleton/api.ts +18 -0
- package/components/base/skeleton/index.ts +15 -0
- package/components/base/skeleton/props.d.ts +41 -0
- package/components/base/slider/api.ts +20 -0
- package/components/base/slider/index.ts +15 -0
- package/components/base/slider/props.d.ts +65 -0
- package/components/base/slider/useSlider.ts +83 -0
- package/components/base/space/api.ts +17 -0
- package/components/base/space/index.ts +15 -0
- package/components/base/space/props.d.ts +39 -0
- package/components/base/steps/api.ts +30 -0
- package/components/base/steps/index.ts +22 -0
- package/components/base/steps/props.d.ts +88 -0
- package/components/base/steps/useSteps.ts +101 -0
- package/components/base/switch/api.ts +22 -0
- package/components/base/switch/index.ts +17 -0
- package/components/base/switch/props.d.ts +66 -0
- package/components/base/switch/useSwitch.tsx +79 -0
- package/components/base/tabs/api.ts +23 -0
- package/components/base/tabs/index.ts +18 -0
- package/components/base/tabs/props.d.ts +41 -0
- package/components/base/tabs/useTabs.ts +66 -0
- package/components/base/tag/api.ts +17 -0
- package/components/base/tag/index.ts +13 -0
- package/components/base/tag/props.d.ts +49 -0
- package/components/base/timePicker/api.ts +21 -0
- package/components/base/timePicker/index.ts +18 -0
- package/components/base/timePicker/props.d.ts +66 -0
- package/components/base/timePicker/useTimePicker.ts +161 -0
- package/components/base/timeline/api.ts +24 -0
- package/components/base/timeline/index.ts +16 -0
- package/components/base/timeline/props.d.ts +60 -0
- package/components/base/tooltip/api.ts +19 -0
- package/components/base/tooltip/index.ts +17 -0
- package/components/base/tooltip/props.d.ts +34 -0
- package/components/base/tooltip/useTooltip.ts +89 -0
- package/components/base/transfer/api.ts +18 -0
- package/components/base/transfer/index.ts +17 -0
- package/components/base/transfer/props.d.ts +63 -0
- package/components/base/transfer/useTransfer.ts +207 -0
- package/components/base/tree/api.ts +47 -0
- package/components/base/tree/index.ts +29 -0
- package/components/base/tree/props.d.ts +108 -0
- package/components/base/tree/tree.ts +263 -0
- package/components/base/tree/useTree.ts +114 -0
- package/components/message/confirm/api.ts +21 -0
- package/components/message/confirm/index.ts +15 -0
- package/components/message/confirm/props.d.ts +69 -0
- package/components/message/dialog/api.ts +19 -0
- package/components/message/dialog/index.ts +15 -0
- package/components/message/dialog/props.d.ts +55 -0
- package/components/message/drawer/api.ts +32 -0
- package/components/message/drawer/index.ts +15 -0
- package/components/message/drawer/props.d.ts +73 -0
- package/components/message/message/api.ts +27 -0
- package/components/message/message/index.ts +20 -0
- package/components/message/message/props.d.ts +54 -0
- package/components/message/message/useMessage.ts +61 -0
- package/components/message/notification/api.ts +23 -0
- package/components/message/notification/index.ts +19 -0
- package/components/message/notification/props.d.ts +64 -0
- package/components/message/notification/useNotification.ts +79 -0
- package/components/message/popover/MPopover.tsx +94 -0
- package/components/message/popover/api.ts +54 -0
- package/components/message/popover/index.ts +17 -0
- package/components/message/popover/popover.css +21 -0
- package/components/message/popover/props.d.ts +76 -0
- package/components/message/popover/usePopover.ts +230 -0
- package/components/other/darkMode/api.ts +17 -0
- package/components/other/darkMode/index.ts +17 -0
- package/components/other/darkMode/props.d.ts +37 -0
- package/components/other/darkMode/useDarkMode.ts +129 -0
- package/components/template/border/api.ts +18 -0
- package/components/template/border/index.ts +15 -0
- package/components/template/border/props.d.ts +41 -0
- package/components/template/breadcrumb/api.ts +15 -0
- package/components/template/breadcrumb/index.ts +15 -0
- package/components/template/breadcrumb/props.d.ts +45 -0
- package/components/template/descriptions/api.ts +23 -0
- package/components/template/descriptions/index.ts +16 -0
- package/components/template/descriptions/props.d.ts +54 -0
- package/components/template/form/api.ts +23 -0
- package/components/template/form/index.ts +20 -0
- package/components/template/form/props.d.ts +60 -0
- package/components/template/grid/api.ts +20 -0
- package/components/template/grid/index.ts +15 -0
- package/components/template/grid/props.d.ts +48 -0
- package/components/template/menu/api.ts +26 -0
- package/components/template/menu/index.ts +19 -0
- package/components/template/menu/props.d.ts +93 -0
- package/components/template/menu/useMenu.ts +155 -0
- package/components/template/pagination/api.ts +22 -0
- package/components/template/pagination/index.ts +18 -0
- package/components/template/pagination/props.d.ts +65 -0
- package/components/template/pagination/usePagination.ts +186 -0
- package/components/template/table/api.ts +18 -0
- package/components/template/table/index.ts +18 -0
- package/components/template/table/props.d.ts +36 -0
- package/components/template/table/useTable.ts +138 -0
- package/components/template/tableColumn/api.ts +17 -0
- package/components/template/tableColumn/index.ts +15 -0
- package/components/template/tableColumn/props.d.ts +32 -0
- package/components/template/virtualList/api.ts +16 -0
- package/components/template/virtualList/index.ts +18 -0
- package/components/template/virtualList/props.d.ts +25 -0
- package/components/template/virtualList/useVirtualList.ts +237 -0
- package/components/types/hook.d.ts +13 -0
- package/components/types/props.d.ts +52 -0
- package/components/types/template.d.ts +59 -0
- package/compositions/common/defineCore.ts +55 -0
- package/compositions/common/useDebounceFn.ts +27 -0
- package/compositions/common/useDrag.ts +65 -0
- package/compositions/common/useElementSize.ts +37 -0
- package/compositions/common/useEventListener.ts +48 -0
- package/compositions/common/usePopover.ts +45 -0
- package/compositions/common/useResizeObserver.ts +43 -0
- package/compositions/common/useTeleport.ts +24 -0
- package/compositions/input/useBooleanInput.ts +52 -0
- package/compositions/modal/useModal.ts +72 -0
- package/compositions/popper/useClickAway.ts +41 -0
- package/compositions/popper/usePopper.ts +63 -0
- package/compositions/utils/filters.ts +135 -0
- package/compositions/virtualList/enums.ts +52 -0
- package/compositions/virtualList/useContainerObserver.ts +82 -0
- package/compositions/virtualList/useEntries.ts +248 -0
- package/compositions/virtualList/useHeightCache.ts +83 -0
- package/compositions/virtualList/useSentinelObserver.ts +81 -0
- package/dist/components/base/affix/useAffix.d.ts +5 -4
- package/dist/components/base/anchor/useAnchor.d.ts +1 -1
- package/dist/components/base/autoComplete/useAutoComplete.d.ts +12 -4
- package/dist/components/base/backTop/useBackTop.d.ts +1 -1
- package/dist/components/base/button/index.d.ts +11 -2
- package/dist/components/base/button/useButton.d.ts +11 -2
- package/dist/components/base/carousel/useCarousel.d.ts +6 -3
- package/dist/components/base/cascader/useCascader.d.ts +23 -11
- package/dist/components/base/checkbox/useCheckbox.d.ts +4 -3
- package/dist/components/base/collapse/useCollapse.d.ts +2 -2
- package/dist/components/base/datePicker/useDatePicker.d.ts +140 -8
- package/dist/components/base/dropdown/useDropdown.d.ts +11 -5
- package/dist/components/base/image/useImage.d.ts +5 -5
- package/dist/components/base/input/useInput.d.ts +1 -2
- package/dist/components/base/inputNumber/useInputNumber.d.ts +2 -2
- package/dist/components/base/popover/usePopover.d.ts +8 -8
- package/dist/components/base/progress/useProgress.d.ts +1 -1
- package/dist/components/base/rate/useRate.d.ts +1 -1
- package/dist/components/base/select/useSelect.d.ts +8 -8
- package/dist/components/base/slider/useSlider.d.ts +3 -3
- package/dist/components/base/steps/index.d.ts +1 -1
- package/dist/components/base/steps/useSteps.d.ts +5 -5
- package/dist/components/base/switch/useSwitch.d.ts +8 -3
- package/dist/components/base/tabs/useTabs.d.ts +2 -2
- package/dist/components/base/timePicker/useTimePicker.d.ts +14 -6
- package/dist/components/base/tooltip/useTooltip.d.ts +14 -4
- package/dist/components/base/transfer/useTransfer.d.ts +15 -15
- package/dist/components/base/tree/index.d.ts +1 -1
- package/dist/components/base/tree/useTree.d.ts +2 -1
- package/dist/components/message/message/useMessage.d.ts +11 -1
- package/dist/components/message/notification/useNotification.d.ts +17 -1
- package/dist/components/message/popover/MPopover.d.ts +6 -1
- package/dist/components/message/popover/usePopover.d.ts +6 -6
- package/dist/components/other/darkMode/useDarkMode.d.ts +1 -1
- package/dist/components/template/menu/useMenu.d.ts +1 -0
- package/dist/components/template/virtualList/useVirtualList.d.ts +10 -7
- package/dist/compositions/common/useDrag.d.ts +1 -1
- package/dist/compositions/common/useElementSize.d.ts +2 -2
- package/dist/compositions/common/useTeleport.d.ts +4 -2
- package/dist/compositions/modal/useModal.d.ts +1 -1
- package/dist/core.js +6137 -4186
- package/dist/runtime/defineHook.d.ts +1 -1
- package/index.css +1 -0
- package/index.ts +71 -0
- package/package.json +19 -16
- package/runtime/defineHook.ts +21 -0
- package/tools/empty.ts +81 -0
- package/tools/index.ts +15 -0
- package/tools/types.ts +11 -0
- package/tsconfig.json +8 -0
- package/types/common/common.d.ts +25 -0
- package/types/common/model.d.ts +25 -0
- package/types/index.d.ts +11 -0
- package/types/props.d.ts +13 -0
- package/vite.config.build.ts +41 -0
- package/dist/vite.config.build.d.ts +0 -2
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description notification 组件 props 类型定义
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/26
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 通知类型
|
|
12
|
+
*/
|
|
13
|
+
export type NotificationType = 'success' | 'warning' | 'error' | 'info';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 通知显示位置
|
|
17
|
+
*/
|
|
18
|
+
export type NotificationPosition = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 单条通知 props
|
|
22
|
+
*/
|
|
23
|
+
export declare type NotificationProps = {
|
|
24
|
+
/**
|
|
25
|
+
* @description 通知标题
|
|
26
|
+
*/
|
|
27
|
+
title: string;
|
|
28
|
+
/**
|
|
29
|
+
* @description 通知正文内容
|
|
30
|
+
*/
|
|
31
|
+
message?: string;
|
|
32
|
+
/**
|
|
33
|
+
* @description 通知类型
|
|
34
|
+
* @default 'info'
|
|
35
|
+
*/
|
|
36
|
+
type?: NotificationType;
|
|
37
|
+
/**
|
|
38
|
+
* @description 显示时长(毫秒),0 表示不自动关闭
|
|
39
|
+
* @default 4500
|
|
40
|
+
*/
|
|
41
|
+
duration?: number;
|
|
42
|
+
/**
|
|
43
|
+
* @description 通知显示位置
|
|
44
|
+
* @default 'top-right'
|
|
45
|
+
*/
|
|
46
|
+
position?: NotificationPosition;
|
|
47
|
+
/**
|
|
48
|
+
* @description 是否显示关闭按钮
|
|
49
|
+
* @default true
|
|
50
|
+
*/
|
|
51
|
+
closable?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* @description 与屏幕边缘的偏移量(像素)
|
|
54
|
+
* @default 16
|
|
55
|
+
*/
|
|
56
|
+
offset?: number;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 通知事件类型
|
|
61
|
+
*/
|
|
62
|
+
export declare type NotificationEvents = {
|
|
63
|
+
onClose?: () => void;
|
|
64
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description notification 队列 composable
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/26
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { ref } from 'vue';
|
|
10
|
+
import { NotificationType, NotificationPosition } from './props';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 通知队列中每一条通知的内部结构
|
|
14
|
+
*/
|
|
15
|
+
export interface NotificationItem {
|
|
16
|
+
id: number;
|
|
17
|
+
title: string;
|
|
18
|
+
message: string;
|
|
19
|
+
type: NotificationType;
|
|
20
|
+
duration: number;
|
|
21
|
+
position: NotificationPosition;
|
|
22
|
+
closable: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 创建通知时的配置参数
|
|
27
|
+
*/
|
|
28
|
+
export interface NotificationAddOptions {
|
|
29
|
+
title: string;
|
|
30
|
+
message?: string;
|
|
31
|
+
type?: NotificationType;
|
|
32
|
+
duration?: number;
|
|
33
|
+
position?: NotificationPosition;
|
|
34
|
+
closable?: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 通知队列 composable
|
|
39
|
+
* 管理通知的增删与自动关闭定时器
|
|
40
|
+
*/
|
|
41
|
+
export function useNotificationQueue() {
|
|
42
|
+
const notifications = ref<NotificationItem[]>([]);
|
|
43
|
+
let nextId = 0;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 添加一条通知,duration > 0 时自动移除
|
|
47
|
+
*/
|
|
48
|
+
const add = (options: NotificationAddOptions): number => {
|
|
49
|
+
const id = nextId++;
|
|
50
|
+
const item: NotificationItem = {
|
|
51
|
+
id,
|
|
52
|
+
title: options.title,
|
|
53
|
+
message: options.message ?? '',
|
|
54
|
+
type: options.type ?? 'info',
|
|
55
|
+
duration: options.duration ?? 4500,
|
|
56
|
+
position: options.position ?? 'top-right',
|
|
57
|
+
closable: options.closable ?? true,
|
|
58
|
+
};
|
|
59
|
+
notifications.value.push(item);
|
|
60
|
+
|
|
61
|
+
if (item.duration > 0) {
|
|
62
|
+
setTimeout(() => remove(id), item.duration);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return id;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 按 id 移除一条通知
|
|
70
|
+
*/
|
|
71
|
+
const remove = (id: number): void => {
|
|
72
|
+
const idx = notifications.value.findIndex(n => n.id === id);
|
|
73
|
+
if (idx !== -1) {
|
|
74
|
+
notifications.value.splice(idx, 1);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return { notifications, add, remove };
|
|
79
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description MPopover
|
|
3
|
+
* @author youus
|
|
4
|
+
* @date 2022/4/3 18:07
|
|
5
|
+
* @version v2.0.0-process
|
|
6
|
+
*
|
|
7
|
+
* Hello, humor
|
|
8
|
+
* v2.0.0-process 阿怪 准备重构,搭建模版
|
|
9
|
+
*/
|
|
10
|
+
import { defineComponent, ref, watch } from 'vue';
|
|
11
|
+
import { props } from './api.ts';
|
|
12
|
+
import useTeleport from '../../../compositions/common/useTeleport.ts';
|
|
13
|
+
import { usePopover } from './usePopover.ts';
|
|
14
|
+
import './popover.css';
|
|
15
|
+
import { PopoverProps } from './props';
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
export default defineComponent((_props: PopoverProps, { slots, emit, expose }) => {
|
|
19
|
+
const props = _props as Required<PopoverProps>;
|
|
20
|
+
|
|
21
|
+
if (!slots.content) {
|
|
22
|
+
console.error('MPopover: content is required');
|
|
23
|
+
return () => (<></>);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (!slots.default) {
|
|
27
|
+
console.error('MPopover: trigger is required');
|
|
28
|
+
return () => (<></>);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
const placementRef = ref(props.placement);
|
|
33
|
+
const {
|
|
34
|
+
getContent,
|
|
35
|
+
popoverEnter,
|
|
36
|
+
popoverLeave,
|
|
37
|
+
popoverRef, contentRef, arrowRef,
|
|
38
|
+
popperInstance,
|
|
39
|
+
style, arrowStyle,
|
|
40
|
+
} = usePopover(
|
|
41
|
+
{ props, value: { placement: placementRef } },
|
|
42
|
+
{
|
|
43
|
+
onShow: () => {
|
|
44
|
+
emit('update:show', true);
|
|
45
|
+
},
|
|
46
|
+
onHide: () => {
|
|
47
|
+
emit('update:show', false);
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const show = async () => {
|
|
53
|
+
await popperInstance.value?.show();
|
|
54
|
+
};
|
|
55
|
+
const hide = () => {
|
|
56
|
+
popperInstance.value?.hide();
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
expose({ show, hide });
|
|
60
|
+
|
|
61
|
+
watch(() => props.show, () => {
|
|
62
|
+
if (props.show) {show();} else {hide();}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const handleClick = async () => {
|
|
66
|
+
if (props.hover) {return;}
|
|
67
|
+
await popperInstance.value?.toggle();
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
return () => {
|
|
72
|
+
return <div class="m-popover" data-popper-placement={placementRef.value}
|
|
73
|
+
onMouseleave={popoverLeave}>
|
|
74
|
+
<div class="m-popover-default-wrapper"
|
|
75
|
+
ref={popoverRef}
|
|
76
|
+
onMouseenter={popoverEnter}
|
|
77
|
+
onClick={handleClick}>
|
|
78
|
+
{slots.default?.()}
|
|
79
|
+
</div>
|
|
80
|
+
<div class="m-popover-content" ref={contentRef} style={style.value}>
|
|
81
|
+
{getContent(props, () => slots.content?.(), useTeleport)}
|
|
82
|
+
{
|
|
83
|
+
// todo when content not render arrow should not render
|
|
84
|
+
slots.arrow ?
|
|
85
|
+
<div class="m-popover-arrow" ref={arrowRef} style={arrowStyle.value}>{slots.arrow()}</div> : null
|
|
86
|
+
}
|
|
87
|
+
</div>
|
|
88
|
+
</div>;
|
|
89
|
+
};
|
|
90
|
+
}, {
|
|
91
|
+
name: 'MPopover',
|
|
92
|
+
props,
|
|
93
|
+
emits: ['open:popper', 'close:popper', 'update:show'],
|
|
94
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description popover api
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2023/4/23 11:53
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { PopoverProps } from './props';
|
|
10
|
+
import { MCOPO, MPropType } from '../../types/props';
|
|
11
|
+
import { Placement } from '../../../compositions/popper/usePopper.ts';
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export const props: MCOPO<PopoverProps> = {
|
|
15
|
+
placement: {
|
|
16
|
+
type: String as MPropType<Placement>,
|
|
17
|
+
default: 'bottom',
|
|
18
|
+
// validator: (value: string) =>
|
|
19
|
+
// [
|
|
20
|
+
// 'auto',
|
|
21
|
+
// 'auto-start',
|
|
22
|
+
// 'auto-end',
|
|
23
|
+
// 'top',
|
|
24
|
+
// 'top-start',
|
|
25
|
+
// 'top-end',
|
|
26
|
+
// 'bottom',
|
|
27
|
+
// 'bottom-start',
|
|
28
|
+
// 'bottom-end',
|
|
29
|
+
// 'right',
|
|
30
|
+
// 'right-start',
|
|
31
|
+
// 'right-end',
|
|
32
|
+
// 'left',
|
|
33
|
+
// 'left-start',
|
|
34
|
+
// 'left-end'
|
|
35
|
+
// ].includes(value)
|
|
36
|
+
},
|
|
37
|
+
mountRender: { type: Boolean, default: false },
|
|
38
|
+
disableClickAway: { type: Boolean, default: false },
|
|
39
|
+
// offsetSkid: { type: String, default: '0' },
|
|
40
|
+
// offsetDistance: { type: String, default: '0' },
|
|
41
|
+
hover: { type: Boolean, default: false },
|
|
42
|
+
show: { type: Boolean, default: null },
|
|
43
|
+
// disabled: { type: Boolean, default: false },
|
|
44
|
+
// openDelay: { type: Number, default: 0 },
|
|
45
|
+
// closeDelay: { type: Number, default: 0 },
|
|
46
|
+
// interactive: { type: Boolean, default: true },
|
|
47
|
+
// locked: { type: Boolean, default: false },
|
|
48
|
+
content: { type: String, default: '' },
|
|
49
|
+
popper: {
|
|
50
|
+
type: Object, default: () => ({}),
|
|
51
|
+
},
|
|
52
|
+
teleport: { type: [Object, Boolean], default: undefined },
|
|
53
|
+
title: { type: String, default: undefined },
|
|
54
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2024/11/29 09:22
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { props } from './api.ts';
|
|
10
|
+
import { usePopover } from './usePopover.ts';
|
|
11
|
+
|
|
12
|
+
export const MessagePopoverCore = {
|
|
13
|
+
props,
|
|
14
|
+
usePopover,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type { PopoverProps as MessagePopoverProps } from './props';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
.m-popover {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.m-popover-content {
|
|
6
|
+
position: absolute;
|
|
7
|
+
display: none;
|
|
8
|
+
z-index: 9;
|
|
9
|
+
width: max-content;
|
|
10
|
+
top: 0;
|
|
11
|
+
left: 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.m-popover-default-wrapper {
|
|
15
|
+
display: inline-block;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.m-popover-arrow {
|
|
19
|
+
position: absolute;
|
|
20
|
+
display: none;
|
|
21
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description popover api type
|
|
3
|
+
* @author youus
|
|
4
|
+
* @date 2022/4/4 01:22
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* @name m-popover
|
|
8
|
+
* @docDescription Popover component with shuimo-ui style.
|
|
9
|
+
* 水墨组件的弹出框组件。
|
|
10
|
+
* @docUrl https://shuimo.design/popover
|
|
11
|
+
*
|
|
12
|
+
* Hello, humor
|
|
13
|
+
*/
|
|
14
|
+
import { Placement, PopperConfig } from '../../../compositions/popper/usePopper.ts';
|
|
15
|
+
import { MTeleportProps } from '../../../types/common/common';
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
export type PopoverProps = {
|
|
19
|
+
/**
|
|
20
|
+
* @description popover display placement
|
|
21
|
+
* @type Placement
|
|
22
|
+
* @default bottom
|
|
23
|
+
*/
|
|
24
|
+
placement?: Placement,
|
|
25
|
+
/**
|
|
26
|
+
* @description Whether to render the popover content when the component is mounted
|
|
27
|
+
* @type boolean
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
mountRender?: boolean,
|
|
31
|
+
/**
|
|
32
|
+
* @description Disables automatically closing the popover when the user clicks away from it
|
|
33
|
+
* @type boolean
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
disableClickAway?: boolean,
|
|
37
|
+
/**
|
|
38
|
+
* @description If the content is just a simple string, it can be passed in as a prop
|
|
39
|
+
* @type any
|
|
40
|
+
* @default ''
|
|
41
|
+
*/
|
|
42
|
+
content?: any,
|
|
43
|
+
/**
|
|
44
|
+
* @description Trigger the popper on hover
|
|
45
|
+
* @type boolean
|
|
46
|
+
* @default false
|
|
47
|
+
*/
|
|
48
|
+
hover?: boolean,
|
|
49
|
+
/**
|
|
50
|
+
* @description display content value
|
|
51
|
+
* 是否显示参数
|
|
52
|
+
* @type boolean
|
|
53
|
+
* @default false
|
|
54
|
+
*/
|
|
55
|
+
show?: boolean,
|
|
56
|
+
/**
|
|
57
|
+
* @description floating-ui options, look: https://floating-ui.com/
|
|
58
|
+
* @type PopperConfig
|
|
59
|
+
* @default {}
|
|
60
|
+
*/
|
|
61
|
+
popper?: PopperConfig,
|
|
62
|
+
/**
|
|
63
|
+
* @description popover teleport
|
|
64
|
+
* 弹出框传送
|
|
65
|
+
* @type teleport props
|
|
66
|
+
* @default undefined
|
|
67
|
+
*/
|
|
68
|
+
teleport?: MTeleportProps | undefined | boolean,
|
|
69
|
+
/**
|
|
70
|
+
* @description popover title
|
|
71
|
+
* 气泡标题,传入时在内容上方渲染标题行
|
|
72
|
+
* @type string
|
|
73
|
+
* @default undefined
|
|
74
|
+
*/
|
|
75
|
+
title?: string,
|
|
76
|
+
};
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description core usePopover hook
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2023/1/29 10:39
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { Placement, PopperConfig, PositionStyle, usePopper } from '../../../compositions/popper/usePopper.ts';
|
|
10
|
+
import useClickAway from '../../../compositions/popper/useClickAway';
|
|
11
|
+
import { Options } from '../../../compositions/common/defineCore';
|
|
12
|
+
// import MPrinter from '../../other/printer/Printer';
|
|
13
|
+
import { PopoverProps } from './props';
|
|
14
|
+
import { onBeforeMount, onMounted, ref, type Ref, shallowRef } from 'vue';
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
// const error = MPrinter('水墨Popover组件').error;
|
|
18
|
+
export type IPopper = ReturnType<typeof usePopper>;
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
export class PopoverImpl {
|
|
22
|
+
|
|
23
|
+
protected _active: HTMLElement;
|
|
24
|
+
protected _content: HTMLElement;
|
|
25
|
+
protected _arrow: HTMLElement | undefined;
|
|
26
|
+
popperInstance: IPopper;
|
|
27
|
+
style: Ref;
|
|
28
|
+
arrowStyle: Ref;
|
|
29
|
+
placement: Ref;
|
|
30
|
+
visible: boolean = false;
|
|
31
|
+
onShow?: Function;
|
|
32
|
+
onHide?: Function;
|
|
33
|
+
|
|
34
|
+
constructor(
|
|
35
|
+
val: { style: Ref, arrowStyle: Ref, placement: Ref, /* default */show: boolean },
|
|
36
|
+
active?: HTMLElement,
|
|
37
|
+
content?: HTMLElement,
|
|
38
|
+
arrow?: HTMLElement,
|
|
39
|
+
config?: PopperConfig,
|
|
40
|
+
lifecycle?: {
|
|
41
|
+
onShow?: Function,
|
|
42
|
+
onHide?: Function
|
|
43
|
+
},
|
|
44
|
+
) {
|
|
45
|
+
if (!content) {throw new Error('MPopover: content is required');}
|
|
46
|
+
if (!active) {throw new Error('MPopover: active is required');}
|
|
47
|
+
|
|
48
|
+
this._active = active!;
|
|
49
|
+
this._content = content!;
|
|
50
|
+
this._arrow = arrow;
|
|
51
|
+
this.popperInstance = usePopper(this._active, this._content,
|
|
52
|
+
(positionStyle: PositionStyle) => this.update(positionStyle), this._arrow, config);
|
|
53
|
+
this.style = val.style;
|
|
54
|
+
this.arrowStyle = val.arrowStyle;
|
|
55
|
+
this.placement = val.placement;
|
|
56
|
+
this.visible = val.show;
|
|
57
|
+
this.onShow = lifecycle?.onShow;
|
|
58
|
+
this.onHide = lifecycle?.onHide;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
get content() {
|
|
62
|
+
return this._content;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async show() {
|
|
66
|
+
this.style.value = { display: 'block', opacity: '0' };
|
|
67
|
+
this.arrowStyle.value = { display: 'block', opacity: '0' };
|
|
68
|
+
this.visible = true;
|
|
69
|
+
await this.popperInstance.getPositionStyle();
|
|
70
|
+
this.onShow?.();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
update(positionStyle: PositionStyle) {
|
|
74
|
+
if (!this.visible) {
|
|
75
|
+
this.hide();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
this.style.value = positionStyle.style;
|
|
79
|
+
this.arrowStyle.value = positionStyle.arrowStyle;
|
|
80
|
+
this.placement.value = positionStyle.placement;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
hide() {
|
|
84
|
+
this.style.value = undefined;
|
|
85
|
+
this.arrowStyle.value = undefined;
|
|
86
|
+
this.visible = false;
|
|
87
|
+
this.onHide?.();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async toggle() {
|
|
91
|
+
if (this.visible) {
|
|
92
|
+
this.hide();
|
|
93
|
+
} else {
|
|
94
|
+
await this.show();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
destroy() {
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// magic tool type, get array element type
|
|
104
|
+
type ArrayElement<ArrayType> =
|
|
105
|
+
ArrayType extends readonly (infer ElementType)[] ? ElementType : never;
|
|
106
|
+
|
|
107
|
+
export function usePopover(
|
|
108
|
+
options: Options<{ props: PopoverProps, value: { placement: Placement } }>,
|
|
109
|
+
lifecycle?: { /* event can't use optional... */
|
|
110
|
+
onShow?: Function,
|
|
111
|
+
onHide?: Function
|
|
112
|
+
}) {
|
|
113
|
+
const style = ref();
|
|
114
|
+
const arrowStyle = ref();
|
|
115
|
+
const placement = ref(options.value.placement);
|
|
116
|
+
let instance: PopoverImpl | null = null;
|
|
117
|
+
let clickAwayInstance: ReturnType<typeof useClickAway>;
|
|
118
|
+
|
|
119
|
+
const popperInstance = shallowRef<PopoverImpl>();
|
|
120
|
+
|
|
121
|
+
const popoverRef = ref<HTMLElement>();
|
|
122
|
+
const contentRef = ref<HTMLElement>();
|
|
123
|
+
const arrowRef = ref<HTMLElement>();
|
|
124
|
+
|
|
125
|
+
const createPopover = (
|
|
126
|
+
active: HTMLElement,
|
|
127
|
+
content: HTMLElement,
|
|
128
|
+
arrow?: HTMLElement,
|
|
129
|
+
config?: PopperConfig,
|
|
130
|
+
) => {
|
|
131
|
+
instance = new PopoverImpl(
|
|
132
|
+
{ style, arrowStyle, placement, show: options.props.show },
|
|
133
|
+
active,
|
|
134
|
+
content,
|
|
135
|
+
arrow,
|
|
136
|
+
config,
|
|
137
|
+
{
|
|
138
|
+
onShow: () => {
|
|
139
|
+
clickAwayInstance?.add();
|
|
140
|
+
lifecycle?.onShow?.();
|
|
141
|
+
},
|
|
142
|
+
onHide: () => {
|
|
143
|
+
clickAwayInstance?.remove();
|
|
144
|
+
lifecycle?.onHide?.();
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
return instance;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const props = options.props;
|
|
151
|
+
const popoverEnter = () => {
|
|
152
|
+
if (props.hover) {
|
|
153
|
+
instance?.show();
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
const popoverLeave = () => {
|
|
157
|
+
if (props.hover) {
|
|
158
|
+
instance?.hide();
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const onBeforeDestroyEvents: Function[] = [];
|
|
163
|
+
|
|
164
|
+
onMounted(() => {
|
|
165
|
+
if (!popoverRef.value || !contentRef.value) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
popperInstance.value = createPopover(popoverRef.value, contentRef.value, arrowRef.value, {
|
|
169
|
+
...props.popper,
|
|
170
|
+
placement: props.placement,
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
if (options.props.disableClickAway) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
clickAwayInstance = useClickAway({
|
|
178
|
+
target: () => instance?.content?.parentElement,
|
|
179
|
+
handler: () => {
|
|
180
|
+
instance?.hide();
|
|
181
|
+
// emits?
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
onBeforeMount(() => {
|
|
187
|
+
if (clickAwayInstance) {
|
|
188
|
+
const { onBeforeDestroy } = clickAwayInstance;
|
|
189
|
+
onBeforeDestroy();
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
const getContent = <T>(
|
|
195
|
+
props: PopoverProps,
|
|
196
|
+
getContentSlot: () => T,
|
|
197
|
+
useTeleport: (options: any) => ArrayElement<T> | T,
|
|
198
|
+
_instance = instance,
|
|
199
|
+
) => {
|
|
200
|
+
const contentTeleportWrapper = () => {
|
|
201
|
+
if (props.teleport) {
|
|
202
|
+
return useTeleport({
|
|
203
|
+
teleportProps: props.teleport,
|
|
204
|
+
slot: getContentSlot(),
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
return getContentSlot();
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
if (props.mountRender) {
|
|
211
|
+
return contentTeleportWrapper();
|
|
212
|
+
}
|
|
213
|
+
if (!_instance || !_instance.visible) {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
return contentTeleportWrapper();
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
return {
|
|
220
|
+
getContent,
|
|
221
|
+
popoverEnter,
|
|
222
|
+
popoverLeave,
|
|
223
|
+
popoverRef, contentRef, arrowRef,
|
|
224
|
+
popperInstance,
|
|
225
|
+
style, arrowStyle,
|
|
226
|
+
lifecycle: {
|
|
227
|
+
onBeforeDestroyEvents,
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description dark mode api
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/25
|
|
5
|
+
* @version v1.1.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { MCOPO, MPropType } from '../../types/props';
|
|
10
|
+
import { DarkModeProps } from './props';
|
|
11
|
+
|
|
12
|
+
export const props: MCOPO<DarkModeProps> = {
|
|
13
|
+
modelValue: { type: Boolean, default: false },
|
|
14
|
+
autoMode: { type: Boolean, default: false },
|
|
15
|
+
initHandler: { type: Function as MPropType<() => boolean>, default: undefined },
|
|
16
|
+
storageKey: { type: String, default: undefined },
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description dark mode core 导出
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/25
|
|
5
|
+
* @version v1.1.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { props } from './api';
|
|
10
|
+
import { useDarkMode } from './useDarkMode';
|
|
11
|
+
|
|
12
|
+
export const DarkModeCore = {
|
|
13
|
+
props,
|
|
14
|
+
useDarkMode,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type { DarkModeProps } from './props';
|