@done-coding/forge-core 0.0.0-placeholder.0 → 0.100.0-alpha.0

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 (283) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +49 -0
  3. package/es/_virtual/_plugin-vue_export-helper.mjs +10 -0
  4. package/es/bridge/badge.mjs +37 -0
  5. package/es/bridge/config-hook.mjs +58 -0
  6. package/es/bridge/contracts/event.mjs +102 -0
  7. package/es/bridge/contracts/index.mjs +5 -0
  8. package/es/bridge/event.mjs +87 -0
  9. package/es/bridge/index.mjs +331 -0
  10. package/es/bridge/layout.mjs +100 -0
  11. package/es/bridge/permission.mjs +91 -0
  12. package/es/bridge/plugin.mjs +39 -0
  13. package/es/bridge/route.mjs +78 -0
  14. package/es/bridge/state.mjs +61 -0
  15. package/es/bridge/storage.mjs +26 -0
  16. package/es/bridge/theme/index.mjs +233 -0
  17. package/es/bridge/theme/persist.mjs +18 -0
  18. package/es/bridge/theme/system-dark.mjs +18 -0
  19. package/es/components/basic/AppCollapseToggle.vue.mjs +7 -0
  20. package/es/components/basic/AppCollapseToggle.vue2.mjs +63 -0
  21. package/es/components/basic/action-btn/ActionBtn.vue.mjs +200 -0
  22. package/es/components/basic/action-btn/ActionBtn.vue2.mjs +4 -0
  23. package/es/components/basic/action-btn/index.mjs +4 -0
  24. package/es/components/basic/action-btn/use-action-btn-report.mjs +54 -0
  25. package/es/components/basic/action-btn-group/ActionBtnGroup.vue.mjs +69 -0
  26. package/es/components/basic/action-btn-group/ActionBtnGroup.vue2.mjs +4 -0
  27. package/es/components/basic/action-btn-group/index.mjs +4 -0
  28. package/es/components/basic/action-btn-group/use-action-btn-group-report.mjs +30 -0
  29. package/es/components/basic/display-contracts/index.mjs +1 -0
  30. package/es/components/basic/drag-float/DragFloat.vue.mjs +7 -0
  31. package/es/components/basic/drag-float/DragFloat.vue2.mjs +109 -0
  32. package/es/components/basic/drag-float/index.mjs +4 -0
  33. package/es/components/basic/height-provider/HeightProvider.vue.mjs +62 -0
  34. package/es/components/basic/height-provider/HeightProvider.vue2.mjs +4 -0
  35. package/es/components/basic/height-provider/index.mjs +4 -0
  36. package/es/components/basic/index.mjs +4 -0
  37. package/es/components/basic/shadow-clone/ShadowClone.vue.mjs +32 -0
  38. package/es/components/basic/shadow-clone/ShadowClone.vue2.mjs +4 -0
  39. package/es/components/basic/shadow-clone/index.mjs +4 -0
  40. package/es/components/basic/shadow-clone/use-shadow-target.mjs +76 -0
  41. package/es/components/basic/slot-layout-flow-aside/SlotLayoutFlowAside.vue.mjs +7 -0
  42. package/es/components/basic/slot-layout-flow-aside/SlotLayoutFlowAside.vue2.mjs +68 -0
  43. package/es/components/basic/slot-layout-flow-aside/index.mjs +4 -0
  44. package/es/components/basic/slot-layout-template/SlotLayoutTemplate.vue.mjs +30 -0
  45. package/es/components/basic/slot-layout-template/SlotLayoutTemplate.vue2.mjs +4 -0
  46. package/es/components/basic/slot-layout-template/index.mjs +4 -0
  47. package/es/components/basic/watch-size/WatchSize.vue.mjs +73 -0
  48. package/es/components/basic/watch-size/WatchSize.vue2.mjs +4 -0
  49. package/es/components/basic/watch-size/index.mjs +4 -0
  50. package/es/components/config/app-theme/AppTheme.vue.mjs +7 -0
  51. package/es/components/config/app-theme/AppTheme.vue2.mjs +82 -0
  52. package/es/components/config/app-theme/index.mjs +4 -0
  53. package/es/components/data/badge-mark/BadgeMark.vue.mjs +7 -0
  54. package/es/components/data/badge-mark/BadgeMark.vue2.mjs +80 -0
  55. package/es/components/data/badge-mark/index.mjs +4 -0
  56. package/es/components/data/badge-mark/use-badge-mask.mjs +82 -0
  57. package/es/components/data/badge-mark/use-badge.mjs +106 -0
  58. package/es/components/data/boolean-tag/BooleanTag.vue.mjs +36 -0
  59. package/es/components/data/boolean-tag/BooleanTag.vue2.mjs +4 -0
  60. package/es/components/data/boolean-tag/index.mjs +4 -0
  61. package/es/components/data/image-preview-trigger/ImagePreviewTrigger.vue.mjs +38 -0
  62. package/es/components/data/image-preview-trigger/ImagePreviewTrigger.vue2.mjs +4 -0
  63. package/es/components/data/image-preview-trigger/index.mjs +4 -0
  64. package/es/components/data/modal-image-preview/ModalImagePreview.vue.mjs +52 -0
  65. package/es/components/data/modal-image-preview/ModalImagePreview.vue2.mjs +4 -0
  66. package/es/components/data/modal-image-preview/index.mjs +4 -0
  67. package/es/components/feedback/action-confirm/ActionConfirm.vue.mjs +7 -0
  68. package/es/components/feedback/action-confirm/ActionConfirm.vue2.mjs +143 -0
  69. package/es/components/feedback/action-confirm/index.mjs +4 -0
  70. package/es/components/feedback/modal-confirm/ModalConfirm.vue.mjs +8 -0
  71. package/es/components/feedback/modal-confirm/ModalConfirm.vue2.mjs +243 -0
  72. package/es/components/feedback/modal-confirm/index.mjs +4 -0
  73. package/es/components/feedback/modal-video-preview/ModalVideoPreview.vue.mjs +8 -0
  74. package/es/components/feedback/modal-video-preview/ModalVideoPreview.vue2.mjs +93 -0
  75. package/es/components/feedback/modal-video-preview/index.mjs +4 -0
  76. package/es/components/feedback/preview-keys/index.mjs +7 -0
  77. package/es/components/feedback/preview-keys/keys.mjs +7 -0
  78. package/es/components/feedback/shelf-contracts/index.mjs +1 -0
  79. package/es/components/feedback/video-preview-trigger/VideoPreviewTrigger.vue.mjs +7 -0
  80. package/es/components/feedback/video-preview-trigger/VideoPreviewTrigger.vue2.mjs +133 -0
  81. package/es/components/feedback/video-preview-trigger/index.mjs +4 -0
  82. package/es/components/other/TriggerAutoImport.vue.mjs +12 -0
  83. package/es/components/other/TriggerAutoImport.vue2.mjs +4 -0
  84. package/es/components/other/auto-refresh/AutoRefresh.vue.mjs +7 -0
  85. package/es/components/other/auto-refresh/AutoRefresh.vue2.mjs +96 -0
  86. package/es/components/other/auto-refresh/index.mjs +4 -0
  87. package/es/components/other/auto-refresh/use-auto-refresh-report.mjs +31 -0
  88. package/es/components/other/auto-refresh-contracts/index.mjs +1 -0
  89. package/es/components/other/auto-refresh-group/AutoRefreshGroup.vue.mjs +7 -0
  90. package/es/components/other/auto-refresh-group/AutoRefreshGroup.vue2.mjs +69 -0
  91. package/es/components/other/auto-refresh-group/index.mjs +4 -0
  92. package/es/components/other/auto-refresh-group/use-auto-refresh-group-report.mjs +12 -0
  93. package/es/components/other/index.mjs +4 -0
  94. package/es/config/badge-attr.mjs +6 -0
  95. package/es/config/index.mjs +19 -0
  96. package/es/config/list-model.mjs +13 -0
  97. package/es/config/modal-keys.mjs +6 -0
  98. package/es/config/route.mjs +6 -0
  99. package/es/config/slot-region.mjs +45 -0
  100. package/es/helpers/form.mjs +25 -0
  101. package/es/helpers/index.mjs +10 -0
  102. package/es/helpers/list-helper.mjs +77 -0
  103. package/es/hooks/activated.mjs +64 -0
  104. package/es/hooks/feel-size.mjs +46 -0
  105. package/es/hooks/index.mjs +31 -0
  106. package/es/hooks/menus-dispatch.mjs +85 -0
  107. package/es/hooks/timeout.mjs +36 -0
  108. package/es/hooks/use-active-record.mjs +104 -0
  109. package/es/hooks/use-breakpoint.mjs +48 -0
  110. package/es/hooks/use-bridge-report.mjs +12 -0
  111. package/es/hooks/use-channel-viewport-height.mjs +43 -0
  112. package/es/hooks/use-context-defaults.mjs +44 -0
  113. package/es/hooks/use-custom-breakpoint.mjs +69 -0
  114. package/es/hooks/use-is-dev.mjs +16 -0
  115. package/es/hooks/use-observe-size.mjs +43 -0
  116. package/es/hooks/use-permission.mjs +12 -0
  117. package/es/hooks/use-surface.mjs +35 -0
  118. package/es/hooks/use-theme-apply.mjs +496 -0
  119. package/es/hooks/use-viewport-apply.mjs +52 -0
  120. package/es/index.mjs +179 -0
  121. package/es/inject/index.mjs +19 -0
  122. package/es/inject/key.mjs +70 -0
  123. package/es/injection-namespace.mjs +4 -0
  124. package/es/internals/index.mjs +16 -0
  125. package/es/router/group-redirect.mjs +26 -0
  126. package/es/router/guard/index.mjs +36 -0
  127. package/es/router/guard/login.mjs +6 -0
  128. package/es/router/guard/permission.mjs +6 -0
  129. package/es/router/index.mjs +10 -0
  130. package/es/store/app.mjs +306 -0
  131. package/es/store/index.mjs +8 -0
  132. package/es/store/router-permission.mjs +94 -0
  133. package/es/store/user.mjs +128 -0
  134. package/es/style.css +339 -0
  135. package/es/types/index.mjs +1 -0
  136. package/es/utils/dom.mjs +42 -0
  137. package/es/utils/export.mjs +39 -0
  138. package/es/utils/gap-scale.mjs +25 -0
  139. package/es/utils/id.mjs +7 -0
  140. package/es/utils/index.mjs +37 -0
  141. package/es/utils/permission.mjs +31 -0
  142. package/es/utils/router.mjs +42 -0
  143. package/es/utils/theme-scale.mjs +86 -0
  144. package/es/utils/time.mjs +24 -0
  145. package/package.json +232 -1
  146. package/types/bridge/badge.d.ts +215 -0
  147. package/types/bridge/config-hook.d.ts +12 -0
  148. package/types/bridge/contracts/bridge.d.ts +339 -0
  149. package/types/bridge/contracts/config.d.ts +519 -0
  150. package/types/bridge/contracts/event.d.ts +546 -0
  151. package/types/bridge/contracts/index.d.ts +3 -0
  152. package/types/bridge/event.d.ts +3 -0
  153. package/types/bridge/index.d.ts +28 -0
  154. package/types/bridge/layout.d.ts +102 -0
  155. package/types/bridge/permission.d.ts +31 -0
  156. package/types/bridge/plugin.d.ts +11 -0
  157. package/types/bridge/route.d.ts +36 -0
  158. package/types/bridge/state.d.ts +26 -0
  159. package/types/bridge/storage.d.ts +10 -0
  160. package/types/bridge/theme/index.d.ts +10 -0
  161. package/types/bridge/theme/persist.d.ts +23 -0
  162. package/types/bridge/theme/system-dark.d.ts +14 -0
  163. package/types/bridge/theme/types.d.ts +346 -0
  164. package/types/components/basic/AppCollapseToggle.vue.d.ts +14 -0
  165. package/types/components/basic/action-btn/ActionBtn.vue.d.ts +19 -0
  166. package/types/components/basic/action-btn/index.d.ts +1 -0
  167. package/types/components/basic/action-btn/use-action-btn-report.d.ts +12 -0
  168. package/types/components/basic/action-btn-group/ActionBtnGroup.vue.d.ts +18 -0
  169. package/types/components/basic/action-btn-group/index.d.ts +1 -0
  170. package/types/components/basic/action-btn-group/use-action-btn-group-report.d.ts +6 -0
  171. package/types/components/basic/display-contracts/index.d.ts +1 -0
  172. package/types/components/basic/display-contracts/types.d.ts +280 -0
  173. package/types/components/basic/drag-float/DragFloat.vue.d.ts +35 -0
  174. package/types/components/basic/drag-float/index.d.ts +1 -0
  175. package/types/components/basic/height-provider/HeightProvider.vue.d.ts +28 -0
  176. package/types/components/basic/height-provider/index.d.ts +1 -0
  177. package/types/components/basic/index.d.ts +1 -0
  178. package/types/components/basic/shadow-clone/ShadowClone.vue.d.ts +20 -0
  179. package/types/components/basic/shadow-clone/index.d.ts +1 -0
  180. package/types/components/basic/shadow-clone/use-shadow-target.d.ts +9 -0
  181. package/types/components/basic/slot-layout-flow-aside/SlotLayoutFlowAside.vue.d.ts +32 -0
  182. package/types/components/basic/slot-layout-flow-aside/index.d.ts +2 -0
  183. package/types/components/basic/slot-layout-flow-aside/types.d.ts +10 -0
  184. package/types/components/basic/slot-layout-template/SlotLayoutTemplate.vue.d.ts +48 -0
  185. package/types/components/basic/slot-layout-template/index.d.ts +1 -0
  186. package/types/components/basic/watch-size/WatchSize.vue.d.ts +45 -0
  187. package/types/components/basic/watch-size/index.d.ts +1 -0
  188. package/types/components/config/app-theme/AppTheme.vue.d.ts +2 -0
  189. package/types/components/config/app-theme/index.d.ts +1 -0
  190. package/types/components/data/badge-mark/BadgeMark.vue.d.ts +212 -0
  191. package/types/components/data/badge-mark/index.d.ts +1 -0
  192. package/types/components/data/badge-mark/use-badge-mask.d.ts +8 -0
  193. package/types/components/data/badge-mark/use-badge.d.ts +78 -0
  194. package/types/components/data/boolean-tag/BooleanTag.vue.d.ts +8 -0
  195. package/types/components/data/boolean-tag/index.d.ts +1 -0
  196. package/types/components/data/image-preview-trigger/ImagePreviewTrigger.vue.d.ts +41 -0
  197. package/types/components/data/image-preview-trigger/index.d.ts +1 -0
  198. package/types/components/data/modal-image-preview/ModalImagePreview.vue.d.ts +31 -0
  199. package/types/components/data/modal-image-preview/index.d.ts +1 -0
  200. package/types/components/feedback/action-confirm/ActionConfirm.vue.d.ts +33 -0
  201. package/types/components/feedback/action-confirm/index.d.ts +1 -0
  202. package/types/components/feedback/modal-confirm/ModalConfirm.vue.d.ts +120 -0
  203. package/types/components/feedback/modal-confirm/index.d.ts +2 -0
  204. package/types/components/feedback/modal-confirm/types.d.ts +4 -0
  205. package/types/components/feedback/modal-video-preview/ModalVideoPreview.vue.d.ts +40 -0
  206. package/types/components/feedback/modal-video-preview/index.d.ts +1 -0
  207. package/types/components/feedback/preview-keys/index.d.ts +2 -0
  208. package/types/components/feedback/preview-keys/keys.d.ts +14 -0
  209. package/types/components/feedback/shelf-contracts/index.d.ts +1 -0
  210. package/types/components/feedback/shelf-contracts/types.d.ts +1 -0
  211. package/types/components/feedback/video-preview-trigger/VideoPreviewTrigger.vue.d.ts +46 -0
  212. package/types/components/feedback/video-preview-trigger/index.d.ts +1 -0
  213. package/types/components/other/TriggerAutoImport.vue.d.ts +17 -0
  214. package/types/components/other/auto-refresh/AutoRefresh.vue.d.ts +14 -0
  215. package/types/components/other/auto-refresh/index.d.ts +1 -0
  216. package/types/components/other/auto-refresh/use-auto-refresh-report.d.ts +1 -0
  217. package/types/components/other/auto-refresh-contracts/index.d.ts +1 -0
  218. package/types/components/other/auto-refresh-contracts/types.d.ts +17 -0
  219. package/types/components/other/auto-refresh-group/AutoRefreshGroup.vue.d.ts +18 -0
  220. package/types/components/other/auto-refresh-group/index.d.ts +1 -0
  221. package/types/components/other/auto-refresh-group/use-auto-refresh-group-report.d.ts +3 -0
  222. package/types/components/other/index.d.ts +1 -0
  223. package/types/config/badge-attr.d.ts +26 -0
  224. package/types/config/index.d.ts +5 -0
  225. package/types/config/list-model.d.ts +49 -0
  226. package/types/config/modal-keys.d.ts +12 -0
  227. package/types/config/route.d.ts +4 -0
  228. package/types/config/slot-region.d.ts +72 -0
  229. package/types/helpers/form.d.ts +8 -0
  230. package/types/helpers/index.d.ts +3 -0
  231. package/types/helpers/list-helper.d.ts +35 -0
  232. package/types/helpers/types.d.ts +15 -0
  233. package/types/hooks/activated.d.ts +36 -0
  234. package/types/hooks/feel-size.d.ts +10 -0
  235. package/types/hooks/index.d.ts +12 -0
  236. package/types/hooks/menus-dispatch.d.ts +35 -0
  237. package/types/hooks/timeout.d.ts +7 -0
  238. package/types/hooks/use-active-record.d.ts +64 -0
  239. package/types/hooks/use-breakpoint.d.ts +4 -0
  240. package/types/hooks/use-bridge-report.d.ts +3 -0
  241. package/types/hooks/use-channel-viewport-height.d.ts +22 -0
  242. package/types/hooks/use-context-defaults.d.ts +39 -0
  243. package/types/hooks/use-custom-breakpoint.d.ts +17 -0
  244. package/types/hooks/use-is-dev.d.ts +24 -0
  245. package/types/hooks/use-observe-size.d.ts +36 -0
  246. package/types/hooks/use-permission.d.ts +14 -0
  247. package/types/hooks/use-surface.d.ts +45 -0
  248. package/types/hooks/use-theme-apply.d.ts +34 -0
  249. package/types/hooks/use-viewport-apply.d.ts +20 -0
  250. package/types/index.d.ts +33 -0
  251. package/types/inject/index.d.ts +1 -0
  252. package/types/inject/key.d.ts +247 -0
  253. package/types/injection-namespace.d.ts +4 -0
  254. package/types/internals/index.d.ts +6 -0
  255. package/types/router/group-redirect.d.ts +14 -0
  256. package/types/router/guard/index.d.ts +20 -0
  257. package/types/router/guard/login.d.ts +4 -0
  258. package/types/router/guard/permission.d.ts +4 -0
  259. package/types/router/guard/types.d.ts +14 -0
  260. package/types/router/index.d.ts +2 -0
  261. package/types/store/app.d.ts +219 -0
  262. package/types/store/index.d.ts +3 -0
  263. package/types/store/router-permission.d.ts +79 -0
  264. package/types/store/user.d.ts +64 -0
  265. package/types/types/app-layout.d.ts +42 -0
  266. package/types/types/dc-path.d.ts +2 -0
  267. package/types/types/dot-path.d.ts +13 -0
  268. package/types/types/index.d.ts +9 -0
  269. package/types/types/list-api.d.ts +17 -0
  270. package/types/types/modal-shelf.d.ts +123 -0
  271. package/types/types/nest-form.d.ts +8 -0
  272. package/types/types/permission.d.ts +31 -0
  273. package/types/types/route.d.ts +141 -0
  274. package/types/types/utility-types.d.ts +25 -0
  275. package/types/utils/dom.d.ts +61 -0
  276. package/types/utils/export.d.ts +35 -0
  277. package/types/utils/gap-scale.d.ts +46 -0
  278. package/types/utils/id.d.ts +2 -0
  279. package/types/utils/index.d.ts +8 -0
  280. package/types/utils/permission.d.ts +16 -0
  281. package/types/utils/router.d.ts +18 -0
  282. package/types/utils/theme-scale.d.ts +78 -0
  283. package/types/utils/time.d.ts +2 -0
@@ -0,0 +1,85 @@
1
+ import { computed } from "vue";
2
+ import { useRoute } from "vue-router";
3
+ import { ROUTE_MODULE_LEVEL } from "../config/route.mjs";
4
+ const useMenusDataDispatch = ({
5
+ getMenus,
6
+ getMenuFlatList,
7
+ getExtractLevel1ToHeader
8
+ }) => {
9
+ const menus = computed(getMenus);
10
+ const menuFlatList = computed(getMenuFlatList);
11
+ const extractLevel1ToHeader = computed(getExtractLevel1ToHeader);
12
+ const route = useRoute();
13
+ const activeMenu = computed(() => {
14
+ return menuFlatList.value.find((item) => {
15
+ return item.path === route.path;
16
+ });
17
+ });
18
+ const needRedirectToFirstChildMenu = computed(
19
+ () => activeMenu.value && getCanRedirectFirstChildMenu(activeMenu.value, true)
20
+ );
21
+ const activeModulePath = computed(() => {
22
+ var _a;
23
+ if (!activeMenu.value) {
24
+ const menuMeta = (_a = route.meta) == null ? void 0 : _a.menu;
25
+ const hasMenuIntent = !!menuMeta && menuMeta.show !== false;
26
+ if (hasMenuIntent) {
27
+ console.warn(
28
+ `当前 ${route.path} 未找到聚焦的菜单 可能路由配置不展示菜单`
29
+ );
30
+ }
31
+ return;
32
+ }
33
+ if (activeMenu.value.routeLevel === ROUTE_MODULE_LEVEL) {
34
+ return activeMenu.value.path;
35
+ } else {
36
+ return activeMenu.value.parentPathList[0];
37
+ }
38
+ });
39
+ const activeModuleMenu = computed(() => {
40
+ return activeModulePath.value ? menus.value.find((item) => item.path === activeModulePath.value) : void 0;
41
+ });
42
+ const activeModuleMenuChildrenMenu = computed(() => {
43
+ var _a;
44
+ return (_a = activeModuleMenu.value) == null ? void 0 : _a.children;
45
+ });
46
+ const sidebarMenus = computed(() => {
47
+ return extractLevel1ToHeader.value ? activeModuleMenuChildrenMenu.value || [] : menus.value;
48
+ });
49
+ const routeModuleLevelList = computed(() => {
50
+ return menus.value.filter((item) => item.routeLevel === ROUTE_MODULE_LEVEL);
51
+ });
52
+ const routeModuleLevel1ListNoChildren = computed(
53
+ () => routeModuleLevelList.value.map((item) => {
54
+ return {
55
+ ...item,
56
+ // 避免 展示子菜单
57
+ children: []
58
+ };
59
+ })
60
+ );
61
+ const headerMenus = computed(() => {
62
+ return extractLevel1ToHeader.value ? routeModuleLevel1ListNoChildren.value : [];
63
+ });
64
+ const getCanRedirectFirstChildMenu = (menu, isInitCall) => {
65
+ if (menu.redirectToFirstChildRoute) {
66
+ const firstChild = menu.children[0];
67
+ if (firstChild) {
68
+ return getCanRedirectFirstChildMenu(firstChild, false);
69
+ }
70
+ }
71
+ if (!isInitCall) {
72
+ return menu;
73
+ }
74
+ };
75
+ return {
76
+ sidebarMenus,
77
+ headerMenus,
78
+ activeMenu,
79
+ activeModuleMenu,
80
+ needRedirectToFirstChildMenu
81
+ };
82
+ };
83
+ export {
84
+ useMenusDataDispatch
85
+ };
@@ -0,0 +1,36 @@
1
+ import { ref, onBeforeUnmount, watch } from "vue";
2
+ import { useActivated } from "./activated.mjs";
3
+ const useTimeout = (autoClear = true) => {
4
+ const { isActivated } = useActivated();
5
+ const timer = ref(void 0);
6
+ const clearTimer = () => {
7
+ if (timer.value !== null && timer.value !== void 0) {
8
+ clearTimeout(timer.value);
9
+ timer.value = void 0;
10
+ }
11
+ };
12
+ const setTimer = (handler, timeout) => {
13
+ clearTimer();
14
+ timer.value = setTimeout(handler, timeout);
15
+ };
16
+ if (autoClear) {
17
+ onBeforeUnmount(clearTimer);
18
+ }
19
+ watch(
20
+ isActivated,
21
+ (n) => {
22
+ if (!n) {
23
+ if (autoClear) {
24
+ clearTimer();
25
+ }
26
+ }
27
+ },
28
+ {
29
+ immediate: true
30
+ }
31
+ );
32
+ return [setTimer, clearTimer];
33
+ };
34
+ export {
35
+ useTimeout
36
+ };
@@ -0,0 +1,104 @@
1
+ import { watch } from "vue";
2
+ import { useActivated } from "./activated.mjs";
3
+ const activeRecordValueOf = (row, rowKey) => typeof rowKey === "function" ? rowKey(row) : row[rowKey];
4
+ const normalizeActiveKey = (v) => String(v);
5
+ function useActiveRecord(options) {
6
+ const { data, keyOf, activeId, activeData, name } = options;
7
+ const enabled = () => {
8
+ var _a;
9
+ return ((_a = options.enabled) == null ? void 0 : _a.call(options)) ?? true;
10
+ };
11
+ let lastValidId;
12
+ let lastValidData;
13
+ const findRow = (id) => data().find(
14
+ (row) => normalizeActiveKey(keyOf(row)) === normalizeActiveKey(id)
15
+ );
16
+ const setActive = (row) => {
17
+ const id = row ? keyOf(row) : void 0;
18
+ lastValidId = id;
19
+ lastValidData = row;
20
+ activeId.value = id;
21
+ activeData.value = row;
22
+ };
23
+ const warnMissing = (what, shown) => {
24
+ console.warn(
25
+ `[${name}] ${what} ${shown} 不在当前列表数据内,已忽略。当前项 [MUST] 由列表内选择产生(不变式:先有列表,才有详情);深链请把 id 带进搜索条件筛出该条后再激活。`
26
+ );
27
+ };
28
+ const applyId = (id) => {
29
+ if (id === lastValidId) return;
30
+ if (id === void 0) {
31
+ lastValidData = void 0;
32
+ activeData.value = void 0;
33
+ return;
34
+ }
35
+ const row = findRow(id);
36
+ if (!row) {
37
+ warnMissing("activeId", `"${String(id)}"`);
38
+ activeId.value = lastValidId;
39
+ return;
40
+ }
41
+ lastValidId = id;
42
+ lastValidData = row;
43
+ activeData.value = row;
44
+ };
45
+ const applyData = (row) => {
46
+ if (row === lastValidData) return;
47
+ if (row === void 0) {
48
+ lastValidData = void 0;
49
+ lastValidId = void 0;
50
+ activeId.value = void 0;
51
+ return;
52
+ }
53
+ const id = keyOf(row);
54
+ if (!findRow(id)) {
55
+ warnMissing("activeData 对应的键", `"${String(id)}"`);
56
+ activeData.value = lastValidData;
57
+ return;
58
+ }
59
+ lastValidData = row;
60
+ lastValidId = id;
61
+ activeId.value = id;
62
+ };
63
+ watch(activeId, (id) => {
64
+ if (!enabled()) return;
65
+ applyId(id);
66
+ });
67
+ watch(activeData, (row) => {
68
+ if (!enabled()) return;
69
+ applyData(row);
70
+ });
71
+ useActivated((info) => {
72
+ if (!info.isActivated || !enabled()) return;
73
+ if (data().length === 0) return;
74
+ if (activeId.value !== void 0) applyId(activeId.value);
75
+ else if (activeData.value !== void 0) applyData(activeData.value);
76
+ });
77
+ watch(
78
+ () => data(),
79
+ () => {
80
+ if (!enabled()) return;
81
+ const id = activeId.value;
82
+ if (id === void 0) {
83
+ if (activeData.value !== void 0) applyData(activeData.value);
84
+ return;
85
+ }
86
+ const row = findRow(id);
87
+ if (row) {
88
+ lastValidData = row;
89
+ activeData.value = row;
90
+ return;
91
+ }
92
+ lastValidData = void 0;
93
+ lastValidId = void 0;
94
+ activeId.value = void 0;
95
+ activeData.value = void 0;
96
+ }
97
+ );
98
+ const isActive = (row) => activeId.value !== void 0 && normalizeActiveKey(keyOf(row)) === normalizeActiveKey(activeId.value);
99
+ return { isActive, setActive };
100
+ }
101
+ export {
102
+ activeRecordValueOf,
103
+ useActiveRecord
104
+ };
@@ -0,0 +1,48 @@
1
+ import { ref, readonly } from "vue";
2
+ import { useActivated } from "./activated.mjs";
3
+ const QUERIES = [];
4
+ const DESCENDING = ["xl", "lg", "md", "sm"];
5
+ const initQueries = () => {
6
+ if (QUERIES.length) return;
7
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function")
8
+ return;
9
+ const map = {
10
+ xl: "(min-width: 1920px)",
11
+ lg: "(min-width: 1200px)",
12
+ md: "(min-width: 992px)",
13
+ sm: "(min-width: 768px)",
14
+ xs: "(max-width: 767px)"
15
+ };
16
+ for (const key of DESCENDING) {
17
+ QUERIES.push({ key, mql: window.matchMedia(map[key]) });
18
+ }
19
+ };
20
+ const useBreakpoint = () => {
21
+ const activeBreakpoint = ref("lg");
22
+ const evaluate = () => {
23
+ for (const { key, mql } of QUERIES) {
24
+ if (mql.matches) {
25
+ activeBreakpoint.value = key;
26
+ return;
27
+ }
28
+ }
29
+ activeBreakpoint.value = "xs";
30
+ };
31
+ useActivated((info) => {
32
+ if (info.isActivated) {
33
+ initQueries();
34
+ evaluate();
35
+ for (const { mql } of QUERIES) {
36
+ mql.addEventListener("change", evaluate);
37
+ }
38
+ } else {
39
+ for (const { mql } of QUERIES) {
40
+ mql.removeEventListener("change", evaluate);
41
+ }
42
+ }
43
+ });
44
+ return { activeBreakpoint: readonly(activeBreakpoint) };
45
+ };
46
+ export {
47
+ useBreakpoint
48
+ };
@@ -0,0 +1,12 @@
1
+ import { inject } from "vue";
2
+ import { CORE_BRIDGE_KEY } from "../inject/key.mjs";
3
+ function useBridgeReport() {
4
+ const bridge = inject(CORE_BRIDGE_KEY, void 0);
5
+ return (...args) => {
6
+ if (!bridge) return;
7
+ bridge.emitEvent({ event: args[0], data: args[1] });
8
+ };
9
+ }
10
+ export {
11
+ useBridgeReport
12
+ };
@@ -0,0 +1,43 @@
1
+ import { inject, computed, watch } from "vue";
2
+ import { SCOPE_VIEWPORT_MAX_HEIGHT } from "../inject/key.mjs";
3
+ const SCOPE_CHAIN_MAX_DEPTH = 100;
4
+ const useChannelViewportHeight = (maybeProps, options = {}) => {
5
+ const fallback = options.fallback ?? 0;
6
+ const parentChannel = maybeProps.parentChannel;
7
+ const nearestScope = inject(SCOPE_VIEWPORT_MAX_HEIGHT, void 0);
8
+ const resolveScopeHeight = () => {
9
+ if (!nearestScope) return void 0;
10
+ if (!parentChannel) return nearestScope.viewportMaxHeight.value;
11
+ let cur = nearestScope;
12
+ let depth = 0;
13
+ while (cur) {
14
+ if (cur.scope === parentChannel) return cur.viewportMaxHeight.value;
15
+ cur = cur.parent;
16
+ if (++depth > SCOPE_CHAIN_MAX_DEPTH) {
17
+ console.error(
18
+ "[useChannelViewportHeight] scope 链超深(疑似环链),已降级 fallback。"
19
+ );
20
+ return void 0;
21
+ }
22
+ }
23
+ return void 0;
24
+ };
25
+ const viewportHeightFinal = computed(() => {
26
+ if (maybeProps.viewportHeight !== void 0)
27
+ return maybeProps.viewportHeight;
28
+ const scoped = resolveScopeHeight();
29
+ if (scoped !== void 0) return scoped;
30
+ return fallback;
31
+ });
32
+ watch(
33
+ // eslint-disable-next-line vue/no-setup-props-destructure
34
+ () => maybeProps.parentChannel,
35
+ () => console.error(
36
+ "[useChannelViewportHeight] parentChannel 不支持响应式变更,当前值已忽略。"
37
+ )
38
+ );
39
+ return { viewportHeightFinal, nearestScope };
40
+ };
41
+ export {
42
+ useChannelViewportHeight
43
+ };
@@ -0,0 +1,44 @@
1
+ import { getCurrentInstance, shallowRef, computed } from "vue";
2
+ import { DC_SLOT_ATTR, parseSlotRegion } from "../config/slot-region.mjs";
3
+ import { useActivated } from "./activated.mjs";
4
+ const useContextDefaults = (options) => {
5
+ var _a, _b;
6
+ const instance = getCurrentInstance();
7
+ const region = shallowRef(void 0);
8
+ useActivated((info) => {
9
+ var _a2, _b2;
10
+ if (info.isActivated && region.value === void 0) {
11
+ const el = (_a2 = instance == null ? void 0 : instance.proxy) == null ? void 0 : _a2.$el;
12
+ const raw = (_b2 = el == null ? void 0 : el.parentElement) == null ? void 0 : _b2.getAttribute(DC_SLOT_ATTR);
13
+ region.value = parseSlotRegion(raw);
14
+ }
15
+ });
16
+ try {
17
+ const defs = (_b = (_a = instance == null ? void 0 : instance.vnode) == null ? void 0 : _a.type) == null ? void 0 : _b.props;
18
+ if (defs) {
19
+ for (const key of Object.keys(options.defaults)) {
20
+ const def = defs[key];
21
+ if (def && "default" in def && def.default !== void 0) {
22
+ console.warn(
23
+ `[useContextDefaults] prop "${key}" 在 withDefaults 设了内建默认(${String(
24
+ def.default
25
+ )})——会短路 \`props.xx ?? 上下文默认\` 合并,上下文默认静默失效。[MUST] 上下文默认 prop 的 withDefaults 只填 undefined。详见 spec 2026-08-14 useContextDefaults。`
26
+ );
27
+ }
28
+ }
29
+ }
30
+ } catch {
31
+ }
32
+ const result = {};
33
+ for (const key of Object.keys(options.defaults)) {
34
+ const resolver = options.defaults[key];
35
+ const ctxKey = `ctx${key.charAt(0).toUpperCase()}${key.slice(1)}`;
36
+ result[ctxKey] = computed(
37
+ () => resolver({ props: options.getProps(), parentInfo: region.value })
38
+ );
39
+ }
40
+ return result;
41
+ };
42
+ export {
43
+ useContextDefaults
44
+ };
@@ -0,0 +1,69 @@
1
+ import { shallowRef, ref, watch, onScopeDispose, readonly } from "vue";
2
+ import { useActivated } from "./activated.mjs";
3
+ const DESCENDING_THRESHOLDS = [
4
+ { key: "xl", min: 1920 },
5
+ { key: "lg", min: 1200 },
6
+ { key: "md", min: 992 },
7
+ { key: "sm", min: 768 }
8
+ ];
9
+ const resolveBreakpointByWidth = (width) => {
10
+ for (const { key, min } of DESCENDING_THRESHOLDS) {
11
+ if (width >= min) return key;
12
+ }
13
+ return "xs";
14
+ };
15
+ const resolveRootEl = (target) => {
16
+ if (!target) return null;
17
+ if (typeof HTMLElement === "undefined") return null;
18
+ if (target instanceof HTMLElement) return target;
19
+ const el = target.$el;
20
+ if (el instanceof HTMLElement) return el;
21
+ return null;
22
+ };
23
+ const resolveInitialBreakpoint = () => {
24
+ const viewportWidth = typeof window === "undefined" ? 0 : window.innerWidth;
25
+ return viewportWidth > 0 ? resolveBreakpointByWidth(viewportWidth) : "lg";
26
+ };
27
+ const useCustomBreakpoint = () => {
28
+ const elRef = shallowRef();
29
+ const activeBreakpoint = ref(resolveInitialBreakpoint());
30
+ const measured = ref(false);
31
+ const { isActivated } = useActivated();
32
+ let ro;
33
+ const evaluate = (el) => {
34
+ activeBreakpoint.value = resolveBreakpointByWidth(
35
+ el.getBoundingClientRect().width
36
+ );
37
+ measured.value = true;
38
+ };
39
+ const detach = () => {
40
+ ro == null ? void 0 : ro.disconnect();
41
+ ro = void 0;
42
+ };
43
+ const attach = () => {
44
+ const el = resolveRootEl(elRef.value);
45
+ if (!el || typeof ResizeObserver === "undefined") return;
46
+ evaluate(el);
47
+ ro = new ResizeObserver(() => evaluate(el));
48
+ ro.observe(el);
49
+ };
50
+ watch(
51
+ [isActivated, elRef],
52
+ ([active]) => {
53
+ detach();
54
+ if (active) attach();
55
+ },
56
+ { immediate: true, flush: "post" }
57
+ );
58
+ onScopeDispose(detach);
59
+ return {
60
+ elRef,
61
+ activeBreakpoint: readonly(activeBreakpoint),
62
+ measured: readonly(measured)
63
+ };
64
+ };
65
+ export {
66
+ resolveBreakpointByWidth,
67
+ resolveRootEl,
68
+ useCustomBreakpoint
69
+ };
@@ -0,0 +1,16 @@
1
+ import { inject } from "vue";
2
+ import { CORE_BRIDGE_KEY } from "../inject/key.mjs";
3
+ const useIsDev = () => {
4
+ const bridge = inject(CORE_BRIDGE_KEY, void 0);
5
+ return () => {
6
+ var _a, _b;
7
+ const fromBridge = (_a = bridge == null ? void 0 : bridge.APP_ENV_INFO) == null ? void 0 : _a.isDev;
8
+ if (fromBridge !== void 0) return fromBridge;
9
+ if (typeof process !== "undefined" && ((_b = process.env) == null ? void 0 : _b.NODE_ENV))
10
+ return process.env.NODE_ENV !== "production";
11
+ return true;
12
+ };
13
+ };
14
+ export {
15
+ useIsDev
16
+ };
@@ -0,0 +1,43 @@
1
+ import { watch, onScopeDispose } from "vue";
2
+ import _debounce from "lodash/debounce.js";
3
+ import { useActivated } from "./activated.mjs";
4
+ const useObserveSize = (options) => {
5
+ const { getTarget, onResize, enabled, debounce = 100 } = options;
6
+ const debounced = debounce > 0 ? _debounce(onResize, debounce, { leading: true, trailing: true }) : void 0;
7
+ const dispatch = debounced ?? onResize;
8
+ let ro;
9
+ let observedEl;
10
+ let active = false;
11
+ const stop = () => {
12
+ ro == null ? void 0 : ro.disconnect();
13
+ ro = void 0;
14
+ observedEl = void 0;
15
+ debounced == null ? void 0 : debounced.cancel();
16
+ };
17
+ const start = () => {
18
+ const el = getTarget() ?? void 0;
19
+ const shouldObserve = active && (enabled == null ? void 0 : enabled()) !== false && typeof ResizeObserver !== "undefined" && !!el;
20
+ if (!shouldObserve) {
21
+ stop();
22
+ return;
23
+ }
24
+ if (ro && observedEl === el) return;
25
+ stop();
26
+ ro = new ResizeObserver((entries) => {
27
+ const entry = entries[0];
28
+ if (entry) dispatch(entry);
29
+ });
30
+ ro.observe(el);
31
+ observedEl = el;
32
+ };
33
+ watch([getTarget, () => enabled == null ? void 0 : enabled()], () => start(), { flush: "post" });
34
+ useActivated((info) => {
35
+ active = info.isActivated;
36
+ if (active) start();
37
+ else stop();
38
+ });
39
+ onScopeDispose(stop);
40
+ };
41
+ export {
42
+ useObserveSize
43
+ };
@@ -0,0 +1,12 @@
1
+ import { inject } from "vue";
2
+ import { CORE_BRIDGE_KEY } from "../inject/key.mjs";
3
+ import { resolvePermissionRule } from "../utils/permission.mjs";
4
+ const usePermission = () => {
5
+ const bridge = inject(CORE_BRIDGE_KEY, void 0);
6
+ return {
7
+ can: (rule) => bridge ? bridge.havePermission(rule) : !resolvePermissionRule(rule)
8
+ };
9
+ };
10
+ export {
11
+ usePermission
12
+ };
@@ -0,0 +1,35 @@
1
+ import { inject, computed } from "vue";
2
+ import { SlotRegion } from "../config/slot-region.mjs";
3
+ import { APP_LAYOUT_BRIDGE_KEY } from "../inject/key.mjs";
4
+ import { gapScaleValue } from "../utils/gap-scale.mjs";
5
+ import { useContextDefaults } from "./use-context-defaults.mjs";
6
+ const useSurface = (getProps) => {
7
+ const { ctxSurface } = useContextDefaults({
8
+ getProps,
9
+ defaults: {
10
+ // 🔴 只对 **modal 正文**关面:那一档的底是抬升面(`--el-bg-color-overlay`)。
11
+ // **抽屉正文自 v0.32.0 起取底色**(`ModalConfirm_DrawerBody`)⇒ 那儿 [MUST] 自持面,
12
+ // 否则内容直接摊在底色上(与「空占位没有面」是同一种坏法,范围更大)。
13
+ // [MUST NOT] 写成 `parentInfo !== ModalConfirm_Body` 之外再排除抽屉档 ——
14
+ // 判据是「**脚下是不是一块面**」,抽屉那档的答案是「不是」。
15
+ surface: ({ parentInfo, props: rawProps }) => rawProps.surface ?? parentInfo !== SlotRegion.ModalConfirm_Body
16
+ }
17
+ });
18
+ const layoutBridge = inject(APP_LAYOUT_BRIDGE_KEY, void 0);
19
+ const surfaceActive = computed(() => !!ctxSurface.value);
20
+ const surfacePad = computed(
21
+ () => surfaceActive.value ? gapScaleValue(
22
+ (layoutBridge == null ? void 0 : layoutBridge.APP_LAYOUT_GAP_CONFIG.size) ?? 8,
23
+ "breath",
24
+ layoutBridge == null ? void 0 : layoutBridge.themeDensity.value
25
+ ) : 0
26
+ );
27
+ const surfacePadCss = computed(() => `${surfacePad.value}px`);
28
+ const surfaceBgActive = computed(
29
+ () => surfaceActive.value && !getProps().itemCard
30
+ );
31
+ return { surfaceActive, surfaceBgActive, surfacePad, surfacePadCss };
32
+ };
33
+ export {
34
+ useSurface
35
+ };