king-design-analyzer 2.1.9 → 2.2.1

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 (327) hide show
  1. package/components/actions.json +109 -0
  2. package/components/advancedset.json +128 -0
  3. package/components/affix.json +8 -0
  4. package/components/aksk.json +172 -0
  5. package/components/anchor.json +220 -0
  6. package/components/anchorlink.json +111 -0
  7. package/components/az.json +15 -2
  8. package/components/badge.json +8 -0
  9. package/components/billtypes.json +14 -2
  10. package/components/breadcrumb.json +9 -1
  11. package/components/button.json +192 -0
  12. package/components/buttonlink.json +74 -0
  13. package/components/card.json +14 -4
  14. package/components/cardcol.json +142 -0
  15. package/components/cardcols.json +121 -0
  16. package/components/cardcontent.json +20 -3
  17. package/components/cardtabs.json +172 -0
  18. package/components/carousel.json +7 -0
  19. package/components/cascader.json +576 -368
  20. package/components/checkbox.json +51 -4
  21. package/components/cidrinput.json +140 -0
  22. package/components/code.json +8 -1
  23. package/components/collapse.json +335 -341
  24. package/components/colorpicker.json +217 -0
  25. package/components/configprovider.json +96 -0
  26. package/components/copy.json +7 -0
  27. package/components/copyhover.json +111 -0
  28. package/components/copyrow.json +125 -0
  29. package/components/datepicker.json +656 -524
  30. package/components/description.json +98 -0
  31. package/components/descriptions.json +10 -3
  32. package/components/diagram.json +295 -0
  33. package/components/dialog.json +526 -455
  34. package/components/divider.json +9 -1
  35. package/components/drawer.json +603 -558
  36. package/components/dropdown.json +464 -384
  37. package/components/duration.json +125 -0
  38. package/components/editable.json +66 -0
  39. package/components/ellipsis.json +34 -1
  40. package/components/filtertablefieldsdialog.json +128 -0
  41. package/components/flex.json +152 -0
  42. package/components/form.json +143 -3
  43. package/components/formiteminput.json +214 -0
  44. package/components/formitemspinner.json +213 -0
  45. package/components/formitemswitch.json +185 -0
  46. package/components/formitemtableconfigs.json +210 -0
  47. package/components/grid.json +7 -0
  48. package/components/header.json +165 -0
  49. package/components/icon.json +13 -1
  50. package/components/icontooltip.json +19 -1
  51. package/components/input.json +196 -8
  52. package/components/instancelist.json +194 -0
  53. package/components/instancenum.json +196 -0
  54. package/components/ipinput.json +117 -0
  55. package/components/kspstatus.json +205 -0
  56. package/components/kvcode.json +120 -0
  57. package/components/layoutcontent.json +24 -3
  58. package/components/layoutlistcontent.json +157 -0
  59. package/components/layoutpermissioncontent.json +156 -0
  60. package/components/layoutstandardlist.json +276 -0
  61. package/components/layouttabs.json +168 -0
  62. package/components/lazymount.json +87 -0
  63. package/components/lazyteleport.json +119 -0
  64. package/components/menu.json +11 -3
  65. package/components/notification.json +351 -0
  66. package/components/pagination.json +12 -0
  67. package/components/paginationplus.json +30 -3
  68. package/components/password.json +121 -0
  69. package/components/popover.json +457 -437
  70. package/components/projects.json +129 -0
  71. package/components/protable.json +99 -8
  72. package/components/queuevisualrange.json +110 -0
  73. package/components/radio.json +82 -2
  74. package/components/rate.json +200 -0
  75. package/components/region.json +14 -2
  76. package/components/scrollselect.json +140 -0
  77. package/components/search.json +221 -0
  78. package/components/searchinput.json +132 -0
  79. package/components/searchitems.json +215 -0
  80. package/components/searchselect.json +195 -0
  81. package/components/select.json +749 -666
  82. package/components/sidebar.json +198 -0
  83. package/components/skeleton.json +234 -0
  84. package/components/slider.json +12 -2
  85. package/components/spin.json +10 -2
  86. package/components/spinner.json +419 -429
  87. package/components/split.json +263 -0
  88. package/components/sshkeys.json +138 -0
  89. package/components/status.json +60 -3
  90. package/components/steps.json +7 -0
  91. package/components/switch.json +12 -3
  92. package/components/table.json +24 -2
  93. package/components/tablecolumnid.json +14 -2
  94. package/components/tabs.json +14 -2
  95. package/components/tag.json +8 -5
  96. package/components/timeline.json +215 -0
  97. package/components/timepicker.json +147 -3
  98. package/components/timerange.json +262 -0
  99. package/components/tip.json +27 -0
  100. package/components/tooltip.json +492 -395
  101. package/components/tour.json +418 -372
  102. package/components/transfer.json +79 -8
  103. package/components/tree.json +28 -5
  104. package/components/treeselect.json +612 -475
  105. package/components/upload.json +474 -473
  106. package/components/vdialog.json +309 -0
  107. package/components/vdrawer.json +335 -0
  108. package/components/virtuallist.json +7 -0
  109. package/dist/ast/index.d.mts +65 -2
  110. package/dist/ast/index.d.ts +65 -2
  111. package/dist/ast/index.js +4 -3
  112. package/dist/ast/index.mjs +2 -1
  113. package/dist/chunk-4OTQAQ6J.mjs +341 -0
  114. package/dist/{chunk-F26GUCGG.js → chunk-4WXOYU2N.js} +32 -9
  115. package/dist/chunk-6HOIRUQB.mjs +409 -0
  116. package/dist/chunk-DHLWNT53.js +364 -0
  117. package/dist/{chunk-H2ET6MMM.mjs → chunk-IPJJMPOO.mjs} +155 -66
  118. package/dist/{chunk-WYSRJVX4.js → chunk-JJ6AB4ZH.js} +2 -2
  119. package/dist/{chunk-2W6OCG2S.js → chunk-JNRGUR3O.js} +155 -67
  120. package/dist/chunk-KF5YBEM5.js +143 -0
  121. package/dist/{chunk-OJOHB64C.mjs → chunk-LRTDTFFQ.mjs} +28 -5
  122. package/dist/{chunk-DSWKLUIX.mjs → chunk-NZL6T22V.mjs} +1 -1
  123. package/dist/chunk-QC6VTSA3.mjs +117 -0
  124. package/dist/chunk-V5N65MRP.js +411 -0
  125. package/dist/full/index.d.mts +2 -0
  126. package/dist/full/index.d.ts +2 -0
  127. package/dist/full/index.js +7 -6
  128. package/dist/full/index.mjs +5 -4
  129. package/dist/index.d.mts +1 -0
  130. package/dist/index.d.ts +1 -0
  131. package/dist/index.js +14 -13
  132. package/dist/index.mjs +6 -5
  133. package/dist/metadata/index.d.mts +38 -3
  134. package/dist/metadata/index.d.ts +38 -3
  135. package/dist/metadata/index.js +26 -16
  136. package/dist/metadata/index.mjs +26 -15
  137. package/dist/resolve-BsLBxlBi.d.mts +24 -0
  138. package/dist/resolve-BsLBxlBi.d.ts +24 -0
  139. package/dist/runtime/index.d.mts +2 -0
  140. package/dist/runtime/index.d.ts +2 -0
  141. package/dist/runtime/index.js +4 -4
  142. package/dist/runtime/index.mjs +2 -2
  143. package/dist/shared/index.d.mts +10 -0
  144. package/dist/shared/index.d.ts +10 -0
  145. package/dist/shared/index.js +23 -0
  146. package/dist/shared/index.mjs +2 -0
  147. package/dist/static/index.js +5 -5
  148. package/dist/static/index.mjs +2 -2
  149. package/docs_for_llm/actions.doc.md +87 -0
  150. package/docs_for_llm/advancedset.doc.md +98 -0
  151. package/docs_for_llm/affix.doc.md +20 -7
  152. package/docs_for_llm/aksk.doc.md +111 -0
  153. package/docs_for_llm/anchor.doc.md +155 -0
  154. package/docs_for_llm/anchorlink.doc.md +75 -0
  155. package/docs_for_llm/az.doc.md +17 -11
  156. package/docs_for_llm/badge.doc.md +11 -5
  157. package/docs_for_llm/billtypes.doc.md +17 -11
  158. package/docs_for_llm/breadcrumb.doc.md +80 -4
  159. package/docs_for_llm/button.doc.md +91 -18
  160. package/docs_for_llm/buttonlink.doc.md +64 -0
  161. package/docs_for_llm/card.doc.md +58 -8
  162. package/docs_for_llm/cardcol.doc.md +78 -0
  163. package/docs_for_llm/cardcols.doc.md +84 -0
  164. package/docs_for_llm/cardcontent.doc.md +31 -10
  165. package/docs_for_llm/cardtabs.doc.md +106 -0
  166. package/docs_for_llm/carousel.doc.md +79 -7
  167. package/docs_for_llm/cascader.doc.md +106 -23
  168. package/docs_for_llm/checkbox.doc.md +25 -13
  169. package/docs_for_llm/cidrinput.doc.md +83 -0
  170. package/docs_for_llm/code.doc.md +22 -11
  171. package/docs_for_llm/collapse.doc.md +147 -14
  172. package/docs_for_llm/colorpicker.doc.md +104 -0
  173. package/docs_for_llm/configprovider.doc.md +77 -0
  174. package/docs_for_llm/copy.doc.md +15 -13
  175. package/docs_for_llm/copyhover.doc.md +59 -0
  176. package/docs_for_llm/copyrow.doc.md +80 -0
  177. package/docs_for_llm/datepicker.doc.md +66 -35
  178. package/docs_for_llm/description.doc.md +75 -0
  179. package/docs_for_llm/descriptions.doc.md +122 -10
  180. package/docs_for_llm/diagram.doc.md +343 -0
  181. package/docs_for_llm/dialog.doc.md +97 -77
  182. package/docs_for_llm/divider.doc.md +14 -7
  183. package/docs_for_llm/drawer.doc.md +114 -69
  184. package/docs_for_llm/dropdown.doc.md +290 -22
  185. package/docs_for_llm/duration.doc.md +76 -0
  186. package/docs_for_llm/editable.doc.md +36 -14
  187. package/docs_for_llm/ellipsis.doc.md +10 -5
  188. package/docs_for_llm/filtertablefieldsdialog.doc.md +99 -0
  189. package/docs_for_llm/flex.doc.md +83 -0
  190. package/docs_for_llm/form.doc.md +196 -18
  191. package/docs_for_llm/formiteminput.doc.md +128 -0
  192. package/docs_for_llm/formitemspinner.doc.md +105 -0
  193. package/docs_for_llm/formitemswitch.doc.md +113 -0
  194. package/docs_for_llm/formitemtableconfigs.doc.md +95 -0
  195. package/docs_for_llm/grid.doc.md +78 -5
  196. package/docs_for_llm/header.doc.md +114 -0
  197. package/docs_for_llm/icon.doc.md +12 -8
  198. package/docs_for_llm/icontooltip.doc.md +121 -0
  199. package/docs_for_llm/input.doc.md +199 -41
  200. package/docs_for_llm/instancelist.doc.md +113 -0
  201. package/docs_for_llm/instancenum.doc.md +95 -0
  202. package/docs_for_llm/ipinput.doc.md +77 -0
  203. package/docs_for_llm/kspstatus.doc.md +82 -0
  204. package/docs_for_llm/kvcode.doc.md +76 -0
  205. package/docs_for_llm/layoutcontent.doc.md +54 -17
  206. package/docs_for_llm/layoutlistcontent.doc.md +168 -0
  207. package/docs_for_llm/layoutpermissioncontent.doc.md +93 -0
  208. package/docs_for_llm/layoutstandardlist.doc.md +129 -0
  209. package/docs_for_llm/layouttabs.doc.md +101 -0
  210. package/docs_for_llm/lazymount.doc.md +82 -0
  211. package/docs_for_llm/lazyteleport.doc.md +85 -0
  212. package/docs_for_llm/menu.doc.md +139 -14
  213. package/docs_for_llm/message.doc.md +93 -10
  214. package/docs_for_llm/notification.doc.md +214 -0
  215. package/docs_for_llm/pagination.doc.md +30 -17
  216. package/docs_for_llm/paginationplus.doc.md +31 -10
  217. package/docs_for_llm/password.doc.md +86 -0
  218. package/docs_for_llm/popover.doc.md +24 -55
  219. package/docs_for_llm/progress.doc.md +13 -10
  220. package/docs_for_llm/projects.doc.md +91 -0
  221. package/docs_for_llm/protable.doc.md +98 -15
  222. package/docs_for_llm/queuevisualrange.doc.md +78 -0
  223. package/docs_for_llm/radio.doc.md +23 -8
  224. package/docs_for_llm/rate.doc.md +127 -0
  225. package/docs_for_llm/region.doc.md +25 -13
  226. package/docs_for_llm/scrollselect.doc.md +90 -0
  227. package/docs_for_llm/search.doc.md +120 -0
  228. package/docs_for_llm/searchinput.doc.md +111 -0
  229. package/docs_for_llm/searchitems.doc.md +116 -0
  230. package/docs_for_llm/searchselect.doc.md +126 -0
  231. package/docs_for_llm/select.doc.md +208 -49
  232. package/docs_for_llm/sidebar.doc.md +133 -0
  233. package/docs_for_llm/skeleton.doc.md +152 -0
  234. package/docs_for_llm/slider.doc.md +42 -22
  235. package/docs_for_llm/spin.doc.md +18 -6
  236. package/docs_for_llm/spinner.doc.md +28 -18
  237. package/docs_for_llm/split.doc.md +170 -0
  238. package/docs_for_llm/sshkeys.doc.md +88 -0
  239. package/docs_for_llm/status.doc.md +14 -9
  240. package/docs_for_llm/steps.doc.md +81 -7
  241. package/docs_for_llm/switch.doc.md +32 -16
  242. package/docs_for_llm/table.doc.md +317 -55
  243. package/docs_for_llm/tablecolumnid.doc.md +36 -16
  244. package/docs_for_llm/tabs.doc.md +117 -12
  245. package/docs_for_llm/tag.doc.md +167 -15
  246. package/docs_for_llm/timeline.doc.md +187 -0
  247. package/docs_for_llm/timepicker.doc.md +74 -36
  248. package/docs_for_llm/timerange.doc.md +157 -0
  249. package/docs_for_llm/tip.doc.md +50 -11
  250. package/docs_for_llm/tooltip.doc.md +99 -27
  251. package/docs_for_llm/tour.doc.md +125 -28
  252. package/docs_for_llm/transfer.doc.md +99 -33
  253. package/docs_for_llm/tree.doc.md +129 -24
  254. package/docs_for_llm/treeselect.doc.md +101 -44
  255. package/docs_for_llm/upload.doc.md +63 -32
  256. package/docs_for_llm/useCRUD.doc.md +49 -0
  257. package/docs_for_llm/useCountdown.doc.md +43 -0
  258. package/docs_for_llm/useDetail.doc.md +48 -0
  259. package/docs_for_llm/useDialog.doc.md +46 -0
  260. package/docs_for_llm/useEntity.doc.md +45 -0
  261. package/docs_for_llm/useEventListener.doc.md +44 -0
  262. package/docs_for_llm/useFalseUntilTruthy.doc.md +41 -0
  263. package/docs_for_llm/useGetCopyAuthText.doc.md +35 -0
  264. package/docs_for_llm/useGetUserPermission.doc.md +43 -0
  265. package/docs_for_llm/useGroup.doc.md +48 -0
  266. package/docs_for_llm/useIdEntities.doc.md +48 -0
  267. package/docs_for_llm/useIdEntity.doc.md +103 -0
  268. package/docs_for_llm/useInterval.doc.md +43 -0
  269. package/docs_for_llm/useLayoutStandardList.doc.md +38 -0
  270. package/docs_for_llm/useMessage.doc.md +46 -0
  271. package/docs_for_llm/useModifyCache.doc.md +37 -0
  272. package/docs_for_llm/useOpenDialog.doc.md +41 -0
  273. package/docs_for_llm/usePagination.doc.md +60 -0
  274. package/docs_for_llm/usePersist.doc.md +54 -0
  275. package/docs_for_llm/usePoll.doc.md +41 -0
  276. package/docs_for_llm/useRoutePlus.doc.md +34 -0
  277. package/docs_for_llm/useRouterPlus.doc.md +34 -0
  278. package/docs_for_llm/useSearch.doc.md +68 -0
  279. package/docs_for_llm/useShell.doc.md +43 -0
  280. package/docs_for_llm/useSkip.doc.md +41 -0
  281. package/docs_for_llm/useStorageIdEntity.doc.md +46 -0
  282. package/docs_for_llm/useStore.doc.md +34 -0
  283. package/docs_for_llm/useTable.doc.md +57 -0
  284. package/docs_for_llm/useTableGroup.doc.md +47 -0
  285. package/docs_for_llm/useTableSort.doc.md +40 -0
  286. package/docs_for_llm/useToState.doc.md +112 -0
  287. package/docs_for_llm/useUser.doc.md +38 -0
  288. package/docs_for_llm/useValidForm.doc.md +41 -0
  289. package/docs_for_llm/vdialog.doc.md +154 -0
  290. package/docs_for_llm/vdrawer.doc.md +148 -0
  291. package/docs_for_llm/virtuallist.doc.md +157 -3
  292. package/hooks/useCRUD.json +61 -0
  293. package/hooks/useCountdown.json +49 -0
  294. package/hooks/useDetail.json +67 -0
  295. package/hooks/useDialog.json +49 -0
  296. package/hooks/useEntity.json +61 -0
  297. package/hooks/useEventListener.json +61 -0
  298. package/hooks/useFalseUntilTruthy.json +43 -0
  299. package/hooks/useGetCopyAuthText.json +36 -0
  300. package/hooks/useGetUserPermission.json +55 -0
  301. package/hooks/useGroup.json +49 -0
  302. package/hooks/useIdEntities.json +61 -0
  303. package/hooks/useInterval.json +55 -0
  304. package/hooks/useLayoutStandardList.json +36 -0
  305. package/hooks/useMessage.json +73 -0
  306. package/hooks/useModifyCache.json +36 -0
  307. package/hooks/useOpenDialog.json +43 -0
  308. package/hooks/usePagination.json +49 -0
  309. package/hooks/usePersist.json +61 -0
  310. package/hooks/usePoll.json +43 -0
  311. package/hooks/useRoutePlus.json +36 -0
  312. package/hooks/useRouterPlus.json +36 -0
  313. package/hooks/useSearch.json +56 -0
  314. package/hooks/useShell.json +49 -0
  315. package/hooks/useSkip.json +43 -0
  316. package/hooks/useStorageIdEntity.json +67 -0
  317. package/hooks/useStore.json +36 -0
  318. package/hooks/useTable.json +49 -0
  319. package/hooks/useTableGroup.json +43 -0
  320. package/hooks/useTableSort.json +43 -0
  321. package/hooks/useUser.json +36 -0
  322. package/hooks/useValidForm.json +43 -0
  323. package/package.json +14 -8
  324. package/dist/chunk-D3Y6FGWA.js +0 -153
  325. package/dist/chunk-HPAUCD5I.js +0 -156
  326. package/dist/chunk-L4DS3EXI.mjs +0 -133
  327. package/dist/chunk-NZ6TLWMD.mjs +0 -151
@@ -0,0 +1,43 @@
1
+ {
2
+ "id": "useTableSort",
3
+ "name": "useTableSort",
4
+ "displayName": "表格排序状态",
5
+ "category": "table",
6
+ "description": "统一管理表格排序字段和方向,并提供多种派生排序状态,适合请求参数、UI 高亮和布尔/整数映射场景。",
7
+ "importStatement": "import { useTableSort } from '@ksyun-internal/versatile';",
8
+ "source": "@ksyun-internal/versatile",
9
+ "params": [
10
+ {
11
+ "name": "page",
12
+ "type": "Ref<number | undefined>",
13
+ "required": false,
14
+ "description": "分页页码,传入后在切换排序时可联动重置页码"
15
+ }
16
+ ],
17
+ "returnType": "{ sort: Ref<TableSortValue>; curSortKey: ComputedRef<string | undefined>; curSortType: ComputedRef<'desc' | 'asc' | undefined>; curSortTypeByInt: ComputedRef<0 | 1 | -1>; curSortTypeByBoolean: ComputedRef<boolean | ''>; changeSort: Function; }",
18
+ "examples": [
19
+ {
20
+ "id": "table_sort",
21
+ "title": "列表排序状态",
22
+ "description": "将排序状态集中管理,并把变更方法绑定给表格",
23
+ "code": "<script setup lang=\"ts\">\nimport { usePagination, useTableSort } from '@ksyun-internal/versatile';\n\nconst { page } = usePagination();\nconst { sort, curSortKey, curSortType, changeSort } = useTableSort(page);\n</script>"
24
+ }
25
+ ],
26
+ "commonMistakes": [
27
+ {
28
+ "id": "manual_sort_mapping",
29
+ "description": "自己维护 asc/desc 和 0/1/-1 的映射,重复实现 hook 已有能力",
30
+ "wrongCode": "const sortType = computed(() => sort.value.type === 'asc' ? 1 : -1);",
31
+ "correctCode": "const { curSortTypeByInt } = useTableSort(page);",
32
+ "explanation": "hook 已经提供多种派生排序表示,优先复用。"
33
+ }
34
+ ],
35
+ "searchKeywords": [
36
+ "useTableSort",
37
+ "排序",
38
+ "TableSortValue",
39
+ "ProTable",
40
+ "列表排序",
41
+ "sort"
42
+ ]
43
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "id": "useUser",
3
+ "name": "useUser",
4
+ "displayName": "当前用户信息",
5
+ "category": "auth",
6
+ "description": "获取当前登录用户信息,适合在业务组件中读取 root 权限、当前用户 ID 或账号属性。",
7
+ "importStatement": "import { useUser } from '@ksyun-internal/versatile';",
8
+ "source": "@ksyun-internal/versatile",
9
+ "params": [],
10
+ "returnType": "Ref<UserInfo | undefined>",
11
+ "examples": [
12
+ {
13
+ "id": "read_user",
14
+ "title": "读取当前用户信息",
15
+ "description": "在页面初始化时获取当前用户及权限信息",
16
+ "code": "<script setup lang=\"ts\">\nimport { useUser } from '@ksyun-internal/versatile';\n\nconst user = useUser();\n</script>\n\n<template>\n <div v-if=\"user\">{{ user.curUserId }}</div>\n</template>"
17
+ }
18
+ ],
19
+ "commonMistakes": [
20
+ {
21
+ "id": "skip_undefined_guard",
22
+ "description": "直接访问 user.value 的属性,没有处理未加载完成的情况",
23
+ "wrongCode": "const isRoot = user.value.isRoot;",
24
+ "correctCode": "const isRoot = user.value?.isRoot;",
25
+ "explanation": "返回值是 Ref<UserInfo | undefined>,初始化阶段可能为空。"
26
+ }
27
+ ],
28
+ "searchKeywords": [
29
+ "useUser",
30
+ "当前用户",
31
+ "权限",
32
+ "isRoot",
33
+ "curUserId",
34
+ "账号信息"
35
+ ]
36
+ }
@@ -0,0 +1,43 @@
1
+ {
2
+ "id": "useValidForm",
3
+ "name": "useValidForm",
4
+ "displayName": "表单校验管理",
5
+ "category": "form",
6
+ "description": "封装 Form 实例的校验、重置和滚动定位能力,适合页面表单和弹窗表单统一管理。",
7
+ "importStatement": "import { useValidForm } from '@ksyun-internal/versatile';",
8
+ "source": "@ksyun-internal/versatile",
9
+ "params": [
10
+ {
11
+ "name": "models",
12
+ "type": "Ref<T>",
13
+ "required": false,
14
+ "description": "表单模型对象,可在 reset 时恢复默认值"
15
+ }
16
+ ],
17
+ "returnType": "{ formRef: Ref<Form | undefined>; validate: Function; validateByScroll: Function; reset: Function; scrollIntoFirstInvalidFormItem: Function; }",
18
+ "examples": [
19
+ {
20
+ "id": "page_form",
21
+ "title": "页面表单校验",
22
+ "description": "在提交前统一校验并定位第一个错误项",
23
+ "code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { useValidForm } from '@ksyun-internal/versatile';\n\nconst models = ref({ name: '', region: '' });\nconst { formRef, validateByScroll } = useValidForm(models);\n</script>"
24
+ }
25
+ ],
26
+ "commonMistakes": [
27
+ {
28
+ "id": "reset_without_models",
29
+ "description": "希望 reset 恢复初始模型,但没有把 models 传给 hook",
30
+ "wrongCode": "const { reset } = useValidForm();",
31
+ "correctCode": "const { reset } = useValidForm(models);",
32
+ "explanation": "如果需要重置业务表单值,建议把模型 Ref 传入 useValidForm。"
33
+ }
34
+ ],
35
+ "searchKeywords": [
36
+ "useValidForm",
37
+ "表单校验",
38
+ "Form",
39
+ "validateByScroll",
40
+ "reset",
41
+ "滚动定位"
42
+ ]
43
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "king-design-analyzer",
3
- "version": "2.1.9",
3
+ "version": "2.2.1",
4
4
  "description": "AST-based code analyzer for King Design Vue components with on-demand modular imports",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -40,6 +40,11 @@
40
40
  "types": "./dist/metadata/index.d.ts",
41
41
  "import": "./dist/metadata/index.mjs",
42
42
  "require": "./dist/metadata/index.js"
43
+ },
44
+ "./shared": {
45
+ "types": "./dist/shared/index.d.ts",
46
+ "import": "./dist/shared/index.mjs",
47
+ "require": "./dist/shared/index.js"
43
48
  }
44
49
  },
45
50
  "files": [
@@ -53,12 +58,14 @@
53
58
  "build:tsc": "tsc",
54
59
  "dev": "tsup --watch",
55
60
  "clean": "rm -rf dist",
56
- "validate": "npx tsx src/tools/validateDataset.ts",
57
- "validate:report": "npx tsx src/tools/validateDataset.ts -o report.json",
58
- "validate:unified": "npx tsx src/tools/testUnifiedValidator.ts",
59
- "transform:md": "npx ts-node scripts/transform_metadata.ts",
60
- "test": "vitest run",
61
- "test:watch": "vitest",
61
+ "validate": "ts-node -P tsconfig.scripts.json src/tools/validateDataset.ts",
62
+ "validate:report": "ts-node -P tsconfig.scripts.json src/tools/validateDataset.ts -o report.json",
63
+ "validate:unified": "ts-node -P tsconfig.scripts.json src/tools/testUnifiedValidator.ts",
64
+ "audit:versatile": "node scripts/audit_versatile.js",
65
+ "audit:hooks": "node scripts/audit_hooks.js",
66
+ "transform:md": "ts-node -P tsconfig.scripts.json scripts/transform_metadata.ts",
67
+ "test": "node --require ./scripts/vitest-webcrypto.cjs ./node_modules/vitest/vitest.mjs run",
68
+ "test:watch": "node --require ./scripts/vitest-webcrypto.cjs ./node_modules/vitest/vitest.mjs",
62
69
  "prepublishOnly": "npm run build",
63
70
  "release:patch": "npm version patch && npm publish",
64
71
  "release:minor": "npm version minor && npm publish",
@@ -76,7 +83,6 @@
76
83
  "author": "",
77
84
  "license": "MIT",
78
85
  "dependencies": {
79
- "king-design-analyzer": "^2.1.4",
80
86
  "sucrase": "^3.35.1"
81
87
  },
82
88
  "peerDependencies": {
@@ -1,153 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkHPAUCD5I_js = require('./chunk-HPAUCD5I.js');
4
-
5
- // src/runtime/index.ts
6
- var scopeIdCounter = 0;
7
- var MOCK_VUE_CONTEXT = {
8
- // Reactivity
9
- ref: (v) => ({ value: v }),
10
- reactive: (v) => v,
11
- computed: (fn) => ({ value: typeof fn === "function" ? fn() : fn }),
12
- readonly: (v) => v,
13
- shallowRef: (v) => ({ value: v }),
14
- shallowReactive: (v) => v,
15
- toRef: () => ({ value: void 0 }),
16
- toRefs: (obj) => Object.fromEntries(
17
- Object.keys(obj || {}).map((k) => [k, { value: obj[k] }])
18
- ),
19
- toRaw: (v) => v,
20
- markRaw: (v) => v,
21
- isRef: () => false,
22
- isReactive: () => false,
23
- isReadonly: () => false,
24
- isProxy: () => false,
25
- triggerRef: () => {
26
- },
27
- customRef: (factory) => factory(() => {
28
- }, () => {
29
- }),
30
- // Lifecycle
31
- onMounted: () => {
32
- },
33
- onUnmounted: () => {
34
- },
35
- onBeforeMount: () => {
36
- },
37
- onBeforeUnmount: () => {
38
- },
39
- onUpdated: () => {
40
- },
41
- onBeforeUpdate: () => {
42
- },
43
- onActivated: () => {
44
- },
45
- onDeactivated: () => {
46
- },
47
- onErrorCaptured: () => {
48
- },
49
- // Watchers
50
- watch: () => () => {
51
- },
52
- watchEffect: () => () => {
53
- },
54
- watchPostEffect: () => () => {
55
- },
56
- watchSyncEffect: () => () => {
57
- },
58
- // Composition API
59
- defineProps: () => ({}),
60
- defineEmits: () => () => {
61
- },
62
- defineExpose: () => {
63
- },
64
- defineOptions: () => {
65
- },
66
- defineSlots: () => ({}),
67
- defineModel: () => ({ value: void 0 }),
68
- withDefaults: (_props, defaults) => defaults,
69
- useSlots: () => ({}),
70
- useAttrs: () => ({}),
71
- // Dependency Injection
72
- inject: () => void 0,
73
- provide: () => {
74
- },
75
- // Utilities
76
- nextTick: () => Promise.resolve(),
77
- getCurrentInstance: () => null,
78
- h: () => ({}),
79
- createVNode: () => ({}),
80
- resolveComponent: () => ({}),
81
- // =========================================================================
82
- // @ksyun-internal/versatile Hooks
83
- // =========================================================================
84
- useToState: (_props, _key, _emit, defaultValue) => ({ value: defaultValue ?? void 0 }),
85
- useIdEntity: () => ({ value: void 0 }),
86
- // =========================================================================
87
- // Module Mocking
88
- // =========================================================================
89
- __mockModule: (modulePath) => {
90
- const createMockProxy = (path) => {
91
- return new Proxy(() => {
92
- }, {
93
- get: (target, prop) => {
94
- if (prop === Symbol.toPrimitive) return () => 0;
95
- if (prop === "then") return void 0;
96
- return createMockProxy();
97
- },
98
- apply: (target, thisArg, args) => {
99
- return createMockProxy();
100
- }
101
- });
102
- };
103
- return createMockProxy();
104
- }
105
- };
106
- function validateRuntimePrecheck(code) {
107
- const scopeId = `runtime-${Date.now()}-${++scopeIdCounter}`;
108
- const { script, bindings, strippedImports, error } = chunkHPAUCD5I_js.compileSFC(code, scopeId);
109
- if (error) {
110
- return {
111
- name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
112
- passed: false,
113
- errors: [error]
114
- };
115
- }
116
- try {
117
- const funcBody = `
118
- "use strict";
119
- ${script}
120
- return { ${bindings.join(", ")} };
121
- `;
122
- const keys = Object.keys(MOCK_VUE_CONTEXT);
123
- const values = Object.values(MOCK_VUE_CONTEXT);
124
- const runner = new Function(...keys, funcBody);
125
- const result = runner(...values);
126
- const missingBindings = bindings.filter((binding) => !(binding in result));
127
- if (missingBindings.length > 0) {
128
- return {
129
- name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
130
- passed: false,
131
- errors: missingBindings.map((b) => `\u53D8\u91CF ${b} \u672A\u6B63\u786E\u5BFC\u51FA`)
132
- };
133
- }
134
- return {
135
- name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
136
- passed: true,
137
- errors: []
138
- };
139
- } catch (e) {
140
- const errorMessage = e.message || String(e);
141
- const errorLocation = e.stack?.split("\n")[1]?.trim() || "";
142
- return {
143
- name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
144
- passed: false,
145
- errors: [
146
- `JavaScript \u6267\u884C\u9519\u8BEF: ${errorMessage}`,
147
- ...errorLocation ? [`\u4F4D\u7F6E: ${errorLocation}`] : []
148
- ]
149
- };
150
- }
151
- }
152
-
153
- exports.validateRuntimePrecheck = validateRuntimePrecheck;
@@ -1,156 +0,0 @@
1
- 'use strict';
2
-
3
- var sucrase = require('sucrase');
4
- var ts = require('typescript');
5
-
6
- function _interopNamespace(e) {
7
- if (e && e.__esModule) return e;
8
- var n = Object.create(null);
9
- if (e) {
10
- Object.keys(e).forEach(function (k) {
11
- if (k !== 'default') {
12
- var d = Object.getOwnPropertyDescriptor(e, k);
13
- Object.defineProperty(n, k, d.get ? d : {
14
- enumerable: true,
15
- get: function () { return e[k]; }
16
- });
17
- }
18
- });
19
- }
20
- n.default = e;
21
- return Object.freeze(n);
22
- }
23
-
24
- var ts__namespace = /*#__PURE__*/_interopNamespace(ts);
25
-
26
- // src/tools/sfcCompiler.ts
27
- var ALLOWED_IMPORT_SOURCES = [
28
- "vue",
29
- "@vue/",
30
- "@king-design/vue",
31
- "@ksyun-internal/versatile"
32
- ];
33
- function scopeStyles(css, scopeClass) {
34
- return css.replace(/([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)/g, (match, selector, suffix) => {
35
- if (selector.trim().startsWith("@")) return match;
36
- const scopedSelector = selector.split(",").map((s) => {
37
- s = s.trim();
38
- if (s === "body" || s === "html") return `.${scopeClass}`;
39
- return `.${scopeClass} ${s}`;
40
- }).join(", ");
41
- return `${scopedSelector}${suffix}`;
42
- });
43
- }
44
- function transformLocalImportToMock(importClause, source) {
45
- const namespaceMatch = importClause.match(/^\*\s+as\s+(\w+)$/);
46
- if (namespaceMatch) {
47
- return `const ${namespaceMatch[1]} = __mockModule('${source}');`;
48
- }
49
- const namedMatch = importClause.match(/^\{([^}]+)\}$/);
50
- if (namedMatch) {
51
- return `const { ${namedMatch[1]} } = __mockModule('${source}');`;
52
- }
53
- const defaultMatch = importClause.match(/^(\w+)/);
54
- if (defaultMatch) {
55
- const defaultName = defaultMatch[1];
56
- const mixedMatch = importClause.match(/^(\w+)\s*,\s*\{([^}]+)\}$/);
57
- if (mixedMatch) {
58
- const namedImports = mixedMatch[2];
59
- return `const _mock_${defaultName} = __mockModule('${source}'); const ${defaultName} = _mock_${defaultName}.default || _mock_${defaultName}; const { ${namedImports} } = _mock_${defaultName};`;
60
- }
61
- return `const ${defaultName} = __mockModule('${source}').default || __mockModule('${source}');`;
62
- }
63
- return "";
64
- }
65
- function compileSFC(code, scopeId, options) {
66
- const whitelist = options?.allowedImports ?? ALLOWED_IMPORT_SOURCES;
67
- const strippedImports = [];
68
- try {
69
- const templateMatch = code.match(/<template>([\s\S]*)<\/template>/);
70
- const scriptMatch = code.match(/<script[\s\S]*?>([\s\S]*)<\/script>/);
71
- const styleMatch = code.match(/<style[\s\S]*?>([\s\S]*)<\/style>/);
72
- const template = templateMatch && templateMatch[1] || "";
73
- const script = scriptMatch && scriptMatch[1] || "";
74
- const styleRaw = styleMatch && styleMatch[1] || "";
75
- const style = styleRaw ? scopeStyles(styleRaw, scopeId) : "";
76
- if (!template && !script) {
77
- return { template: "", script: "", style: "", bindings: [] };
78
- }
79
- let cleanScript = script;
80
- cleanScript = cleanScript.replace(/import\s+type\s+[\s\S]*?from\s+['"].*?['"];?/g, "");
81
- cleanScript = cleanScript.replace(
82
- /import\s+([^;]+?)\s+from\s+['"]([^'"]+)['"];?/g,
83
- (match, importClause, source) => {
84
- const isWhitelisted = whitelist.some(
85
- (w) => source === w || source.startsWith(w + "/")
86
- );
87
- if (isWhitelisted) {
88
- strippedImports.push({ source, reason: "whitelisted" });
89
- return "";
90
- }
91
- if (source.startsWith(".")) {
92
- strippedImports.push({ source, reason: "relative" });
93
- return transformLocalImportToMock(importClause.trim(), source);
94
- }
95
- strippedImports.push({ source, reason: "unknown" });
96
- return "";
97
- }
98
- );
99
- const result = sucrase.transform(cleanScript, {
100
- transforms: ["typescript"],
101
- disableESTransforms: true
102
- });
103
- if (result && typeof result.code === "string") {
104
- cleanScript = result.code;
105
- }
106
- const varNames = /* @__PURE__ */ new Set();
107
- try {
108
- let extractNames2 = function(name) {
109
- if (ts__namespace.isIdentifier(name)) {
110
- varNames.add(name.text);
111
- } else if (ts__namespace.isObjectBindingPattern(name) || ts__namespace.isArrayBindingPattern(name)) {
112
- name.elements.forEach((element) => {
113
- if (ts__namespace.isBindingElement(element)) {
114
- extractNames2(element.name);
115
- }
116
- });
117
- }
118
- }, visit2 = function(node) {
119
- if (ts__namespace.isVariableStatement(node)) {
120
- node.declarationList.declarations.forEach((decl) => extractNames2(decl.name));
121
- } else if (ts__namespace.isFunctionDeclaration(node) && node.name) {
122
- varNames.add(node.name.text);
123
- } else if (ts__namespace.isClassDeclaration(node) && node.name) {
124
- varNames.add(node.name.text);
125
- }
126
- };
127
- var extractNames = extractNames2, visit = visit2;
128
- const sourceFile = ts__namespace.createSourceFile(
129
- "temp.ts",
130
- cleanScript,
131
- ts__namespace.ScriptTarget.Latest,
132
- true
133
- );
134
- sourceFile.statements.forEach(visit2);
135
- } catch (e) {
136
- }
137
- return {
138
- template,
139
- script: cleanScript,
140
- style,
141
- bindings: [...varNames],
142
- strippedImports: strippedImports.length > 0 ? strippedImports : void 0
143
- };
144
- } catch (e) {
145
- return {
146
- template: "",
147
- script: "",
148
- style: "",
149
- bindings: [],
150
- error: e.message
151
- };
152
- }
153
- }
154
-
155
- exports.compileSFC = compileSFC;
156
- exports.scopeStyles = scopeStyles;
@@ -1,133 +0,0 @@
1
- import { transform } from 'sucrase';
2
- import * as ts from 'typescript';
3
-
4
- // src/tools/sfcCompiler.ts
5
- var ALLOWED_IMPORT_SOURCES = [
6
- "vue",
7
- "@vue/",
8
- "@king-design/vue",
9
- "@ksyun-internal/versatile"
10
- ];
11
- function scopeStyles(css, scopeClass) {
12
- return css.replace(/([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)/g, (match, selector, suffix) => {
13
- if (selector.trim().startsWith("@")) return match;
14
- const scopedSelector = selector.split(",").map((s) => {
15
- s = s.trim();
16
- if (s === "body" || s === "html") return `.${scopeClass}`;
17
- return `.${scopeClass} ${s}`;
18
- }).join(", ");
19
- return `${scopedSelector}${suffix}`;
20
- });
21
- }
22
- function transformLocalImportToMock(importClause, source) {
23
- const namespaceMatch = importClause.match(/^\*\s+as\s+(\w+)$/);
24
- if (namespaceMatch) {
25
- return `const ${namespaceMatch[1]} = __mockModule('${source}');`;
26
- }
27
- const namedMatch = importClause.match(/^\{([^}]+)\}$/);
28
- if (namedMatch) {
29
- return `const { ${namedMatch[1]} } = __mockModule('${source}');`;
30
- }
31
- const defaultMatch = importClause.match(/^(\w+)/);
32
- if (defaultMatch) {
33
- const defaultName = defaultMatch[1];
34
- const mixedMatch = importClause.match(/^(\w+)\s*,\s*\{([^}]+)\}$/);
35
- if (mixedMatch) {
36
- const namedImports = mixedMatch[2];
37
- return `const _mock_${defaultName} = __mockModule('${source}'); const ${defaultName} = _mock_${defaultName}.default || _mock_${defaultName}; const { ${namedImports} } = _mock_${defaultName};`;
38
- }
39
- return `const ${defaultName} = __mockModule('${source}').default || __mockModule('${source}');`;
40
- }
41
- return "";
42
- }
43
- function compileSFC(code, scopeId, options) {
44
- const whitelist = options?.allowedImports ?? ALLOWED_IMPORT_SOURCES;
45
- const strippedImports = [];
46
- try {
47
- const templateMatch = code.match(/<template>([\s\S]*)<\/template>/);
48
- const scriptMatch = code.match(/<script[\s\S]*?>([\s\S]*)<\/script>/);
49
- const styleMatch = code.match(/<style[\s\S]*?>([\s\S]*)<\/style>/);
50
- const template = templateMatch && templateMatch[1] || "";
51
- const script = scriptMatch && scriptMatch[1] || "";
52
- const styleRaw = styleMatch && styleMatch[1] || "";
53
- const style = styleRaw ? scopeStyles(styleRaw, scopeId) : "";
54
- if (!template && !script) {
55
- return { template: "", script: "", style: "", bindings: [] };
56
- }
57
- let cleanScript = script;
58
- cleanScript = cleanScript.replace(/import\s+type\s+[\s\S]*?from\s+['"].*?['"];?/g, "");
59
- cleanScript = cleanScript.replace(
60
- /import\s+([^;]+?)\s+from\s+['"]([^'"]+)['"];?/g,
61
- (match, importClause, source) => {
62
- const isWhitelisted = whitelist.some(
63
- (w) => source === w || source.startsWith(w + "/")
64
- );
65
- if (isWhitelisted) {
66
- strippedImports.push({ source, reason: "whitelisted" });
67
- return "";
68
- }
69
- if (source.startsWith(".")) {
70
- strippedImports.push({ source, reason: "relative" });
71
- return transformLocalImportToMock(importClause.trim(), source);
72
- }
73
- strippedImports.push({ source, reason: "unknown" });
74
- return "";
75
- }
76
- );
77
- const result = transform(cleanScript, {
78
- transforms: ["typescript"],
79
- disableESTransforms: true
80
- });
81
- if (result && typeof result.code === "string") {
82
- cleanScript = result.code;
83
- }
84
- const varNames = /* @__PURE__ */ new Set();
85
- try {
86
- let extractNames2 = function(name) {
87
- if (ts.isIdentifier(name)) {
88
- varNames.add(name.text);
89
- } else if (ts.isObjectBindingPattern(name) || ts.isArrayBindingPattern(name)) {
90
- name.elements.forEach((element) => {
91
- if (ts.isBindingElement(element)) {
92
- extractNames2(element.name);
93
- }
94
- });
95
- }
96
- }, visit2 = function(node) {
97
- if (ts.isVariableStatement(node)) {
98
- node.declarationList.declarations.forEach((decl) => extractNames2(decl.name));
99
- } else if (ts.isFunctionDeclaration(node) && node.name) {
100
- varNames.add(node.name.text);
101
- } else if (ts.isClassDeclaration(node) && node.name) {
102
- varNames.add(node.name.text);
103
- }
104
- };
105
- var extractNames = extractNames2, visit = visit2;
106
- const sourceFile = ts.createSourceFile(
107
- "temp.ts",
108
- cleanScript,
109
- ts.ScriptTarget.Latest,
110
- true
111
- );
112
- sourceFile.statements.forEach(visit2);
113
- } catch (e) {
114
- }
115
- return {
116
- template,
117
- script: cleanScript,
118
- style,
119
- bindings: [...varNames],
120
- strippedImports: strippedImports.length > 0 ? strippedImports : void 0
121
- };
122
- } catch (e) {
123
- return {
124
- template: "",
125
- script: "",
126
- style: "",
127
- bindings: [],
128
- error: e.message
129
- };
130
- }
131
- }
132
-
133
- export { compileSFC, scopeStyles };