@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.
Files changed (300) hide show
  1. package/assets/style/global.css +1 -0
  2. package/assets/style/var/Wuxing.css +71 -0
  3. package/assets/style/var.css +23 -0
  4. package/components/base/affix/api.ts +16 -0
  5. package/components/base/affix/index.ts +15 -0
  6. package/components/base/affix/props.d.ts +34 -0
  7. package/components/base/affix/useAffix.ts +123 -0
  8. package/components/base/alert/api.ts +18 -0
  9. package/components/base/alert/index.ts +15 -0
  10. package/components/base/alert/props.d.ts +50 -0
  11. package/components/base/anchor/api.ts +20 -0
  12. package/components/base/anchor/index.ts +16 -0
  13. package/components/base/anchor/props.d.ts +46 -0
  14. package/components/base/anchor/useAnchor.ts +83 -0
  15. package/components/base/autoComplete/api.ts +24 -0
  16. package/components/base/autoComplete/index.ts +17 -0
  17. package/components/base/autoComplete/props.d.ts +75 -0
  18. package/components/base/autoComplete/useAutoComplete.ts +149 -0
  19. package/components/base/avatar/api.ts +17 -0
  20. package/components/base/avatar/avatar.css +61 -0
  21. package/components/base/avatar/index.ts +14 -0
  22. package/components/base/avatar/props.d.ts +37 -0
  23. package/components/base/backTop/api.ts +17 -0
  24. package/components/base/backTop/index.ts +15 -0
  25. package/components/base/backTop/props.d.ts +38 -0
  26. package/components/base/backTop/useBackTop.ts +62 -0
  27. package/components/base/badge/api.ts +22 -0
  28. package/components/base/badge/index.ts +15 -0
  29. package/components/base/badge/props.d.ts +50 -0
  30. package/components/base/button/api.ts +28 -0
  31. package/components/base/button/button.css +34 -0
  32. package/components/base/button/index.ts +16 -0
  33. package/components/base/button/props.d.ts +64 -0
  34. package/components/base/button/useButton.ts +37 -0
  35. package/components/base/card/api.ts +17 -0
  36. package/components/base/card/index.ts +15 -0
  37. package/components/base/card/props.d.ts +37 -0
  38. package/components/base/carousel/api.ts +28 -0
  39. package/components/base/carousel/index.ts +17 -0
  40. package/components/base/carousel/props.d.ts +72 -0
  41. package/components/base/carousel/useCarousel.ts +151 -0
  42. package/components/base/cascader/api.ts +23 -0
  43. package/components/base/cascader/index.ts +18 -0
  44. package/components/base/cascader/props.d.ts +103 -0
  45. package/components/base/cascader/useCascader.ts +334 -0
  46. package/components/base/checkbox/api.ts +24 -0
  47. package/components/base/checkbox/checkbox.css +0 -0
  48. package/components/base/checkbox/index.ts +16 -0
  49. package/components/base/checkbox/props.d.ts +77 -0
  50. package/components/base/checkbox/useCheckbox.ts +42 -0
  51. package/components/base/collapse/api.ts +21 -0
  52. package/components/base/collapse/index.ts +16 -0
  53. package/components/base/collapse/props.d.ts +45 -0
  54. package/components/base/collapse/useCollapse.ts +80 -0
  55. package/components/base/datePicker/api.ts +18 -0
  56. package/components/base/datePicker/index.ts +19 -0
  57. package/components/base/datePicker/props.d.ts +60 -0
  58. package/components/base/datePicker/useDatePicker.ts +392 -0
  59. package/components/base/divider/api.ts +15 -0
  60. package/components/base/divider/divider.css +11 -0
  61. package/components/base/divider/index.ts +15 -0
  62. package/components/base/divider/props.d.ts +30 -0
  63. package/components/base/dropdown/api.ts +33 -0
  64. package/components/base/dropdown/index.ts +16 -0
  65. package/components/base/dropdown/props.d.ts +60 -0
  66. package/components/base/dropdown/useDropdown.ts +123 -0
  67. package/components/base/empty/api.ts +15 -0
  68. package/components/base/empty/index.ts +15 -0
  69. package/components/base/empty/props.d.ts +26 -0
  70. package/components/base/image/api.ts +25 -0
  71. package/components/base/image/index.ts +18 -0
  72. package/components/base/image/props.d.ts +67 -0
  73. package/components/base/image/useImage.ts +119 -0
  74. package/components/base/input/api.ts +19 -0
  75. package/components/base/input/index.ts +16 -0
  76. package/components/base/input/input.css +19 -0
  77. package/components/base/input/props.d.ts +60 -0
  78. package/components/base/input/useInput.ts +53 -0
  79. package/components/base/inputNumber/api.ts +21 -0
  80. package/components/base/inputNumber/index.ts +15 -0
  81. package/components/base/inputNumber/props.d.ts +64 -0
  82. package/components/base/inputNumber/useInputNumber.ts +140 -0
  83. package/components/base/li/api.ts +15 -0
  84. package/components/base/li/index.ts +13 -0
  85. package/components/base/li/props.d.ts +30 -0
  86. package/components/base/list/api.ts +16 -0
  87. package/components/base/list/index.ts +15 -0
  88. package/components/base/list/props.d.ts +33 -0
  89. package/components/base/list/useList.ts +36 -0
  90. package/components/base/loading/api.ts +17 -0
  91. package/components/base/loading/index.ts +15 -0
  92. package/components/base/loading/props.d.ts +38 -0
  93. package/components/base/popover/api.ts +28 -0
  94. package/components/base/popover/index.ts +15 -0
  95. package/components/base/popover/props.d.ts +73 -0
  96. package/components/base/popover/usePopover.ts +188 -0
  97. package/components/base/progress/api.ts +18 -0
  98. package/components/base/progress/index.ts +15 -0
  99. package/components/base/progress/props.d.ts +53 -0
  100. package/components/base/progress/useProgress.ts +28 -0
  101. package/components/base/radio/api.ts +19 -0
  102. package/components/base/radio/index.ts +19 -0
  103. package/components/base/radio/props.d.ts +59 -0
  104. package/components/base/radio/useRadio.ts +11 -0
  105. package/components/base/rate/api.ts +18 -0
  106. package/components/base/rate/index.ts +15 -0
  107. package/components/base/rate/props.d.ts +49 -0
  108. package/components/base/rate/useRate.ts +75 -0
  109. package/components/base/result/api.ts +20 -0
  110. package/components/base/result/index.ts +15 -0
  111. package/components/base/result/props.d.ts +36 -0
  112. package/components/base/select/api.ts +31 -0
  113. package/components/base/select/index.ts +18 -0
  114. package/components/base/select/props.d.ts +132 -0
  115. package/components/base/select/select.css +7 -0
  116. package/components/base/select/useSelect.ts +280 -0
  117. package/components/base/select/useSelectTools.ts +60 -0
  118. package/components/base/skeleton/api.ts +18 -0
  119. package/components/base/skeleton/index.ts +15 -0
  120. package/components/base/skeleton/props.d.ts +41 -0
  121. package/components/base/slider/api.ts +20 -0
  122. package/components/base/slider/index.ts +15 -0
  123. package/components/base/slider/props.d.ts +65 -0
  124. package/components/base/slider/useSlider.ts +83 -0
  125. package/components/base/space/api.ts +17 -0
  126. package/components/base/space/index.ts +15 -0
  127. package/components/base/space/props.d.ts +39 -0
  128. package/components/base/steps/api.ts +30 -0
  129. package/components/base/steps/index.ts +22 -0
  130. package/components/base/steps/props.d.ts +88 -0
  131. package/components/base/steps/useSteps.ts +101 -0
  132. package/components/base/switch/api.ts +22 -0
  133. package/components/base/switch/index.ts +17 -0
  134. package/components/base/switch/props.d.ts +66 -0
  135. package/components/base/switch/useSwitch.tsx +79 -0
  136. package/components/base/tabs/api.ts +23 -0
  137. package/components/base/tabs/index.ts +18 -0
  138. package/components/base/tabs/props.d.ts +41 -0
  139. package/components/base/tabs/useTabs.ts +66 -0
  140. package/components/base/tag/api.ts +17 -0
  141. package/components/base/tag/index.ts +13 -0
  142. package/components/base/tag/props.d.ts +49 -0
  143. package/components/base/timePicker/api.ts +21 -0
  144. package/components/base/timePicker/index.ts +18 -0
  145. package/components/base/timePicker/props.d.ts +66 -0
  146. package/components/base/timePicker/useTimePicker.ts +161 -0
  147. package/components/base/timeline/api.ts +24 -0
  148. package/components/base/timeline/index.ts +16 -0
  149. package/components/base/timeline/props.d.ts +60 -0
  150. package/components/base/tooltip/api.ts +19 -0
  151. package/components/base/tooltip/index.ts +17 -0
  152. package/components/base/tooltip/props.d.ts +34 -0
  153. package/components/base/tooltip/useTooltip.ts +89 -0
  154. package/components/base/transfer/api.ts +18 -0
  155. package/components/base/transfer/index.ts +17 -0
  156. package/components/base/transfer/props.d.ts +63 -0
  157. package/components/base/transfer/useTransfer.ts +207 -0
  158. package/components/base/tree/api.ts +47 -0
  159. package/components/base/tree/index.ts +29 -0
  160. package/components/base/tree/props.d.ts +108 -0
  161. package/components/base/tree/tree.ts +263 -0
  162. package/components/base/tree/useTree.ts +114 -0
  163. package/components/message/confirm/api.ts +21 -0
  164. package/components/message/confirm/index.ts +15 -0
  165. package/components/message/confirm/props.d.ts +69 -0
  166. package/components/message/dialog/api.ts +19 -0
  167. package/components/message/dialog/index.ts +15 -0
  168. package/components/message/dialog/props.d.ts +55 -0
  169. package/components/message/drawer/api.ts +32 -0
  170. package/components/message/drawer/index.ts +15 -0
  171. package/components/message/drawer/props.d.ts +73 -0
  172. package/components/message/message/api.ts +27 -0
  173. package/components/message/message/index.ts +20 -0
  174. package/components/message/message/props.d.ts +54 -0
  175. package/components/message/message/useMessage.ts +61 -0
  176. package/components/message/notification/api.ts +23 -0
  177. package/components/message/notification/index.ts +19 -0
  178. package/components/message/notification/props.d.ts +64 -0
  179. package/components/message/notification/useNotification.ts +79 -0
  180. package/components/message/popover/MPopover.tsx +94 -0
  181. package/components/message/popover/api.ts +54 -0
  182. package/components/message/popover/index.ts +17 -0
  183. package/components/message/popover/popover.css +21 -0
  184. package/components/message/popover/props.d.ts +76 -0
  185. package/components/message/popover/usePopover.ts +230 -0
  186. package/components/other/darkMode/api.ts +17 -0
  187. package/components/other/darkMode/index.ts +17 -0
  188. package/components/other/darkMode/props.d.ts +37 -0
  189. package/components/other/darkMode/useDarkMode.ts +129 -0
  190. package/components/template/border/api.ts +18 -0
  191. package/components/template/border/index.ts +15 -0
  192. package/components/template/border/props.d.ts +41 -0
  193. package/components/template/breadcrumb/api.ts +15 -0
  194. package/components/template/breadcrumb/index.ts +15 -0
  195. package/components/template/breadcrumb/props.d.ts +45 -0
  196. package/components/template/descriptions/api.ts +23 -0
  197. package/components/template/descriptions/index.ts +16 -0
  198. package/components/template/descriptions/props.d.ts +54 -0
  199. package/components/template/form/api.ts +23 -0
  200. package/components/template/form/index.ts +20 -0
  201. package/components/template/form/props.d.ts +60 -0
  202. package/components/template/grid/api.ts +20 -0
  203. package/components/template/grid/index.ts +15 -0
  204. package/components/template/grid/props.d.ts +48 -0
  205. package/components/template/menu/api.ts +26 -0
  206. package/components/template/menu/index.ts +19 -0
  207. package/components/template/menu/props.d.ts +93 -0
  208. package/components/template/menu/useMenu.ts +155 -0
  209. package/components/template/pagination/api.ts +22 -0
  210. package/components/template/pagination/index.ts +18 -0
  211. package/components/template/pagination/props.d.ts +65 -0
  212. package/components/template/pagination/usePagination.ts +186 -0
  213. package/components/template/table/api.ts +18 -0
  214. package/components/template/table/index.ts +18 -0
  215. package/components/template/table/props.d.ts +36 -0
  216. package/components/template/table/useTable.ts +138 -0
  217. package/components/template/tableColumn/api.ts +17 -0
  218. package/components/template/tableColumn/index.ts +15 -0
  219. package/components/template/tableColumn/props.d.ts +32 -0
  220. package/components/template/virtualList/api.ts +16 -0
  221. package/components/template/virtualList/index.ts +18 -0
  222. package/components/template/virtualList/props.d.ts +25 -0
  223. package/components/template/virtualList/useVirtualList.ts +237 -0
  224. package/components/types/hook.d.ts +13 -0
  225. package/components/types/props.d.ts +52 -0
  226. package/components/types/template.d.ts +59 -0
  227. package/compositions/common/defineCore.ts +55 -0
  228. package/compositions/common/useDebounceFn.ts +27 -0
  229. package/compositions/common/useDrag.ts +65 -0
  230. package/compositions/common/useElementSize.ts +37 -0
  231. package/compositions/common/useEventListener.ts +48 -0
  232. package/compositions/common/usePopover.ts +45 -0
  233. package/compositions/common/useResizeObserver.ts +43 -0
  234. package/compositions/common/useTeleport.ts +24 -0
  235. package/compositions/input/useBooleanInput.ts +52 -0
  236. package/compositions/modal/useModal.ts +72 -0
  237. package/compositions/popper/useClickAway.ts +41 -0
  238. package/compositions/popper/usePopper.ts +63 -0
  239. package/compositions/utils/filters.ts +135 -0
  240. package/compositions/virtualList/enums.ts +52 -0
  241. package/compositions/virtualList/useContainerObserver.ts +82 -0
  242. package/compositions/virtualList/useEntries.ts +248 -0
  243. package/compositions/virtualList/useHeightCache.ts +83 -0
  244. package/compositions/virtualList/useSentinelObserver.ts +81 -0
  245. package/dist/components/base/affix/useAffix.d.ts +5 -4
  246. package/dist/components/base/anchor/useAnchor.d.ts +1 -1
  247. package/dist/components/base/autoComplete/useAutoComplete.d.ts +12 -4
  248. package/dist/components/base/backTop/useBackTop.d.ts +1 -1
  249. package/dist/components/base/button/index.d.ts +11 -2
  250. package/dist/components/base/button/useButton.d.ts +11 -2
  251. package/dist/components/base/carousel/useCarousel.d.ts +6 -3
  252. package/dist/components/base/cascader/useCascader.d.ts +23 -11
  253. package/dist/components/base/checkbox/useCheckbox.d.ts +4 -3
  254. package/dist/components/base/collapse/useCollapse.d.ts +2 -2
  255. package/dist/components/base/datePicker/useDatePicker.d.ts +140 -8
  256. package/dist/components/base/dropdown/useDropdown.d.ts +11 -5
  257. package/dist/components/base/image/useImage.d.ts +5 -5
  258. package/dist/components/base/input/useInput.d.ts +1 -2
  259. package/dist/components/base/inputNumber/useInputNumber.d.ts +2 -2
  260. package/dist/components/base/popover/usePopover.d.ts +8 -8
  261. package/dist/components/base/progress/useProgress.d.ts +1 -1
  262. package/dist/components/base/rate/useRate.d.ts +1 -1
  263. package/dist/components/base/select/useSelect.d.ts +8 -8
  264. package/dist/components/base/slider/useSlider.d.ts +3 -3
  265. package/dist/components/base/steps/index.d.ts +1 -1
  266. package/dist/components/base/steps/useSteps.d.ts +5 -5
  267. package/dist/components/base/switch/useSwitch.d.ts +8 -3
  268. package/dist/components/base/tabs/useTabs.d.ts +2 -2
  269. package/dist/components/base/timePicker/useTimePicker.d.ts +14 -6
  270. package/dist/components/base/tooltip/useTooltip.d.ts +14 -4
  271. package/dist/components/base/transfer/useTransfer.d.ts +15 -15
  272. package/dist/components/base/tree/index.d.ts +1 -1
  273. package/dist/components/base/tree/useTree.d.ts +2 -1
  274. package/dist/components/message/message/useMessage.d.ts +11 -1
  275. package/dist/components/message/notification/useNotification.d.ts +17 -1
  276. package/dist/components/message/popover/MPopover.d.ts +6 -1
  277. package/dist/components/message/popover/usePopover.d.ts +6 -6
  278. package/dist/components/other/darkMode/useDarkMode.d.ts +1 -1
  279. package/dist/components/template/menu/useMenu.d.ts +1 -0
  280. package/dist/components/template/virtualList/useVirtualList.d.ts +10 -7
  281. package/dist/compositions/common/useDrag.d.ts +1 -1
  282. package/dist/compositions/common/useElementSize.d.ts +2 -2
  283. package/dist/compositions/common/useTeleport.d.ts +4 -2
  284. package/dist/compositions/modal/useModal.d.ts +1 -1
  285. package/dist/core.js +6137 -4186
  286. package/dist/runtime/defineHook.d.ts +1 -1
  287. package/index.css +1 -0
  288. package/index.ts +71 -0
  289. package/package.json +19 -16
  290. package/runtime/defineHook.ts +21 -0
  291. package/tools/empty.ts +81 -0
  292. package/tools/index.ts +15 -0
  293. package/tools/types.ts +11 -0
  294. package/tsconfig.json +8 -0
  295. package/types/common/common.d.ts +25 -0
  296. package/types/common/model.d.ts +25 -0
  297. package/types/index.d.ts +11 -0
  298. package/types/props.d.ts +13 -0
  299. package/vite.config.build.ts +41 -0
  300. package/dist/vite.config.build.d.ts +0 -2
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @description steps 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 { StepsProps, StepProps, StepsDirection, StepStatus } from './props';
11
+
12
+ /**
13
+ * Steps 容器组件运行时 props
14
+ */
15
+ export const stepsProps: MCOPO<StepsProps> = {
16
+ active: { type: Number, default: 0 },
17
+ direction: { type: String as MPropType<StepsDirection>, default: 'horizontal' },
18
+ finishStatus: { type: String as MPropType<'success' | 'finish'>, default: 'finish' },
19
+ processStatus: { type: String as MPropType<'process' | 'finish'>, default: 'process' },
20
+ };
21
+
22
+ /**
23
+ * Step 单个步骤组件运行时 props
24
+ */
25
+ export const stepProps: MCOPO<StepProps> = {
26
+ title: { type: String, required: true },
27
+ description: { type: String, default: '' },
28
+ icon: { type: String, default: '' },
29
+ status: { type: String as MPropType<StepStatus>, default: undefined },
30
+ };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @description steps core 导出
3
+ * @author 阿怪
4
+ * @date 2026/2/26
5
+ * @version v1.0.0
6
+ *
7
+ * 江湖的业务千篇一律,复杂的代码好几百行。
8
+ */
9
+ import { stepsProps, stepProps } from './api';
10
+ import { useSteps, useStep, stepsContextKey, resolveStepStatus } from './useSteps';
11
+
12
+ export const StepsCore = {
13
+ stepsProps,
14
+ stepProps,
15
+ useSteps,
16
+ useStep,
17
+ stepsContextKey,
18
+ resolveStepStatus,
19
+ };
20
+
21
+ export type { StepsProps, StepProps, StepItem, StepStatus, StepsDirection } from './props';
22
+ export type { StepsContext } from './useSteps';
@@ -0,0 +1,88 @@
1
+ /**
2
+ * @description steps 组件 props 类型定义
3
+ * @author 阿怪
4
+ * @date 2026/2/26
5
+ * @version v1.0.0
6
+ *
7
+ * 江湖的业务千篇一律,复杂的代码好几百行。
8
+ */
9
+
10
+ /**
11
+ * 步骤状态类型
12
+ */
13
+ export type StepStatus = 'wait' | 'process' | 'finish' | 'error';
14
+
15
+ /**
16
+ * 步骤条方向
17
+ */
18
+ export type StepsDirection = 'horizontal' | 'vertical';
19
+
20
+ /**
21
+ * 单个步骤数据(用于数据驱动模式)
22
+ */
23
+ export declare type StepItem = {
24
+ /**
25
+ * @description 步骤标题
26
+ */
27
+ title: string;
28
+ /**
29
+ * @description 步骤描述
30
+ */
31
+ description?: string;
32
+ /**
33
+ * @description 自定义图标
34
+ */
35
+ icon?: string;
36
+ /**
37
+ * @description 强制指定步骤状态,不指定时由 active 自动推算
38
+ */
39
+ status?: StepStatus;
40
+ };
41
+
42
+ /**
43
+ * Steps 容器组件 props
44
+ */
45
+ export declare type StepsProps = {
46
+ /**
47
+ * @description 当前激活步骤(从 0 开始)
48
+ * @default 0
49
+ */
50
+ active?: number;
51
+ /**
52
+ * @description 步骤条方向
53
+ * @default 'horizontal'
54
+ */
55
+ direction?: StepsDirection;
56
+ /**
57
+ * @description 已完成步骤的状态
58
+ * @default 'finish'
59
+ */
60
+ finishStatus?: 'success' | 'finish';
61
+ /**
62
+ * @description 当前步骤的状态
63
+ * @default 'process'
64
+ */
65
+ processStatus?: 'process' | 'finish';
66
+ };
67
+
68
+ /**
69
+ * Step 单个步骤组件 props
70
+ */
71
+ export declare type StepProps = {
72
+ /**
73
+ * @description 步骤标题
74
+ */
75
+ title: string;
76
+ /**
77
+ * @description 步骤描述
78
+ */
79
+ description?: string;
80
+ /**
81
+ * @description 自定义图标
82
+ */
83
+ icon?: string;
84
+ /**
85
+ * @description 强制指定步骤状态,不指定时由父级 Steps 推算
86
+ */
87
+ status?: StepStatus;
88
+ };
@@ -0,0 +1,101 @@
1
+ /**
2
+ * @description steps composable
3
+ * @author 阿怪
4
+ * @date 2026/2/26
5
+ * @version v1.0.0
6
+ *
7
+ * 江湖的业务千篇一律,复杂的代码好几百行。
8
+ */
9
+ import { computed, InjectionKey, provide, inject } from 'vue';
10
+ import { StepsProps, StepStatus } from './props';
11
+
12
+ /**
13
+ * Steps 向子 Step 注入的上下文结构
14
+ */
15
+ export interface StepsContext {
16
+ /** 当前激活步骤索引 */
17
+ active: number;
18
+ /** 已完成步骤状态 */
19
+ finishStatus: 'success' | 'finish';
20
+ /** 当前步骤状态 */
21
+ processStatus: 'process' | 'finish';
22
+ /** 步骤总数(由子步骤注册后更新) */
23
+ total: number;
24
+ /** 方向 */
25
+ direction: 'horizontal' | 'vertical';
26
+ }
27
+
28
+ /** 注入键 */
29
+ export const stepsContextKey: InjectionKey<StepsContext> = Symbol('stepsContext');
30
+
31
+ /**
32
+ * Steps 容器 composable
33
+ * 负责将当前激活状态通过 provide 下发给 MStep 子组件
34
+ */
35
+ export function useSteps(props: StepsProps) {
36
+ const context: StepsContext = {
37
+ get active() { return props.active ?? 0; },
38
+ get finishStatus() { return props.finishStatus ?? 'finish'; },
39
+ get processStatus() { return props.processStatus ?? 'process'; },
40
+ get direction() { return props.direction ?? 'horizontal'; },
41
+ total: 0,
42
+ };
43
+
44
+ provide(stepsContextKey, context);
45
+
46
+ /** 容器 class 列表 */
47
+ const stepsClass = computed(() => [
48
+ 'm-steps',
49
+ `m-steps-${props.direction ?? 'horizontal'}`,
50
+ ]);
51
+
52
+ return { stepsClass, context };
53
+ }
54
+
55
+ /**
56
+ * 根据步骤索引和父级上下文推算当前步骤状态
57
+ * @param index 当前步骤序号(从 0 开始)
58
+ * @param overrideStatus 显式指定的状态,优先级最高
59
+ * @param ctx 父级 Steps 上下文
60
+ */
61
+ export function resolveStepStatus(
62
+ index: number,
63
+ overrideStatus: StepStatus | undefined,
64
+ ctx: StepsContext,
65
+ ): StepStatus {
66
+ // 显式指定时直接使用
67
+ if (overrideStatus) return overrideStatus;
68
+
69
+ const active = ctx.active;
70
+ if (index < active) return ctx.finishStatus as StepStatus;
71
+ if (index === active) return ctx.processStatus as StepStatus;
72
+ return 'wait';
73
+ }
74
+
75
+ /**
76
+ * Step 单个步骤 composable
77
+ * 从父级注入 StepsContext,计算当前步骤的状态与样式类
78
+ */
79
+ export function useStep(index: number, overrideStatus?: StepStatus) {
80
+ const ctx = inject(stepsContextKey, null);
81
+
82
+ const status = computed<StepStatus>(() => {
83
+ if (!ctx) {
84
+ // 未嵌套在 Steps 中时默认为 wait
85
+ return overrideStatus ?? 'wait';
86
+ }
87
+ return resolveStepStatus(index, overrideStatus, ctx);
88
+ });
89
+
90
+ const stepClass = computed(() => [
91
+ 'm-step',
92
+ `m-step-${status.value}`,
93
+ ]);
94
+
95
+ const isLast = computed(() => {
96
+ if (!ctx) return true;
97
+ return index >= ctx.total - 1;
98
+ });
99
+
100
+ return { status, stepClass, isLast, ctx };
101
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @description switch api
3
+ * @author 阿怪
4
+ * @date 2023/4/23 11:52
5
+ * @version v1.0.0
6
+ *
7
+ * 江湖的业务千篇一律,复杂的代码好几百行。
8
+ */
9
+ import { MCOPO } from '../../types/props';
10
+ import { SwitchProps } from './props';
11
+
12
+
13
+ export const props: MCOPO<SwitchProps> = {
14
+ modelValue: { type: undefined, required: true },
15
+ disabled: { type: Boolean, default: false },
16
+ loading: { type: Boolean, default: false },
17
+ activeInfo: { type: String, default: '' },
18
+ inactiveInfo: { type: String, default: '' },
19
+ activeValue: { type: undefined, default: undefined },
20
+ inactiveValue: { type: undefined, default: undefined },
21
+ onControl: { type: Boolean, default: false },
22
+ };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @description
3
+ * @author 阿怪
4
+ * @date 2025/1/13 10:35
5
+ * @version v1.0.0
6
+ *
7
+ * 江湖的业务千篇一律,复杂的代码好几百行。
8
+ */
9
+ import { props } from './api.ts';
10
+ import useSwitch, { getIsActive, switchIsBoolean } from './useSwitch.tsx';
11
+
12
+ export const SwitchCore = {
13
+ props,
14
+ switchIsBoolean,
15
+ getIsActive,
16
+ useSwitch,
17
+ }
@@ -0,0 +1,66 @@
1
+ /**
2
+ * @description switch api type
3
+ * @author 阿怪
4
+ * @date 2022/8/16 23:13
5
+ * @version v1.0.0
6
+ *
7
+ * @name m-switch
8
+ * @docDescription Switch component with shuimo-ui style.
9
+ * 水墨组件的开关组件。
10
+ * slot优先级高于text
11
+ * @docUrl https://shuimo.design/switch
12
+ *
13
+ * 江湖的业务千篇一律,复杂的代码好几百行。
14
+ */
15
+
16
+ export declare type SwitchProps = {
17
+ /**
18
+ * @description switch value. 开关绑定值
19
+ * @type any
20
+ */
21
+ modelValue: any,
22
+ /**
23
+ * @description switch disabled
24
+ * 是否禁用
25
+ * @default false
26
+ */
27
+ disabled?: boolean,
28
+ /**
29
+ * @description switch disabled
30
+ * 是否加载中
31
+ * @default false
32
+ */
33
+ loading?: boolean,
34
+ /**
35
+ * @description 打开文本
36
+ * @type string
37
+ */
38
+ activeInfo?: string,
39
+ /**
40
+ * @description 关闭文本
41
+ * @type string
42
+ */
43
+ inactiveInfo?: string,
44
+ /**
45
+ * @description 打开参数
46
+ * @type string
47
+ */
48
+ activeValue?: any,
49
+ /**
50
+ * @description 关闭参数
51
+ * @type string
52
+ */
53
+ inactiveValue?: any,
54
+ /**
55
+ * @description 是否控制
56
+ * @type string
57
+ * @default false
58
+ */
59
+ onControl?: boolean
60
+ };
61
+
62
+
63
+ export declare type SwitchEvents = {
64
+ onClick?: (e: MouseEvent) => void
65
+ };
66
+
@@ -0,0 +1,79 @@
1
+ /**
2
+ * @description switch hook
3
+ * @author 阿怪
4
+ * @date 2023/4/23 21:34
5
+ * @version v1.0.0
6
+ *
7
+ * 江湖的业务千篇一律,复杂的代码好几百行。
8
+ */
9
+ import { SwitchProps } from './props';
10
+ import { computed, ref } from 'vue';
11
+ import { isEmpty } from '../../../tools';
12
+
13
+ export const switchIsBoolean = (value: SwitchProps['modelValue']) => {
14
+ return typeof value === 'boolean';
15
+ };
16
+
17
+ export const getIsActive = (value: SwitchProps['modelValue'], activeValue: SwitchProps['activeValue']) => {
18
+ return value === activeValue;
19
+ };
20
+
21
+
22
+ export default function useSwitch<
23
+ Props extends Record<string, any>,
24
+ >(props: Props, ctx: any) {
25
+ const activeValue = ref(props.activeValue);
26
+ const inactiveValue = ref(props.inactiveValue);
27
+ const { slots, emit } = ctx;
28
+
29
+ const isBoolean = computed(() => switchIsBoolean(props.modelValue));
30
+ // 如果modelValue是布尔值
31
+ if (isBoolean.value) {
32
+ // 如果activeValue和inactiveValue都为空
33
+ if (isEmpty(props.activeValue) && isEmpty(props.inactiveValue)) {
34
+ activeValue.value = true;
35
+ inactiveValue.value = false;
36
+ }
37
+ }
38
+
39
+ const isActive = computed(() => getIsActive(props.modelValue, activeValue.value));
40
+
41
+
42
+ const changeSwitch = () => {
43
+ if (props.disabled || props.loading) {
44
+ return;
45
+ }
46
+ // 如果不是自定义控制的
47
+ if (!props.onControl) {
48
+ // 如果是简单的布尔值
49
+ if (isBoolean.value) {
50
+ emit('update:modelValue', !props.modelValue);
51
+ }
52
+ }
53
+ emit('change', !isActive.value ? props.activeValue ?? true : inactiveValue ?? false);
54
+ };
55
+
56
+ const getInfo = (key: keyof Pick<SwitchProps, 'activeInfo' | 'inactiveInfo'>) => {
57
+ if (slots[key]) {
58
+ return slots[key]!();
59
+ }
60
+ const info = props[key];
61
+ if (!info) {
62
+ return;
63
+ }
64
+ return <span class="m-switch-span">{info}</span>;
65
+ };
66
+ const switchClass = computed(()=>[
67
+ 'm-switch',
68
+ isActive.value ? 'm-switch-active' : 'm-switch-inactive',
69
+ { 'm-switch-loading': props.loading },
70
+ { 'm-switch-disabled': props.disabled },
71
+ ])
72
+
73
+
74
+ return {
75
+ getInfo,
76
+ changeSwitch,
77
+ switchClass
78
+ };
79
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @description tabs 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 { TabsProps, TabPaneProps } from './props';
11
+
12
+ export const props: MCOPO<TabsProps> = {
13
+ modelValue: { type: [String, Number], required: true },
14
+ items: { type: Array, default: () => [] },
15
+ type: { type: String as MPropType<'line' | 'card'>, default: 'line' },
16
+ };
17
+
18
+ export const tabPaneProps: MCOPO<TabPaneProps> = {
19
+ label: { type: String, required: true },
20
+ name: { type: [String, Number], required: true },
21
+ disabled: { type: Boolean, default: false },
22
+ lazy: { type: Boolean, default: false },
23
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @description tabs barrel export
3
+ * @author 阿怪
4
+ * @date 2026/2/26
5
+ * @version v1.0.0
6
+ *
7
+ * 江湖的业务千篇一律,复杂的代码好几百行。
8
+ */
9
+ import { props, tabPaneProps } from './api.ts';
10
+ import useTabs from './useTabs.ts';
11
+
12
+ export const TabsCore = {
13
+ props,
14
+ tabPaneProps,
15
+ useTabs,
16
+ };
17
+
18
+ export type { TabsProps, TabPaneProps, TabItem } from './props';
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @description tabs api type
3
+ * @author 阿怪
4
+ * @date 2026/2/26
5
+ * @version v1.0.0
6
+ *
7
+ * 江湖的业务千篇一律,复杂的代码好几百行。
8
+ */
9
+
10
+ export declare type TabItem = {
11
+ /** 标签页显示文本 */
12
+ label: string;
13
+ /** 标签页唯一标识 */
14
+ name: string | number;
15
+ /** 是否禁用 */
16
+ disabled?: boolean;
17
+ };
18
+
19
+ export declare type TabsProps = {
20
+ /** 当前激活的标签页 name */
21
+ modelValue: string | number;
22
+ /** 标签页数据(与插槽 API 二选一) */
23
+ items?: TabItem[];
24
+ /** 标签页样式类型 */
25
+ type?: 'line' | 'card';
26
+ };
27
+
28
+ export declare type TabsEvents = {
29
+ onChange?: (name: string | number) => void;
30
+ };
31
+
32
+ export declare type TabPaneProps = {
33
+ /** 标签页显示文本 */
34
+ label: string;
35
+ /** 标签页唯一标识,需与父组件 modelValue 对应 */
36
+ name: string | number;
37
+ /** 是否禁用 */
38
+ disabled?: boolean;
39
+ /** 是否懒加载(首次激活才渲染内容) */
40
+ lazy?: boolean;
41
+ };
@@ -0,0 +1,66 @@
1
+ /**
2
+ * @description tabs hook
3
+ * @author 阿怪
4
+ * @date 2026/2/26
5
+ * @version v1.0.0
6
+ *
7
+ * 江湖的业务千篇一律,复杂的代码好几百行。
8
+ */
9
+ import { computed } from 'vue';
10
+ import { TabsProps } from './props';
11
+
12
+ export default function useTabs<
13
+ Props extends Record<string, unknown>,
14
+ >(props: Props, ctx: any) {
15
+ const { emit } = ctx;
16
+
17
+ /** 当前激活的标签名 */
18
+ const activeTab = computed(() => (props as unknown as TabsProps).modelValue);
19
+
20
+ /** 判断某个标签是否为激活状态 */
21
+ const isActive = (name: string | number) => activeTab.value === name;
22
+
23
+ /** 切换标签页,禁用状态下不响应 */
24
+ const switchTab = (name: string | number, disabled?: boolean) => {
25
+ if (disabled) {
26
+ return;
27
+ }
28
+ if (name === activeTab.value) {
29
+ return;
30
+ }
31
+ emit('update:modelValue', name);
32
+ emit('change', name);
33
+ };
34
+
35
+ /** 容器根节点 class */
36
+ const tabsClass = computed(() => {
37
+ const type = (props as unknown as TabsProps).type ?? 'line';
38
+ return [
39
+ 'm-tabs',
40
+ `m-tabs-${type}`,
41
+ ];
42
+ });
43
+
44
+ /** 导航栏 class */
45
+ const navClass = 'm-tabs-nav';
46
+
47
+ /** 获取单个导航项的 class */
48
+ const getNavItemClass = (name: string | number, disabled?: boolean) => [
49
+ 'm-tabs-nav-item',
50
+ isActive(name) ? 'm-tabs-nav-item-active' : '',
51
+ disabled ? 'm-tabs-nav-item-disabled' : '',
52
+ ].filter(Boolean);
53
+
54
+ /** 内容区域 class */
55
+ const contentClass = 'm-tabs-content';
56
+
57
+ return {
58
+ activeTab,
59
+ isActive,
60
+ switchTab,
61
+ tabsClass,
62
+ navClass,
63
+ getNavItemClass,
64
+ contentClass,
65
+ };
66
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @description tag api
3
+ * @author 阿怪
4
+ * @date 2026/2/27 00:00
5
+ * @version v1.1.0
6
+ *
7
+ * 江湖的业务千篇一律,复杂的代码好几百行。
8
+ */
9
+ import { MCOPO, MPropType } from '../../types/props';
10
+ import { TagProps } from './props';
11
+
12
+ export const props: MCOPO<TagProps> = {
13
+ type: { type: String as MPropType<'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info'>, default: 'default' },
14
+ size: { type: String as MPropType<'large' | 'medium' | 'small'>, default: 'medium' },
15
+ closable: { type: Boolean, default: false },
16
+ disabled: { type: Boolean, default: false },
17
+ };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @description tag core
3
+ * @author 阿怪
4
+ * @date 2025/02/25 00:00
5
+ * @version v1.0.0
6
+ *
7
+ * 江湖的业务千篇一律,复杂的代码好几百行。
8
+ */
9
+ import { props } from './api.ts';
10
+
11
+ export const TagCore = {
12
+ props,
13
+ };
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @description tag props type
3
+ * @author 阿怪
4
+ * @date 2026/2/27 00:00
5
+ * @version v1.1.0
6
+ *
7
+ * @name m-tag
8
+ * @docDescription Tag component.
9
+ * 标签组件。
10
+ * @docUrl https://shuimo.design/tag
11
+ *
12
+ * 江湖的业务千篇一律,复杂的代码好几百行。
13
+ */
14
+
15
+ export declare type TagProps = {
16
+ /**
17
+ * @description tag type
18
+ * 标签类型
19
+ * @type string
20
+ * @default default
21
+ * @enum default|primary|success|warning|danger|info
22
+ */
23
+ type?: 'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info';
24
+ /**
25
+ * @description tag size
26
+ * 标签尺寸
27
+ * @type string
28
+ * @default medium
29
+ * @enum large|medium|small
30
+ */
31
+ size?: 'large' | 'medium' | 'small';
32
+ /**
33
+ * @description 是否显示关闭按钮
34
+ * @type boolean
35
+ * @default false
36
+ */
37
+ closable?: boolean;
38
+ /**
39
+ * @description 是否禁用
40
+ * @type boolean
41
+ * @default false
42
+ */
43
+ disabled?: boolean;
44
+ };
45
+
46
+ export declare type TagEmits = {
47
+ onClose?: (e: MouseEvent) => void;
48
+ onClick?: (e: MouseEvent) => void;
49
+ };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @description timePicker api
3
+ * @author 阿怪
4
+ * @date 2026/2/27
5
+ * @version v1.0.0
6
+ *
7
+ * 江湖的业务千篇一律,复杂的代码好几百行。
8
+ */
9
+ import { MCOPO } from '../../types/props';
10
+ import { TimePickerProps } from './props';
11
+
12
+ export const props: MCOPO<TimePickerProps> = {
13
+ modelValue: { type: String, default: '' },
14
+ placeholder: { type: String, default: '请选择时间...' },
15
+ format: { type: String, default: undefined },
16
+ disabled: { type: Boolean, default: false },
17
+ showSeconds: { type: Boolean, default: true },
18
+ hourStep: { type: Number, default: 1 },
19
+ minuteStep: { type: Number, default: 1 },
20
+ secondStep: { type: Number, default: 1 },
21
+ };