@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,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Tree 组件 composable,封装树的初始化与交互逻辑
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/25
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { shallowRef } from 'vue';
|
|
10
|
+
import Tree from './tree';
|
|
11
|
+
import { TreeData, TreeNodeData, TreeProps } from './props';
|
|
12
|
+
|
|
13
|
+
/** fixKey 内部递归实现:为无 key 的节点生成唯一 key */
|
|
14
|
+
const _fixKey = (data: TreeData[], key: string | number = 'key', prefixKey: string | number): TreeData[] => {
|
|
15
|
+
let keyStart = 0;
|
|
16
|
+
return data.map(d => {
|
|
17
|
+
if (!d[key]) {
|
|
18
|
+
d[key] = `${prefixKey}${keyStart++}`;
|
|
19
|
+
}
|
|
20
|
+
if (d.children) {
|
|
21
|
+
d.children = _fixKey(d.children as TreeData[], key, d[key] as string | number) as TreeData[];
|
|
22
|
+
}
|
|
23
|
+
return d;
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 为没有 key 的节点递归生成唯一标识
|
|
29
|
+
* @param data 树数据(数组或单节点)
|
|
30
|
+
* @param key key 字段名,默认 'key'
|
|
31
|
+
* @param prefixKey 前缀 key,用于构造子节点唯一 id
|
|
32
|
+
*/
|
|
33
|
+
export const fixKey = (
|
|
34
|
+
data: TreeData | TreeData[],
|
|
35
|
+
key: string | number,
|
|
36
|
+
prefixKey: string | number = '',
|
|
37
|
+
): TreeData | TreeData[] => {
|
|
38
|
+
return Array.isArray(data)
|
|
39
|
+
? _fixKey(data, key ?? 'key', prefixKey)
|
|
40
|
+
: _fixKey([data], key ?? 'key', prefixKey)[0];
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export interface UseTreeOptions {
|
|
44
|
+
props: TreeProps;
|
|
45
|
+
event: {
|
|
46
|
+
/** 触发 shallowRef 更新,通知 Vue 重新渲染 */
|
|
47
|
+
triggerTree: () => void;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* useTree — Tree 组件逻辑 composable
|
|
53
|
+
*
|
|
54
|
+
* 返回:
|
|
55
|
+
* - treeRef:Tree 实例的 shallowRef
|
|
56
|
+
* - initTreeRef:重新初始化 Tree(数据变化时调用)
|
|
57
|
+
* - handleToggleExpand:切换节点展开/收起
|
|
58
|
+
* - handleToggleChecked:切换节点 checkbox 选中状态
|
|
59
|
+
* - getNodesByKeys:根据 key 批量获取节点
|
|
60
|
+
*/
|
|
61
|
+
export const useTree = (options: UseTreeOptions) => {
|
|
62
|
+
const { props, event } = options;
|
|
63
|
+
const treeRef = shallowRef<Tree>();
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 初始化 Tree 实例
|
|
67
|
+
* 使用 structuredClone 深拷贝数据,避免直接修改外部数据源
|
|
68
|
+
*/
|
|
69
|
+
const initTreeRef = (data: TreeData | TreeData[] | undefined = props.data) => {
|
|
70
|
+
// 统一转为数组
|
|
71
|
+
const rawArr = Array.isArray(data) ? data : (data ? [data] : []);
|
|
72
|
+
// 深拷贝避免污染原始数据(不使用 structuredClone,因为 Vue 响应式代理无法被 clone)
|
|
73
|
+
const cloned = JSON.parse(JSON.stringify(rawArr)) as TreeData[];
|
|
74
|
+
// 为无 key 节点补充 key
|
|
75
|
+
const keyField = props.config?.key ?? 'key';
|
|
76
|
+
const fixed = fixKey(cloned, keyField) as TreeData[];
|
|
77
|
+
|
|
78
|
+
treeRef.value = new Tree({
|
|
79
|
+
data: fixed,
|
|
80
|
+
config: props.config,
|
|
81
|
+
defaultExpandAll: props.defaultExpandAll,
|
|
82
|
+
checkStrictly: props.checkStrictly,
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// 组件挂载时立即初始化
|
|
87
|
+
initTreeRef();
|
|
88
|
+
|
|
89
|
+
/** 切换节点展开/收起,并触发 Vue 响应式更新 */
|
|
90
|
+
const handleToggleExpand = (node: TreeNodeData, e: MouseEvent) => {
|
|
91
|
+
e.stopPropagation();
|
|
92
|
+
treeRef.value?.toggleExpand(node);
|
|
93
|
+
event.triggerTree();
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/** 切换节点 checkbox 选中状态,并触发 Vue 响应式更新 */
|
|
97
|
+
const handleToggleChecked = (node: TreeNodeData, checked: boolean) => {
|
|
98
|
+
treeRef.value?.setNodeCheckbox(node, checked);
|
|
99
|
+
event.triggerTree();
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/** 根据 key 数组获取节点列表(透传给 MTreeNode 使用) */
|
|
103
|
+
const getNodesByKeys = (keys: TreeNodeData['key'][]): TreeNodeData[] => {
|
|
104
|
+
return treeRef.value!.getTreeData(keys);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
treeRef,
|
|
109
|
+
getNodesByKeys,
|
|
110
|
+
handleToggleExpand,
|
|
111
|
+
handleToggleChecked,
|
|
112
|
+
initTreeRef,
|
|
113
|
+
};
|
|
114
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description confirm runtime props 定义
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/25
|
|
5
|
+
* @version v1.1.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { MCOPO } from '../../types/props';
|
|
10
|
+
import { ConfirmProps } from './props';
|
|
11
|
+
|
|
12
|
+
export const props: MCOPO<ConfirmProps> = {
|
|
13
|
+
visible: { type: Boolean, default: false },
|
|
14
|
+
mask: { type: Object, default: () => ({ show: true, clickClose: false }) },
|
|
15
|
+
teleport: { type: Object, default: () => ({ to: 'body' }) },
|
|
16
|
+
content: { type: String, default: '' },
|
|
17
|
+
confirmText: { type: String, default: '确定' },
|
|
18
|
+
cancelText: { type: String, default: '取消' },
|
|
19
|
+
title: { type: String, default: undefined },
|
|
20
|
+
loading: { type: Boolean, default: false },
|
|
21
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description confirm core 导出
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/25
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { props } from './api';
|
|
10
|
+
|
|
11
|
+
export const ConfirmCore = {
|
|
12
|
+
props,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type { ConfirmProps } from './props';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description confirm props 类型定义
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/25
|
|
5
|
+
* @version v1.1.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import type { ModelMask } from '../../../types/common/model.d.ts';
|
|
10
|
+
import type { MTeleportProps } from '../../../types/common/common.d.ts';
|
|
11
|
+
|
|
12
|
+
export declare type ConfirmProps = {
|
|
13
|
+
/**
|
|
14
|
+
* @description confirm mask option
|
|
15
|
+
* 确认框背景配置
|
|
16
|
+
* @type ModelMask
|
|
17
|
+
* @default { show: true, clickClose: false }
|
|
18
|
+
*/
|
|
19
|
+
mask?: ModelMask;
|
|
20
|
+
/**
|
|
21
|
+
* @description confirm teleport
|
|
22
|
+
* 确认框传送目标
|
|
23
|
+
* @type MTeleportProps
|
|
24
|
+
* @default { to: 'body' }
|
|
25
|
+
*/
|
|
26
|
+
teleport?: MTeleportProps;
|
|
27
|
+
/**
|
|
28
|
+
* @description confirm content
|
|
29
|
+
* 确认框内容
|
|
30
|
+
* @type string
|
|
31
|
+
* @default ''
|
|
32
|
+
*/
|
|
33
|
+
content?: string;
|
|
34
|
+
/**
|
|
35
|
+
* @description confirm button text
|
|
36
|
+
* 确认按钮文字
|
|
37
|
+
* @type string
|
|
38
|
+
* @default '确定'
|
|
39
|
+
*/
|
|
40
|
+
confirmText?: string;
|
|
41
|
+
/**
|
|
42
|
+
* @description cancel button text
|
|
43
|
+
* 取消按钮文字
|
|
44
|
+
* @type string
|
|
45
|
+
* @default '取消'
|
|
46
|
+
*/
|
|
47
|
+
cancelText?: string;
|
|
48
|
+
/**
|
|
49
|
+
* @description confirm dialog visible
|
|
50
|
+
* 确认框是否显示(由 composable 内部管理)
|
|
51
|
+
* @type boolean
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
54
|
+
visible?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* @description confirm title
|
|
57
|
+
* 确认框标题,传入时渲染标题栏
|
|
58
|
+
* @type string
|
|
59
|
+
* @default undefined
|
|
60
|
+
*/
|
|
61
|
+
title?: string;
|
|
62
|
+
/**
|
|
63
|
+
* @description confirm button loading state
|
|
64
|
+
* 确认按钮 loading 状态,loading 时禁用按钮并显示 spinner
|
|
65
|
+
* @type boolean
|
|
66
|
+
* @default false
|
|
67
|
+
*/
|
|
68
|
+
loading?: boolean;
|
|
69
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description dialog runtime props 定义
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/25
|
|
5
|
+
* @version v1.1.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { MCOPO } from '../../types/props';
|
|
10
|
+
import { DialogProps } from './props';
|
|
11
|
+
|
|
12
|
+
export const props: MCOPO<DialogProps> = {
|
|
13
|
+
visible: { type: Boolean, default: false },
|
|
14
|
+
mask: { type: Object, default: () => ({ show: true, clickClose: true }) },
|
|
15
|
+
closeBtn: { type: Boolean, default: true },
|
|
16
|
+
teleport: { type: Object, default: () => ({ to: 'body' }) },
|
|
17
|
+
title: { type: String, default: undefined },
|
|
18
|
+
width: { type: String, default: undefined },
|
|
19
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description dialog core 导出
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/25
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { props } from './api';
|
|
10
|
+
|
|
11
|
+
export const DialogCore = {
|
|
12
|
+
props,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type { DialogProps } from './props';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description dialog props 类型定义
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/25
|
|
5
|
+
* @version v1.1.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import type { MTeleportProps } from '../../../types/common/common.d.ts';
|
|
10
|
+
import type { ModelMask } from '../../../types/common/model.d.ts';
|
|
11
|
+
|
|
12
|
+
export declare type DialogProps = {
|
|
13
|
+
/**
|
|
14
|
+
* @description dialog visible value
|
|
15
|
+
* 弹窗是否显示
|
|
16
|
+
* @type boolean
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
visible?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* @description dialog mask option
|
|
22
|
+
* 弹窗遮罩配置
|
|
23
|
+
* @type ModelMask
|
|
24
|
+
* @default { show: true, clickClose: true }
|
|
25
|
+
*/
|
|
26
|
+
mask?: ModelMask;
|
|
27
|
+
/**
|
|
28
|
+
* @description close button visible
|
|
29
|
+
* 是否显示关闭按钮
|
|
30
|
+
* @type boolean
|
|
31
|
+
* @default true
|
|
32
|
+
*/
|
|
33
|
+
closeBtn?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* @description dialog teleport
|
|
36
|
+
* 弹窗传送目标
|
|
37
|
+
* @type MTeleportProps
|
|
38
|
+
* @default { to: 'body' }
|
|
39
|
+
*/
|
|
40
|
+
teleport?: MTeleportProps;
|
|
41
|
+
/**
|
|
42
|
+
* @description dialog title
|
|
43
|
+
* 弹窗标题,传入时渲染标题栏
|
|
44
|
+
* @type string
|
|
45
|
+
* @default undefined
|
|
46
|
+
*/
|
|
47
|
+
title?: string;
|
|
48
|
+
/**
|
|
49
|
+
* @description dialog width
|
|
50
|
+
* 弹窗宽度,支持 px / % 等合法 CSS 宽度值
|
|
51
|
+
* @type string
|
|
52
|
+
* @default undefined
|
|
53
|
+
*/
|
|
54
|
+
width?: string;
|
|
55
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description drawer 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 { DrawerProps } from './props';
|
|
11
|
+
import type { ModelMask } from '../../../types/common/model.d.ts';
|
|
12
|
+
import type { MTeleportProps } from '../../../types/common/common.d.ts';
|
|
13
|
+
|
|
14
|
+
export const props: MCOPO<DrawerProps> = {
|
|
15
|
+
visible: { type: Boolean, default: false },
|
|
16
|
+
mask: {
|
|
17
|
+
type: Object as MPropType<ModelMask>,
|
|
18
|
+
default: () => ({ show: true, clickClose: true }),
|
|
19
|
+
},
|
|
20
|
+
drawerClass: { type: Array, default: () => [] },
|
|
21
|
+
direction: {
|
|
22
|
+
type: String as MPropType<'top' | 'right' | 'bottom' | 'left'>,
|
|
23
|
+
default: 'right',
|
|
24
|
+
},
|
|
25
|
+
teleport: {
|
|
26
|
+
type: Object as MPropType<MTeleportProps>,
|
|
27
|
+
default: () => ({ to: 'body' }),
|
|
28
|
+
},
|
|
29
|
+
title: { type: String, default: undefined },
|
|
30
|
+
width: { type: String, default: undefined },
|
|
31
|
+
height: { type: String, default: undefined },
|
|
32
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description drawer core 导出
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/25
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { props } from './api';
|
|
10
|
+
|
|
11
|
+
export const DrawerCore = {
|
|
12
|
+
props,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type { DrawerProps } from './props.d.ts';
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description drawer api type
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/25
|
|
5
|
+
* @version v1.1.0
|
|
6
|
+
*
|
|
7
|
+
* @name m-drawer
|
|
8
|
+
* @docDescription Headless drawer component.
|
|
9
|
+
* 无样式抽屉组件。
|
|
10
|
+
*
|
|
11
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
12
|
+
*/
|
|
13
|
+
import type { ModelMask } from '../../../types/common/model.d.ts';
|
|
14
|
+
import type { MTeleportProps } from '../../../types/common/common.d.ts';
|
|
15
|
+
|
|
16
|
+
export declare type DrawerProps = {
|
|
17
|
+
/**
|
|
18
|
+
* @description drawer visible value
|
|
19
|
+
* 抽屉是否显示
|
|
20
|
+
* @type boolean
|
|
21
|
+
* @default false
|
|
22
|
+
*/
|
|
23
|
+
visible?: boolean,
|
|
24
|
+
/**
|
|
25
|
+
* @description drawer mask option
|
|
26
|
+
* 抽屉背景配置
|
|
27
|
+
* @type ModelMask
|
|
28
|
+
* @default { show: true, clickClose: true }
|
|
29
|
+
*/
|
|
30
|
+
mask?: ModelMask,
|
|
31
|
+
/**
|
|
32
|
+
* @description drawer class
|
|
33
|
+
* 抽屉扩展类名
|
|
34
|
+
* @type string[]
|
|
35
|
+
* @default []
|
|
36
|
+
*/
|
|
37
|
+
drawerClass?: string[],
|
|
38
|
+
/**
|
|
39
|
+
* @description drawer direction
|
|
40
|
+
* 抽屉出现方向
|
|
41
|
+
* @type 'top' | 'right' | 'bottom' | 'left'
|
|
42
|
+
* @default 'right'
|
|
43
|
+
*/
|
|
44
|
+
direction?: 'top' | 'right' | 'bottom' | 'left',
|
|
45
|
+
/**
|
|
46
|
+
* @description drawer teleport
|
|
47
|
+
* 抽屉传送配置
|
|
48
|
+
* @type MTeleportProps
|
|
49
|
+
* @default { to: 'body' }
|
|
50
|
+
*/
|
|
51
|
+
teleport?: MTeleportProps,
|
|
52
|
+
/**
|
|
53
|
+
* @description drawer title
|
|
54
|
+
* 抽屉标题,传入时渲染标题栏
|
|
55
|
+
* @type string
|
|
56
|
+
* @default undefined
|
|
57
|
+
*/
|
|
58
|
+
title?: string,
|
|
59
|
+
/**
|
|
60
|
+
* @description drawer width
|
|
61
|
+
* 抽屉宽度,适用于 left / right 方向
|
|
62
|
+
* @type string
|
|
63
|
+
* @default undefined
|
|
64
|
+
*/
|
|
65
|
+
width?: string,
|
|
66
|
+
/**
|
|
67
|
+
* @description drawer height
|
|
68
|
+
* 抽屉高度,适用于 top / bottom 方向
|
|
69
|
+
* @type string
|
|
70
|
+
* @default undefined
|
|
71
|
+
*/
|
|
72
|
+
height?: string,
|
|
73
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description message runtime props 定义
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/25
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { MCOPO, MPropType } from '../../types/props';
|
|
10
|
+
import { MessageProps, MessageListProps, MessageType, MessageDirectionType } from './props';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 单条消息组件的运行时 props
|
|
14
|
+
*/
|
|
15
|
+
export const messageProps: MCOPO<MessageProps> = {
|
|
16
|
+
content: { type: String, required: true },
|
|
17
|
+
type: { type: String as MPropType<MessageType>, default: 'info' },
|
|
18
|
+
duration: { type: Number, default: 3000 },
|
|
19
|
+
direction: { type: String as MPropType<MessageDirectionType>, default: 'top-right' },
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 消息列表容器的运行时 props
|
|
24
|
+
*/
|
|
25
|
+
export const messageListProps: MCOPO<MessageListProps> = {
|
|
26
|
+
direction: { type: String as MPropType<MessageDirectionType>, default: 'top-right' },
|
|
27
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description message core 导出
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/25
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { messageProps, messageListProps } from './api';
|
|
10
|
+
import { useMessageQueue } from './useMessage';
|
|
11
|
+
|
|
12
|
+
export const MessageCore = {
|
|
13
|
+
messageProps,
|
|
14
|
+
messageListProps,
|
|
15
|
+
useMessageQueue,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { useMessageQueue } from './useMessage';
|
|
19
|
+
export type { MessageProps, MessageListProps, MessageType, MessageDirectionType } from './props';
|
|
20
|
+
export type { MessageItem } from './useMessage';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description message 组件 props 类型定义
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/25
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 消息类型枚举
|
|
12
|
+
*/
|
|
13
|
+
export type MessageType = 'success' | 'warning' | 'info' | 'error';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 消息出现方位枚举
|
|
17
|
+
*/
|
|
18
|
+
export type MessageDirectionType = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 单条消息 props
|
|
22
|
+
*/
|
|
23
|
+
export declare type MessageProps = {
|
|
24
|
+
/**
|
|
25
|
+
* @description 消息类型
|
|
26
|
+
* @default 'info'
|
|
27
|
+
*/
|
|
28
|
+
type?: MessageType;
|
|
29
|
+
/**
|
|
30
|
+
* @description 显示时长(毫秒),0 表示不自动关闭
|
|
31
|
+
* @default 3000
|
|
32
|
+
*/
|
|
33
|
+
duration?: number;
|
|
34
|
+
/**
|
|
35
|
+
* @description 消息内容
|
|
36
|
+
*/
|
|
37
|
+
content: string;
|
|
38
|
+
/**
|
|
39
|
+
* @description 消息出现的方位
|
|
40
|
+
* @default 'top-right'
|
|
41
|
+
*/
|
|
42
|
+
direction?: MessageDirectionType;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 消息列表容器 props
|
|
47
|
+
*/
|
|
48
|
+
export declare type MessageListProps = {
|
|
49
|
+
/**
|
|
50
|
+
* @description 消息列表出现的方位
|
|
51
|
+
* @default 'top-right'
|
|
52
|
+
*/
|
|
53
|
+
direction?: MessageDirectionType;
|
|
54
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description message 队列 composable
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/25
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { ref } from 'vue';
|
|
10
|
+
import { MessageType } from './props';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 消息队列中每一条消息的内部结构
|
|
14
|
+
*/
|
|
15
|
+
export interface MessageItem {
|
|
16
|
+
id: number;
|
|
17
|
+
type: MessageType;
|
|
18
|
+
content: string;
|
|
19
|
+
duration: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 消息队列 composable
|
|
24
|
+
* 管理消息的增删与自动关闭定时器
|
|
25
|
+
*/
|
|
26
|
+
export function useMessageQueue() {
|
|
27
|
+
const messages = ref<MessageItem[]>([]);
|
|
28
|
+
let nextId = 0;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 添加一条消息,duration > 0 时自动移除
|
|
32
|
+
*/
|
|
33
|
+
const add = (props: { type?: MessageType; content: string; duration?: number }): number => {
|
|
34
|
+
const id = nextId++;
|
|
35
|
+
const item: MessageItem = {
|
|
36
|
+
id,
|
|
37
|
+
type: props.type ?? 'info',
|
|
38
|
+
content: props.content,
|
|
39
|
+
duration: props.duration ?? 3000,
|
|
40
|
+
};
|
|
41
|
+
messages.value.push(item);
|
|
42
|
+
|
|
43
|
+
if (item.duration > 0) {
|
|
44
|
+
setTimeout(() => remove(id), item.duration);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return id;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 按 id 移除一条消息
|
|
52
|
+
*/
|
|
53
|
+
const remove = (id: number): void => {
|
|
54
|
+
const idx = messages.value.findIndex(m => m.id === id);
|
|
55
|
+
if (idx !== -1) {
|
|
56
|
+
messages.value.splice(idx, 1);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return { messages, add, remove };
|
|
61
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description notification runtime props 定义
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/26
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { MCOPO, MPropType } from '../../types/props';
|
|
10
|
+
import { NotificationProps, NotificationType, NotificationPosition } from './props';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 单条通知运行时 props
|
|
14
|
+
*/
|
|
15
|
+
export const notificationProps: MCOPO<NotificationProps> = {
|
|
16
|
+
title: { type: String, required: true },
|
|
17
|
+
message: { type: String, default: '' },
|
|
18
|
+
type: { type: String as MPropType<NotificationType>, default: 'info' },
|
|
19
|
+
duration: { type: Number, default: 4500 },
|
|
20
|
+
position: { type: String as MPropType<NotificationPosition>, default: 'top-right' },
|
|
21
|
+
closable: { type: Boolean, default: true },
|
|
22
|
+
offset: { type: Number, default: 16 },
|
|
23
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description notification core 导出
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/26
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { notificationProps } from './api';
|
|
10
|
+
import { useNotificationQueue } from './useNotification';
|
|
11
|
+
|
|
12
|
+
export const NotificationCore = {
|
|
13
|
+
notificationProps,
|
|
14
|
+
useNotificationQueue,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { useNotificationQueue } from './useNotification';
|
|
18
|
+
export type { NotificationProps, NotificationEvents, NotificationType, NotificationPosition } from './props';
|
|
19
|
+
export type { NotificationItem, NotificationAddOptions } from './useNotification';
|