@kine-design/core 0.0.1-beta.1 → 0.0.1-beta.3
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 +17 -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 +18 -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 +15 -0
- package/components/base/avatar/props.d.ts +37 -0
- package/components/base/backTop/api.ts +17 -0
- package/components/base/backTop/index.ts +17 -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 +17 -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 +149 -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 +17 -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 +18 -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 +18 -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 +17 -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 +17 -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 +15 -0
- package/components/base/li/props.d.ts +30 -0
- package/components/base/list/api.ts +16 -0
- package/components/base/list/index.ts +17 -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 +17 -0
- package/components/base/popover/props.d.ts +73 -0
- package/components/base/popover/usePopover.ts +192 -0
- package/components/base/progress/api.ts +18 -0
- package/components/base/progress/index.ts +17 -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 +17 -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 +17 -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 +19 -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 +15 -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 +234 -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 +18 -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 +19 -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 +17 -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 +89 -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/index.d.ts +2 -1
- package/dist/components/base/affix/useAffix.d.ts +6 -5
- package/dist/components/base/anchor/index.d.ts +2 -1
- package/dist/components/base/anchor/useAnchor.d.ts +2 -2
- package/dist/components/base/autoComplete/useAutoComplete.d.ts +12 -4
- package/dist/components/base/avatar/index.d.ts +1 -0
- package/dist/components/base/backTop/index.d.ts +2 -1
- package/dist/components/base/backTop/useBackTop.d.ts +2 -2
- package/dist/components/base/button/index.d.ts +3 -21
- package/dist/components/base/button/useButton.d.ts +5 -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/index.d.ts +2 -1
- package/dist/components/base/checkbox/useCheckbox.d.ts +4 -3
- package/dist/components/base/collapse/index.d.ts +2 -1
- package/dist/components/base/collapse/useCollapse.d.ts +3 -3
- package/dist/components/base/datePicker/useDatePicker.d.ts +140 -8
- package/dist/components/base/dropdown/index.d.ts +2 -1
- package/dist/components/base/dropdown/useDropdown.d.ts +12 -6
- package/dist/components/base/image/useImage.d.ts +5 -5
- package/dist/components/base/input/index.d.ts +2 -1
- package/dist/components/base/input/useInput.d.ts +1 -2
- package/dist/components/base/inputNumber/index.d.ts +2 -1
- package/dist/components/base/inputNumber/useInputNumber.d.ts +3 -3
- package/dist/components/base/li/index.d.ts +1 -0
- package/dist/components/base/list/index.d.ts +2 -1
- package/dist/components/base/list/useList.d.ts +1 -1
- package/dist/components/base/popover/index.d.ts +2 -1
- package/dist/components/base/popover/usePopover.d.ts +9 -9
- package/dist/components/base/progress/index.d.ts +2 -1
- package/dist/components/base/progress/useProgress.d.ts +2 -2
- package/dist/components/base/rate/index.d.ts +2 -1
- package/dist/components/base/rate/useRate.d.ts +2 -2
- package/dist/components/base/select/useSelect.d.ts +8 -8
- package/dist/components/base/slider/index.d.ts +2 -1
- package/dist/components/base/slider/useSlider.d.ts +4 -4
- 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/index.d.ts +2 -1
- package/dist/components/base/switch/useSwitch.d.ts +8 -3
- package/dist/components/base/tabs/index.d.ts +1 -1
- package/dist/components/base/tabs/useTabs.d.ts +3 -3
- package/dist/components/base/tag/index.d.ts +1 -0
- package/dist/components/base/timePicker/useTimePicker.d.ts +14 -6
- package/dist/components/base/tooltip/index.d.ts +1 -1
- package/dist/components/base/tooltip/useTooltip.d.ts +15 -5
- 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/drawer/index.d.ts +2 -2
- 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/index.d.ts +1 -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/index.d.ts +0 -1
- package/dist/components/template/menu/useMenu.d.ts +2 -1
- package/dist/components/template/pagination/index.d.ts +2 -1
- package/dist/components/template/virtualList/index.d.ts +0 -1
- 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 +6147 -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,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description timePicker core 导出
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/27
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { props } from './api';
|
|
10
|
+
import { useTimePicker } from './useTimePicker';
|
|
11
|
+
|
|
12
|
+
export const TimePickerCore = {
|
|
13
|
+
props,
|
|
14
|
+
useTimePicker,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type { TimePickerProps, TimeRefType } from './props';
|
|
18
|
+
export { useTimePicker, generateColumn } from './useTimePicker';
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description timePicker props 类型定义
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/27
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export declare type TimePickerProps = {
|
|
11
|
+
/**
|
|
12
|
+
* @description 时间值(字符串,如 "14:30:00")
|
|
13
|
+
* @type string
|
|
14
|
+
* @default ''
|
|
15
|
+
*/
|
|
16
|
+
modelValue?: string;
|
|
17
|
+
/**
|
|
18
|
+
* @description 提示文字
|
|
19
|
+
* @type string
|
|
20
|
+
* @default '请选择时间...'
|
|
21
|
+
*/
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
/**
|
|
24
|
+
* @description 时间格式
|
|
25
|
+
* @type string
|
|
26
|
+
* @default 'HH:mm:ss'
|
|
27
|
+
*/
|
|
28
|
+
format?: string;
|
|
29
|
+
/**
|
|
30
|
+
* @description 是否禁用
|
|
31
|
+
* @type boolean
|
|
32
|
+
* @default false
|
|
33
|
+
*/
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* @description 是否显示秒列
|
|
37
|
+
* @type boolean
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
showSeconds?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* @description 小时步长
|
|
43
|
+
* @type number
|
|
44
|
+
* @default 1
|
|
45
|
+
*/
|
|
46
|
+
hourStep?: number;
|
|
47
|
+
/**
|
|
48
|
+
* @description 分钟步长
|
|
49
|
+
* @type number
|
|
50
|
+
* @default 1
|
|
51
|
+
*/
|
|
52
|
+
minuteStep?: number;
|
|
53
|
+
/**
|
|
54
|
+
* @description 秒步长
|
|
55
|
+
* @type number
|
|
56
|
+
* @default 1
|
|
57
|
+
*/
|
|
58
|
+
secondStep?: number;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/** 时间内部引用 */
|
|
62
|
+
export type TimeRefType = {
|
|
63
|
+
hours: number;
|
|
64
|
+
minutes: number;
|
|
65
|
+
seconds: number;
|
|
66
|
+
};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description timePicker 核心 composable
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/27
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*
|
|
9
|
+
* 纯时间数据管理,不含任何 popover 逻辑。
|
|
10
|
+
*/
|
|
11
|
+
import dayjs from 'dayjs';
|
|
12
|
+
import { computed, ref } from 'vue';
|
|
13
|
+
import { TimePickerProps, TimeRefType } from './props';
|
|
14
|
+
|
|
15
|
+
/** 简单的空值判断 */
|
|
16
|
+
const isEmpty = (value: unknown): boolean => {
|
|
17
|
+
return value === '' || value === null || value === undefined;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 生成一列可选数字数组。
|
|
22
|
+
* @param max 最大值(不含),如 24、60
|
|
23
|
+
* @param step 步长
|
|
24
|
+
*/
|
|
25
|
+
export const generateColumn = (max: number, step: number): number[] => {
|
|
26
|
+
const result: number[] = [];
|
|
27
|
+
for (let i = 0; i < max; i += step) {
|
|
28
|
+
result.push(i);
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export function useTimePicker(props: TimePickerProps) {
|
|
34
|
+
const resolvedProps = props as Required<TimePickerProps>;
|
|
35
|
+
|
|
36
|
+
/** 内部时间状态 */
|
|
37
|
+
const timeRef = ref<TimeRefType>({
|
|
38
|
+
hours: 0,
|
|
39
|
+
minutes: 0,
|
|
40
|
+
seconds: 0,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
/** trigger 显示的格式化文本 */
|
|
44
|
+
const displayValue = ref('');
|
|
45
|
+
|
|
46
|
+
/** trigger span 的 class 列表(含 placeholder 状态) */
|
|
47
|
+
const spanClass = ref<Array<string | undefined>>([]);
|
|
48
|
+
|
|
49
|
+
/** 是否处于 placeholder 状态 */
|
|
50
|
+
let needPlaceholder = false;
|
|
51
|
+
|
|
52
|
+
/** 根据 showSeconds 和 format prop 计算实际使用的时间格式 */
|
|
53
|
+
const format = computed(() => {
|
|
54
|
+
if (resolvedProps.format) return resolvedProps.format;
|
|
55
|
+
return resolvedProps.showSeconds ? 'HH:mm:ss' : 'HH:mm';
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
/** 生成时列数据 */
|
|
59
|
+
const hoursColumn = computed(() => generateColumn(24, resolvedProps.hourStep));
|
|
60
|
+
/** 生成分列数据 */
|
|
61
|
+
const minutesColumn = computed(() => generateColumn(60, resolvedProps.minuteStep));
|
|
62
|
+
/** 生成秒列数据 */
|
|
63
|
+
const secondsColumn = computed(() => generateColumn(60, resolvedProps.secondStep));
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 根据传入值更新内部状态。
|
|
67
|
+
* 支持 "HH:mm:ss"、"HH:mm" 格式字符串。
|
|
68
|
+
*/
|
|
69
|
+
const updateTimeRef = (value: string | undefined) => {
|
|
70
|
+
if (isEmpty(value)) {
|
|
71
|
+
displayValue.value = resolvedProps.placeholder ?? '请选择时间...';
|
|
72
|
+
needPlaceholder = true;
|
|
73
|
+
} else {
|
|
74
|
+
needPlaceholder = false;
|
|
75
|
+
// 用 dayjs 解析任意时间格式
|
|
76
|
+
const parsed = dayjs(`2000-01-01 ${value}`);
|
|
77
|
+
if (parsed.isValid()) {
|
|
78
|
+
timeRef.value = {
|
|
79
|
+
hours: parsed.hour(),
|
|
80
|
+
minutes: parsed.minute(),
|
|
81
|
+
seconds: parsed.second(),
|
|
82
|
+
};
|
|
83
|
+
displayValue.value = parsed.format(format.value);
|
|
84
|
+
} else {
|
|
85
|
+
// 兜底:尝试手动解析 HH:mm[:ss]
|
|
86
|
+
const parts = (value as string).split(':').map(Number);
|
|
87
|
+
if (parts.length >= 2 && !isNaN(parts[0]) && !isNaN(parts[1])) {
|
|
88
|
+
timeRef.value = {
|
|
89
|
+
hours: parts[0],
|
|
90
|
+
minutes: parts[1],
|
|
91
|
+
seconds: parts[2] ?? 0,
|
|
92
|
+
};
|
|
93
|
+
displayValue.value = formatTime(timeRef.value);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
spanClass.value = [
|
|
98
|
+
'm-time-picker-span',
|
|
99
|
+
needPlaceholder ? 'm-time-picker-placeholder' : undefined,
|
|
100
|
+
];
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/** 将 TimeRefType 格式化为字符串 */
|
|
104
|
+
const formatTime = (time: TimeRefType): string => {
|
|
105
|
+
const d = dayjs()
|
|
106
|
+
.set('hour', time.hours)
|
|
107
|
+
.set('minute', time.minutes)
|
|
108
|
+
.set('second', time.seconds);
|
|
109
|
+
return d.format(format.value);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/** 选择小时 */
|
|
113
|
+
const selectHour = (hour: number) => {
|
|
114
|
+
timeRef.value = { ...timeRef.value, hours: hour };
|
|
115
|
+
needPlaceholder = false;
|
|
116
|
+
displayValue.value = formatTime(timeRef.value);
|
|
117
|
+
spanClass.value = ['m-time-picker-span'];
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/** 选择分钟 */
|
|
121
|
+
const selectMinute = (minute: number) => {
|
|
122
|
+
timeRef.value = { ...timeRef.value, minutes: minute };
|
|
123
|
+
needPlaceholder = false;
|
|
124
|
+
displayValue.value = formatTime(timeRef.value);
|
|
125
|
+
spanClass.value = ['m-time-picker-span'];
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
/** 选择秒 */
|
|
129
|
+
const selectSecond = (second: number) => {
|
|
130
|
+
timeRef.value = { ...timeRef.value, seconds: second };
|
|
131
|
+
needPlaceholder = false;
|
|
132
|
+
displayValue.value = formatTime(timeRef.value);
|
|
133
|
+
spanClass.value = ['m-time-picker-span'];
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/** 获取当前格式化后的时间值(用于 emit) */
|
|
137
|
+
const getValue = (): string => {
|
|
138
|
+
return formatTime(timeRef.value);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// 初始化
|
|
142
|
+
updateTimeRef(resolvedProps.modelValue);
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
// 状态
|
|
146
|
+
timeRef,
|
|
147
|
+
displayValue,
|
|
148
|
+
spanClass,
|
|
149
|
+
// 列数据
|
|
150
|
+
hoursColumn,
|
|
151
|
+
minutesColumn,
|
|
152
|
+
secondsColumn,
|
|
153
|
+
// 方法
|
|
154
|
+
updateTimeRef,
|
|
155
|
+
selectHour,
|
|
156
|
+
selectMinute,
|
|
157
|
+
selectSecond,
|
|
158
|
+
getValue,
|
|
159
|
+
formatTime,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description timeline api
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/26
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { MCOPO, MPropType } from '../../types/props';
|
|
10
|
+
import { TimelineProps, TimelineItemProps } from './props';
|
|
11
|
+
|
|
12
|
+
export const timelineProps: MCOPO<TimelineProps> = {
|
|
13
|
+
reverse: { type: Boolean, default: false },
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const timelineItemProps: MCOPO<TimelineItemProps> = {
|
|
17
|
+
timestamp: { type: String, default: '' },
|
|
18
|
+
hideTimestamp: { type: Boolean, default: false },
|
|
19
|
+
placement: { type: String as MPropType<'top' | 'bottom'>, default: 'bottom' },
|
|
20
|
+
type: { type: String as MPropType<'primary' | 'success' | 'warning' | 'danger' | 'info'>, default: 'primary' },
|
|
21
|
+
size: { type: String as MPropType<'normal' | 'large'>, default: 'normal' },
|
|
22
|
+
icon: { type: String, default: '' },
|
|
23
|
+
hollow: { type: Boolean, default: false },
|
|
24
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description timeline core 导出
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/26
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { timelineProps, timelineItemProps } from './api';
|
|
10
|
+
|
|
11
|
+
export const TimelineCore = {
|
|
12
|
+
timelineProps,
|
|
13
|
+
timelineItemProps,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type { TimelineProps, TimelineItemProps } from './props';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description timeline api type
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/26
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export declare type TimelineProps = {
|
|
11
|
+
/**
|
|
12
|
+
* @description 是否倒序排列
|
|
13
|
+
* @type boolean
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
reverse?: boolean,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export declare type TimelineItemProps = {
|
|
20
|
+
/**
|
|
21
|
+
* @description 时间戳文本
|
|
22
|
+
* @type string
|
|
23
|
+
*/
|
|
24
|
+
timestamp?: string,
|
|
25
|
+
/**
|
|
26
|
+
* @description 是否隐藏时间戳
|
|
27
|
+
* @type boolean
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
hideTimestamp?: boolean,
|
|
31
|
+
/**
|
|
32
|
+
* @description 时间戳相对内容的位置
|
|
33
|
+
* @type 'top' | 'bottom'
|
|
34
|
+
* @default 'bottom'
|
|
35
|
+
*/
|
|
36
|
+
placement?: 'top' | 'bottom',
|
|
37
|
+
/**
|
|
38
|
+
* @description 节点类型,影响圆点颜色
|
|
39
|
+
* @type 'primary' | 'success' | 'warning' | 'danger' | 'info'
|
|
40
|
+
* @default 'primary'
|
|
41
|
+
*/
|
|
42
|
+
type?: 'primary' | 'success' | 'warning' | 'danger' | 'info',
|
|
43
|
+
/**
|
|
44
|
+
* @description 节点尺寸
|
|
45
|
+
* @type 'normal' | 'large'
|
|
46
|
+
* @default 'normal'
|
|
47
|
+
*/
|
|
48
|
+
size?: 'normal' | 'large',
|
|
49
|
+
/**
|
|
50
|
+
* @description 自定义图标(图标名或内容,由消费层解释)
|
|
51
|
+
* @type string
|
|
52
|
+
*/
|
|
53
|
+
icon?: string,
|
|
54
|
+
/**
|
|
55
|
+
* @description 是否为空心圆点
|
|
56
|
+
* @type boolean
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
hollow?: boolean,
|
|
60
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description tooltip 运行时 props
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/25
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { TooltipProps } from './props';
|
|
10
|
+
import { MCOPO, MPropType } from '../../types/props';
|
|
11
|
+
|
|
12
|
+
export const props: MCOPO<TooltipProps> = {
|
|
13
|
+
content: { type: String, default: '' },
|
|
14
|
+
placement: {
|
|
15
|
+
type: String as MPropType<NonNullable<TooltipProps['placement']>>,
|
|
16
|
+
default: 'top',
|
|
17
|
+
},
|
|
18
|
+
disabled: { type: Boolean, default: false },
|
|
19
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description tooltip core 导出
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/25
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { props } from './api';
|
|
10
|
+
import { useTooltip } from './useTooltip';
|
|
11
|
+
|
|
12
|
+
export const TooltipCore = {
|
|
13
|
+
props,
|
|
14
|
+
useTooltip,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type { TooltipProps } from './props';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description tooltip 类型定义
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/25
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* @name m-tooltip
|
|
8
|
+
* @docDescription Tooltip component.
|
|
9
|
+
* 文字提示组件。
|
|
10
|
+
* @docUrl https://shuimo.design/tooltip
|
|
11
|
+
*
|
|
12
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export declare type TooltipProps = {
|
|
16
|
+
/**
|
|
17
|
+
* @description 提示内容,简单文本可直接通过 prop 传入
|
|
18
|
+
* @type string
|
|
19
|
+
* @default ''
|
|
20
|
+
*/
|
|
21
|
+
content?: string;
|
|
22
|
+
/**
|
|
23
|
+
* @description 弹出位置
|
|
24
|
+
* @type 'top' | 'bottom' | 'left' | 'right'
|
|
25
|
+
* @default 'top'
|
|
26
|
+
*/
|
|
27
|
+
placement?: 'top' | 'bottom' | 'left' | 'right';
|
|
28
|
+
/**
|
|
29
|
+
* @description 是否禁用
|
|
30
|
+
* @type boolean
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description tooltip composable,管理 hover 显示/隐藏及定位
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/25
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { ref, nextTick } from 'vue';
|
|
10
|
+
import { TooltipProps } from './props';
|
|
11
|
+
|
|
12
|
+
export type TooltipStyle = {
|
|
13
|
+
position: string;
|
|
14
|
+
left: string;
|
|
15
|
+
top: string;
|
|
16
|
+
zIndex: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 根据 trigger 元素的 getBoundingClientRect 和 placement 计算 tooltip 的 fixed 定位样式
|
|
21
|
+
*/
|
|
22
|
+
function calcPosition(
|
|
23
|
+
rect: DOMRect,
|
|
24
|
+
tooltipEl: HTMLElement,
|
|
25
|
+
placement: NonNullable<TooltipProps['placement']>,
|
|
26
|
+
): TooltipStyle {
|
|
27
|
+
const gap = 8;
|
|
28
|
+
const tooltipRect = tooltipEl.getBoundingClientRect();
|
|
29
|
+
let left = 0;
|
|
30
|
+
let top = 0;
|
|
31
|
+
|
|
32
|
+
switch (placement) {
|
|
33
|
+
case 'top':
|
|
34
|
+
left = rect.left + rect.width / 2 - tooltipRect.width / 2;
|
|
35
|
+
top = rect.top - tooltipRect.height - gap;
|
|
36
|
+
break;
|
|
37
|
+
case 'bottom':
|
|
38
|
+
left = rect.left + rect.width / 2 - tooltipRect.width / 2;
|
|
39
|
+
top = rect.bottom + gap;
|
|
40
|
+
break;
|
|
41
|
+
case 'left':
|
|
42
|
+
left = rect.left - tooltipRect.width - gap;
|
|
43
|
+
top = rect.top + rect.height / 2 - tooltipRect.height / 2;
|
|
44
|
+
break;
|
|
45
|
+
case 'right':
|
|
46
|
+
left = rect.right + gap;
|
|
47
|
+
top = rect.top + rect.height / 2 - tooltipRect.height / 2;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
position: 'fixed',
|
|
53
|
+
left: `${left}px`,
|
|
54
|
+
top: `${top}px`,
|
|
55
|
+
zIndex: '9999',
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function useTooltip(props: Required<TooltipProps>) {
|
|
60
|
+
const visible = ref(false);
|
|
61
|
+
const tooltipStyle = ref<TooltipStyle | Record<string, never>>({});
|
|
62
|
+
|
|
63
|
+
const triggerRef = ref<HTMLElement | null>(null);
|
|
64
|
+
const tooltipRef = ref<HTMLElement | null>(null);
|
|
65
|
+
|
|
66
|
+
const show = async () => {
|
|
67
|
+
if (props.disabled) return;
|
|
68
|
+
visible.value = true;
|
|
69
|
+
// 等待 tooltip DOM 渲染后再计算位置
|
|
70
|
+
await nextTick();
|
|
71
|
+
if (!triggerRef.value || !tooltipRef.value) return;
|
|
72
|
+
const rect = triggerRef.value.getBoundingClientRect();
|
|
73
|
+
tooltipStyle.value = calcPosition(rect, tooltipRef.value, props.placement);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const hide = () => {
|
|
77
|
+
visible.value = false;
|
|
78
|
+
tooltipStyle.value = {};
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
visible,
|
|
83
|
+
tooltipStyle,
|
|
84
|
+
triggerRef,
|
|
85
|
+
tooltipRef,
|
|
86
|
+
show,
|
|
87
|
+
hide,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description transfer api
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/26
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { MCOPO, MPropType } from '../../types/props';
|
|
10
|
+
import { TransferProps, TransferItem } from './props';
|
|
11
|
+
|
|
12
|
+
export const props: MCOPO<TransferProps> = {
|
|
13
|
+
modelValue: { type: Array as MPropType<(string | number)[]>, default: () => [] },
|
|
14
|
+
data: { type: Array as MPropType<TransferItem[]>, default: () => [] },
|
|
15
|
+
titles: { type: Array as unknown as MPropType<[string, string]>, default: () => ['源列表', '目标列表'] },
|
|
16
|
+
filterable: { type: Boolean, default: false },
|
|
17
|
+
filterPlaceholder: { type: String, default: '请输入搜索内容' },
|
|
18
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description transfer core 导出
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/26
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
import { props } from './api';
|
|
10
|
+
import { useTransfer } from './useTransfer';
|
|
11
|
+
|
|
12
|
+
export const TransferCore = {
|
|
13
|
+
props,
|
|
14
|
+
useTransfer,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type { TransferProps, TransferItem } from './props';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description transfer api type
|
|
3
|
+
* @author 阿怪
|
|
4
|
+
* @date 2026/2/26
|
|
5
|
+
* @version v1.0.0
|
|
6
|
+
*
|
|
7
|
+
* 江湖的业务千篇一律,复杂的代码好几百行。
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 穿梭框的数据项
|
|
12
|
+
*/
|
|
13
|
+
export declare type TransferItem = {
|
|
14
|
+
/**
|
|
15
|
+
* @description 数据项唯一标识
|
|
16
|
+
* @type string | number
|
|
17
|
+
*/
|
|
18
|
+
key: string | number;
|
|
19
|
+
/**
|
|
20
|
+
* @description 数据项显示文本
|
|
21
|
+
* @type string
|
|
22
|
+
*/
|
|
23
|
+
label: string;
|
|
24
|
+
/**
|
|
25
|
+
* @description 是否禁用该项
|
|
26
|
+
* @type boolean
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export declare type TransferProps = {
|
|
33
|
+
/**
|
|
34
|
+
* @description 右侧已选中的数据 key 列表
|
|
35
|
+
* @type (string | number)[]
|
|
36
|
+
* @default []
|
|
37
|
+
*/
|
|
38
|
+
modelValue?: (string | number)[];
|
|
39
|
+
/**
|
|
40
|
+
* @description 数据源
|
|
41
|
+
* @type TransferItem[]
|
|
42
|
+
* @default []
|
|
43
|
+
*/
|
|
44
|
+
data?: TransferItem[];
|
|
45
|
+
/**
|
|
46
|
+
* @description 左右栏的标题
|
|
47
|
+
* @type [string, string]
|
|
48
|
+
* @default ['源列表', '目标列表']
|
|
49
|
+
*/
|
|
50
|
+
titles?: [string, string];
|
|
51
|
+
/**
|
|
52
|
+
* @description 是否可搜索
|
|
53
|
+
* @type boolean
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
filterable?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* @description 搜索框占位文本
|
|
59
|
+
* @type string
|
|
60
|
+
* @default '请输入搜索内容'
|
|
61
|
+
*/
|
|
62
|
+
filterPlaceholder?: string;
|
|
63
|
+
};
|