@vinicunca/taman-ui 0.1.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 (296) hide show
  1. package/README.md +95 -0
  2. package/dist/_virtual/_/plugin-vue/export-helper.mjs +8 -0
  3. package/dist/components/auth/index.d.ts +2 -0
  4. package/dist/components/auth/index.mjs +2 -0
  5. package/dist/components/auth/taman-auth-form.mjs +67 -0
  6. package/dist/components/auth/taman-auth-form.vue.d.ts +31 -0
  7. package/dist/components/back-to-top/index.mjs +2 -0
  8. package/dist/components/back-to-top/taman-back-to-top.mjs +70 -0
  9. package/dist/components/back-to-top/taman-back-to-top.vue.d.ts +18 -0
  10. package/dist/components/button/check-group-selection.mjs +17 -0
  11. package/dist/components/button/index.d.ts +4 -0
  12. package/dist/components/button/index.mjs +3 -0
  13. package/dist/components/button/taman-button-check-group.mjs +132 -0
  14. package/dist/components/button/taman-button-check-group.types.d.ts +22 -0
  15. package/dist/components/button/taman-button-check-group.vue.d.ts +41 -0
  16. package/dist/components/button/taman-button-icon.mjs +105 -0
  17. package/dist/components/button/taman-button-icon.vue.d.ts +17 -0
  18. package/dist/components/descriptions/index.d.ts +4 -0
  19. package/dist/components/descriptions/index.mjs +3 -0
  20. package/dist/components/descriptions/taman-description-cell.mjs +116 -0
  21. package/dist/components/descriptions/taman-description-item.mjs +10 -0
  22. package/dist/components/descriptions/taman-description-item.vue.d.ts +5 -0
  23. package/dist/components/descriptions/taman-description-row.mjs +131 -0
  24. package/dist/components/descriptions/taman-description.mjs +78 -0
  25. package/dist/components/descriptions/taman-description.types.d.ts +51 -0
  26. package/dist/components/descriptions/taman-description.vue.d.ts +23 -0
  27. package/dist/components/descriptions/use-taman-description.mjs +161 -0
  28. package/dist/components/file-upload/index.d.ts +3 -0
  29. package/dist/components/file-upload/index.mjs +2 -0
  30. package/dist/components/file-upload/taman-file-upload.mjs +88 -0
  31. package/dist/components/file-upload/taman-file-upload.types.d.ts +10 -0
  32. package/dist/components/file-upload/taman-file-upload.vue.d.ts +21 -0
  33. package/dist/components/full-screen/full-screen.mjs +27 -0
  34. package/dist/components/full-screen/full-screen.vue.d.ts +8 -0
  35. package/dist/components/full-screen/index.mjs +2 -0
  36. package/dist/components/icon/icon.mjs +27 -0
  37. package/dist/components/icon/icon.vue.d.ts +9 -0
  38. package/dist/components/icon/index.d.ts +2 -0
  39. package/dist/components/icon/index.mjs +2 -0
  40. package/dist/components/index.d.ts +34 -0
  41. package/dist/components/index.mjs +31 -0
  42. package/dist/components/input/index.d.ts +5 -0
  43. package/dist/components/input/index.mjs +4 -0
  44. package/dist/components/input/password-strength.d.ts +7 -0
  45. package/dist/components/input/password-strength.mjs +21 -0
  46. package/dist/components/input/taman-input-currency.mjs +76 -0
  47. package/dist/components/input/taman-input-currency.types.d.ts +8 -0
  48. package/dist/components/input/taman-input-currency.vue.d.ts +15 -0
  49. package/dist/components/input/taman-input-password.mjs +99 -0
  50. package/dist/components/input/taman-input-password.vue.d.ts +17 -0
  51. package/dist/components/input-date/format-calendar-input-value.mjs +26 -0
  52. package/dist/components/input-date/index.d.ts +3 -0
  53. package/dist/components/input-date/index.mjs +2 -0
  54. package/dist/components/input-date/taman-input-date.mjs +116 -0
  55. package/dist/components/input-date/taman-input-date.types.d.ts +14 -0
  56. package/dist/components/input-date/taman-input-date.vue.d.ts +21 -0
  57. package/dist/components/loading/index.d.ts +3 -0
  58. package/dist/components/loading/index.mjs +2 -0
  59. package/dist/components/loading/taman-loading.mjs +64 -0
  60. package/dist/components/loading/taman-loading.vue.d.ts +25 -0
  61. package/dist/components/loading/types.d.ts +13 -0
  62. package/dist/components/logo/index.mjs +2 -0
  63. package/dist/components/logo/taman-logo.mjs +60 -0
  64. package/dist/components/logo/taman-logo.vue.d.ts +32 -0
  65. package/dist/components/render-content/index.d.ts +2 -0
  66. package/dist/components/render-content/index.mjs +2 -0
  67. package/dist/components/render-content/render-content.mjs +42 -0
  68. package/dist/components/render-content/render-content.vue.d.ts +31 -0
  69. package/dist/components/scrollbar/index.d.ts +2 -0
  70. package/dist/components/scrollbar/index.mjs +2 -0
  71. package/dist/components/scrollbar/scrollbar.mjs +136 -0
  72. package/dist/components/scrollbar/scrollbar.vue.d.ts +50 -0
  73. package/dist/form/components/form-actions.mjs +151 -0
  74. package/dist/form/components/form-field-array.mjs +154 -0
  75. package/dist/form/components/form-field-array.types.d.ts +18 -0
  76. package/dist/form/form-render/form-render-field-collapsible.mjs +32 -0
  77. package/dist/form/form-render/form-render-field-control.mjs +44 -0
  78. package/dist/form/form-render/form-render-form-field.mjs +408 -0
  79. package/dist/form/form-render/form-render-form-label.mjs +46 -0
  80. package/dist/form/form-render/form-render-form.mjs +163 -0
  81. package/dist/form/form-render/form-render-group.mjs +89 -0
  82. package/dist/form/form-render/form-render.context.mjs +10 -0
  83. package/dist/form/form-render/form-render.dependencies.mjs +101 -0
  84. package/dist/form/form-render/form-render.helper.mjs +31 -0
  85. package/dist/form/form-render/form-render.schema.mjs +209 -0
  86. package/dist/form/form-render/index.mjs +4 -0
  87. package/dist/form/form.api.d.ts +54 -0
  88. package/dist/form/form.api.mjs +324 -0
  89. package/dist/form/form.built-ins.d.ts +36 -0
  90. package/dist/form/form.built-ins.mjs +48 -0
  91. package/dist/form/form.codec.d.ts +17 -0
  92. package/dist/form/form.codec.mjs +45 -0
  93. package/dist/form/form.config.d.ts +6 -0
  94. package/dist/form/form.config.mjs +43 -0
  95. package/dist/form/form.empty-value.d.ts +4 -0
  96. package/dist/form/form.empty-value.mjs +20 -0
  97. package/dist/form/form.field-name.mjs +25 -0
  98. package/dist/form/form.rule-registry.mjs +10 -0
  99. package/dist/form/form.runtime-field.mjs +56 -0
  100. package/dist/form/form.runtime.mjs +235 -0
  101. package/dist/form/form.schema-defaults.mjs +36 -0
  102. package/dist/form/form.types.d.ts +315 -0
  103. package/dist/form/form.use-delayed-flag.mjs +35 -0
  104. package/dist/form/form.use-form-context.mjs +44 -0
  105. package/dist/form/form.use-taman-form.d.ts +7 -0
  106. package/dist/form/form.use-taman-form.mjs +36 -0
  107. package/dist/form/index.d.ts +8 -0
  108. package/dist/form/index.mjs +6 -0
  109. package/dist/form/taman-use-form.mjs +146 -0
  110. package/dist/index.d.ts +63 -0
  111. package/dist/index.mjs +56 -0
  112. package/dist/layout/components/index.mjs +6 -0
  113. package/dist/layout/components/taman-core-button-collapse.mjs +38 -0
  114. package/dist/layout/components/taman-core-button-fixed.mjs +29 -0
  115. package/dist/layout/components/taman-core-layout-content.mjs +50 -0
  116. package/dist/layout/components/taman-core-layout-footer.mjs +38 -0
  117. package/dist/layout/components/taman-core-layout-header.mjs +48 -0
  118. package/dist/layout/components/taman-core-layout-sidebar.mjs +319 -0
  119. package/dist/layout/components/taman-core-layout-tabbar.mjs +21 -0
  120. package/dist/layout/composables/use-layout.mjs +31 -0
  121. package/dist/layout/composables/use-sidebar-drag.mjs +103 -0
  122. package/dist/layout/header-scroll-state.mjs +9 -0
  123. package/dist/layout/index.d.ts +3 -0
  124. package/dist/layout/index.mjs +2 -0
  125. package/dist/layout/taman-core-layout.d.ts +41 -0
  126. package/dist/layout/taman-core-layout.mjs +603 -0
  127. package/dist/layout/taman-core-layout.vue.d.ts +99 -0
  128. package/dist/menu/components/collapse-transition.mjs +82 -0
  129. package/dist/menu/components/index.mjs +5 -0
  130. package/dist/menu/components/normal-menu/index.d.ts +3 -0
  131. package/dist/menu/components/normal-menu/index.mjs +2 -0
  132. package/dist/menu/components/normal-menu/normal-menu.d.ts +11 -0
  133. package/dist/menu/components/normal-menu/normal-menu.mjs +50 -0
  134. package/dist/menu/components/normal-menu/normal-menu.vue.d.ts +19 -0
  135. package/dist/menu/components/taman-menu-badge-dot.mjs +23 -0
  136. package/dist/menu/components/taman-menu-badge.mjs +49 -0
  137. package/dist/menu/components/taman-menu-badge.vue.d.ts +9 -0
  138. package/dist/menu/components/taman-menu-item.mjs +124 -0
  139. package/dist/menu/components/taman-menu-root.mjs +250 -0
  140. package/dist/menu/components/taman-menu-sub-menu-content.mjs +83 -0
  141. package/dist/menu/components/taman-menu-sub-menu.mjs +216 -0
  142. package/dist/menu/composables/index.mjs +3 -0
  143. package/dist/menu/composables/use-menu-context.mjs +36 -0
  144. package/dist/menu/composables/use-menu-scroll.mjs +23 -0
  145. package/dist/menu/composables/use-menu.mjs +33 -0
  146. package/dist/menu/index.d.ts +7 -0
  147. package/dist/menu/index.mjs +5 -0
  148. package/dist/menu/menu.constants.mjs +5 -0
  149. package/dist/menu/menu.types.d.ts +63 -0
  150. package/dist/menu/menu.utils.mjs +27 -0
  151. package/dist/menu/taman-menu.mjs +41 -0
  152. package/dist/menu/taman-menu.vue.d.ts +12 -0
  153. package/dist/menu/taman-sub-menu.mjs +75 -0
  154. package/dist/popup/alert/alert-builder.d.ts +8 -0
  155. package/dist/popup/alert/alert-builder.mjs +98 -0
  156. package/dist/popup/alert/alert-overlay.mjs +55 -0
  157. package/dist/popup/alert/alert.d.ts +43 -0
  158. package/dist/popup/alert/alert.mjs +10 -0
  159. package/dist/popup/alert/alert.vue.d.ts +26 -0
  160. package/dist/popup/alert/alert2.mjs +238 -0
  161. package/dist/popup/alert/index.d.ts +4 -0
  162. package/dist/popup/alert/index.mjs +4 -0
  163. package/dist/popup/dialog/dialog.api.d.ts +23 -0
  164. package/dist/popup/dialog/dialog.api.mjs +133 -0
  165. package/dist/popup/dialog/dialog.mjs +336 -0
  166. package/dist/popup/dialog/dialog.types.d.ts +60 -0
  167. package/dist/popup/dialog/dialog.vue.d.ts +46 -0
  168. package/dist/popup/dialog/index.d.ts +4 -0
  169. package/dist/popup/dialog/index.mjs +3 -0
  170. package/dist/popup/dialog/use-dialog-draggable.mjs +93 -0
  171. package/dist/popup/dialog/use-taman-dialog.d.ts +13 -0
  172. package/dist/popup/dialog/use-taman-dialog.mjs +106 -0
  173. package/dist/popup/drawer/drawer.api.d.ts +23 -0
  174. package/dist/popup/drawer/drawer.api.mjs +124 -0
  175. package/dist/popup/drawer/drawer.mjs +277 -0
  176. package/dist/popup/drawer/drawer.types.d.ts +56 -0
  177. package/dist/popup/drawer/drawer.vue.d.ts +47 -0
  178. package/dist/popup/drawer/index.d.ts +4 -0
  179. package/dist/popup/drawer/index.mjs +3 -0
  180. package/dist/popup/drawer/use-taman-drawer.d.ts +13 -0
  181. package/dist/popup/drawer/use-taman-drawer.mjs +109 -0
  182. package/dist/popup/index.d.ts +13 -0
  183. package/dist/popup/index.mjs +11 -0
  184. package/dist/tabs/components/index.mjs +2 -0
  185. package/dist/tabs/components/taman-tabs.mjs +158 -0
  186. package/dist/tabs/components/widgets/index.d.ts +4 -0
  187. package/dist/tabs/components/widgets/index.mjs +4 -0
  188. package/dist/tabs/components/widgets/tool-more.mjs +45 -0
  189. package/dist/tabs/components/widgets/tool-more.vue.d.ts +7 -0
  190. package/dist/tabs/components/widgets/tool-refresh.mjs +25 -0
  191. package/dist/tabs/components/widgets/tool-refresh.vue.d.ts +9 -0
  192. package/dist/tabs/components/widgets/tool-screen.mjs +29 -0
  193. package/dist/tabs/components/widgets/tool-screen.vue.d.ts +12 -0
  194. package/dist/tabs/index.d.ts +8 -0
  195. package/dist/tabs/index.mjs +6 -0
  196. package/dist/tabs/strict-context-menu.d.ts +10 -0
  197. package/dist/tabs/tabs.types.d.ts +30 -0
  198. package/dist/tabs/taman-tabs-view.mjs +101 -0
  199. package/dist/tabs/taman-tabs-view.vue.d.ts +18 -0
  200. package/dist/tabs/use-tabs-drag.mjs +69 -0
  201. package/dist/tabs/use-tabs-view-scroll.mjs +114 -0
  202. package/dist/ui/alert-dialog/alert-dialog-action.mjs +21 -0
  203. package/dist/ui/alert-dialog/alert-dialog-action.vue.d.ts +16 -0
  204. package/dist/ui/alert-dialog/alert-dialog-cancel.mjs +21 -0
  205. package/dist/ui/alert-dialog/alert-dialog-cancel.vue.d.ts +16 -0
  206. package/dist/ui/alert-dialog/alert-dialog-content.mjs +111 -0
  207. package/dist/ui/alert-dialog/alert-dialog-content.vue.d.ts +49 -0
  208. package/dist/ui/alert-dialog/alert-dialog-description.mjs +30 -0
  209. package/dist/ui/alert-dialog/alert-dialog-description.vue.d.ts +20 -0
  210. package/dist/ui/alert-dialog/alert-dialog-footer.mjs +14 -0
  211. package/dist/ui/alert-dialog/alert-dialog-footer.vue.d.ts +15 -0
  212. package/dist/ui/alert-dialog/alert-dialog-header.mjs +14 -0
  213. package/dist/ui/alert-dialog/alert-dialog-header.vue.d.ts +15 -0
  214. package/dist/ui/alert-dialog/alert-dialog-overlay.mjs +29 -0
  215. package/dist/ui/alert-dialog/alert-dialog-root.mjs +23 -0
  216. package/dist/ui/alert-dialog/alert-dialog-root.vue.d.ts +23 -0
  217. package/dist/ui/alert-dialog/alert-dialog-title.mjs +30 -0
  218. package/dist/ui/alert-dialog/alert-dialog-title.vue.d.ts +20 -0
  219. package/dist/ui/alert-dialog/alert-dialog-trigger.mjs +21 -0
  220. package/dist/ui/alert-dialog/alert-dialog-trigger.vue.d.ts +16 -0
  221. package/dist/ui/alert-dialog/index.d.ts +10 -0
  222. package/dist/ui/alert-dialog/index.mjs +10 -0
  223. package/dist/ui/dialog/dialog-close.mjs +21 -0
  224. package/dist/ui/dialog/dialog-close.vue.d.ts +16 -0
  225. package/dist/ui/dialog/dialog-content.mjs +111 -0
  226. package/dist/ui/dialog/dialog-content.vue.d.ts +51 -0
  227. package/dist/ui/dialog/dialog-description.mjs +31 -0
  228. package/dist/ui/dialog/dialog-description.vue.d.ts +20 -0
  229. package/dist/ui/dialog/dialog-footer.mjs +14 -0
  230. package/dist/ui/dialog/dialog-footer.vue.d.ts +15 -0
  231. package/dist/ui/dialog/dialog-header.mjs +14 -0
  232. package/dist/ui/dialog/dialog-header.vue.d.ts +15 -0
  233. package/dist/ui/dialog/dialog-overlay.mjs +34 -0
  234. package/dist/ui/dialog/dialog-overlay.vue.d.ts +14 -0
  235. package/dist/ui/dialog/dialog-root.mjs +24 -0
  236. package/dist/ui/dialog/dialog-root.vue.d.ts +23 -0
  237. package/dist/ui/dialog/dialog-title.mjs +31 -0
  238. package/dist/ui/dialog/dialog-title.vue.d.ts +20 -0
  239. package/dist/ui/dialog/dialog-trigger.mjs +21 -0
  240. package/dist/ui/dialog/dialog-trigger.vue.d.ts +16 -0
  241. package/dist/ui/dialog/index.d.ts +10 -0
  242. package/dist/ui/dialog/index.mjs +10 -0
  243. package/dist/ui/dialog/use-dialog-state-events.mjs +60 -0
  244. package/dist/ui/form/form-control.mjs +27 -0
  245. package/dist/ui/form/form-control.vue.d.ts +15 -0
  246. package/dist/ui/form/form-description.mjs +27 -0
  247. package/dist/ui/form/form-description.vue.d.ts +19 -0
  248. package/dist/ui/form/form-field.mjs +37 -0
  249. package/dist/ui/form/form-field.vue.d.ts +27 -0
  250. package/dist/ui/form/form-item.mjs +27 -0
  251. package/dist/ui/form/form-item.vue.d.ts +19 -0
  252. package/dist/ui/form/form-label.mjs +41 -0
  253. package/dist/ui/form/form-label.vue.d.ts +20 -0
  254. package/dist/ui/form/form-message.mjs +28 -0
  255. package/dist/ui/form/form-message.vue.d.ts +9 -0
  256. package/dist/ui/form/index.d.ts +8 -0
  257. package/dist/ui/form/index.mjs +8 -0
  258. package/dist/ui/form/injection-keys.d.ts +13 -0
  259. package/dist/ui/form/injection-keys.mjs +5 -0
  260. package/dist/ui/form/use-form-field.mjs +27 -0
  261. package/dist/ui/index.d.ts +42 -0
  262. package/dist/ui/index.mjs +42 -0
  263. package/dist/ui/label/index.d.ts +2 -0
  264. package/dist/ui/label/index.mjs +2 -0
  265. package/dist/ui/label/label.mjs +31 -0
  266. package/dist/ui/label/label.vue.d.ts +20 -0
  267. package/dist/ui/scroll-area/index.d.ts +3 -0
  268. package/dist/ui/scroll-area/index.mjs +3 -0
  269. package/dist/ui/scroll-area/scroll-area.mjs +47 -0
  270. package/dist/ui/scroll-area/scroll-area.vue.d.ts +21 -0
  271. package/dist/ui/scroll-area/scroll-bar.mjs +38 -0
  272. package/dist/ui/scroll-area/scroll-bar.vue.d.ts +12 -0
  273. package/dist/ui/sheet/index.d.ts +8 -0
  274. package/dist/ui/sheet/index.mjs +8 -0
  275. package/dist/ui/sheet/sheet-close.mjs +21 -0
  276. package/dist/ui/sheet/sheet-close.vue.d.ts +16 -0
  277. package/dist/ui/sheet/sheet-content.mjs +105 -0
  278. package/dist/ui/sheet/sheet-content.vue.d.ts +48 -0
  279. package/dist/ui/sheet/sheet-description.mjs +30 -0
  280. package/dist/ui/sheet/sheet-description.vue.d.ts +20 -0
  281. package/dist/ui/sheet/sheet-footer.mjs +14 -0
  282. package/dist/ui/sheet/sheet-footer.vue.d.ts +15 -0
  283. package/dist/ui/sheet/sheet-header.mjs +14 -0
  284. package/dist/ui/sheet/sheet-header.vue.d.ts +15 -0
  285. package/dist/ui/sheet/sheet-overlay.mjs +32 -0
  286. package/dist/ui/sheet/sheet-root.mjs +24 -0
  287. package/dist/ui/sheet/sheet-root.vue.d.ts +23 -0
  288. package/dist/ui/sheet/sheet-title.mjs +31 -0
  289. package/dist/ui/sheet/sheet-title.vue.d.ts +20 -0
  290. package/dist/ui/sheet/sheet.variants.d.ts +27 -0
  291. package/dist/ui/sheet/sheet.variants.mjs +12 -0
  292. package/dist/unocss/content.d.ts +4 -0
  293. package/dist/unocss/content.mjs +9 -0
  294. package/dist/unocss/index.d.ts +2 -0
  295. package/dist/unocss/index.mjs +2 -0
  296. package/package.json +78 -0
@@ -0,0 +1,250 @@
1
+ import { TAMAN_MENU_ROOT_NAME } from "../menu.constants.mjs";
2
+ import { flattedChildren } from "../menu.utils.mjs";
3
+ import { useMenuStyle } from "../composables/use-menu.mjs";
4
+ import { createMenuContext, createSubMenuContext } from "../composables/use-menu-context.mjs";
5
+ import "../composables/index.mjs";
6
+ import { useMenuScroll } from "../composables/use-menu-scroll.mjs";
7
+ import _sfc_main$1 from "./taman-menu-sub-menu.mjs";
8
+ import { Fragment, computed, createBlock, createElementBlock, createVNode, defineComponent, nextTick, normalizeClass, normalizeStyle, openBlock, reactive, ref, renderList, renderSlot, resolveDynamicComponent, toRef, unref, useSlots, watch, watchEffect, withCtx } from "vue";
9
+ import { useResizeObserver } from "@vueuse/core";
10
+ import PIcon from "pohon-ui/components/Icon.vue";
11
+ //#region src/menu/components/taman-menu-root.vue
12
+ const _sfc_main = /*@__PURE__*/ defineComponent({
13
+ name: TAMAN_MENU_ROOT_NAME,
14
+ __name: "taman-menu-root",
15
+ props: {
16
+ accordion: {
17
+ type: Boolean,
18
+ default: true
19
+ },
20
+ collapse: {
21
+ type: Boolean,
22
+ default: false
23
+ },
24
+ collapseShowTitle: { type: Boolean },
25
+ defaultActive: {},
26
+ defaultOpeneds: {},
27
+ mode: { default: "vertical" },
28
+ rounded: {
29
+ type: Boolean,
30
+ default: true
31
+ },
32
+ scrollToActive: {
33
+ type: Boolean,
34
+ default: false
35
+ },
36
+ theme: { default: "dark" }
37
+ },
38
+ emits: [
39
+ "close",
40
+ "open",
41
+ "select"
42
+ ],
43
+ setup(__props, { emit: __emit }) {
44
+ const props = __props;
45
+ const emit = __emit;
46
+ const menuStyle = useMenuStyle();
47
+ const slots = useSlots();
48
+ const menu = ref();
49
+ const sliceIndex = ref(-1);
50
+ const openedMenus = ref(props.defaultOpeneds && !props.collapse ? [...props.defaultOpeneds] : []);
51
+ const activePath = ref(props.defaultActive);
52
+ const items = ref({});
53
+ const subMenus = ref({});
54
+ const mouseInChild = ref(false);
55
+ const isMenuPopup = computed(() => {
56
+ return props.mode === "horizontal" || props.mode === "vertical" && props.collapse;
57
+ });
58
+ const getSlot = computed(() => {
59
+ const defaultSlots = slots.default?.() ?? [];
60
+ const originalSlot = flattedChildren(defaultSlots);
61
+ const slotDefault = sliceIndex.value === -1 ? originalSlot : originalSlot.slice(0, sliceIndex.value);
62
+ const slotMore = sliceIndex.value === -1 ? [] : originalSlot.slice(sliceIndex.value);
63
+ return {
64
+ showSlotMore: slotMore.length > 0,
65
+ slotDefault,
66
+ slotMore
67
+ };
68
+ });
69
+ watch(() => props.collapse, (value) => {
70
+ if (value) openedMenus.value = [];
71
+ });
72
+ watch(items.value, initMenu);
73
+ watch(() => props.defaultActive, (currentActive = "") => {
74
+ if (!items.value[currentActive]) activePath.value = "";
75
+ updateActiveName(currentActive);
76
+ });
77
+ let resizeStopper;
78
+ watchEffect(() => {
79
+ if (props.mode === "horizontal") resizeStopper = useResizeObserver(menu, handleResize).stop;
80
+ else resizeStopper?.();
81
+ });
82
+ createMenuContext(reactive({
83
+ activePath,
84
+ addMenuItem,
85
+ addSubMenu,
86
+ closeMenu,
87
+ handleMenuItemClick,
88
+ handleSubMenuClick,
89
+ isMenuPopup,
90
+ openedMenus,
91
+ openMenu,
92
+ props,
93
+ removeMenuItem,
94
+ removeSubMenu,
95
+ subMenus,
96
+ theme: toRef(props, "theme"),
97
+ items
98
+ }));
99
+ createSubMenuContext({
100
+ addSubMenu,
101
+ level: 1,
102
+ mouseInChild,
103
+ removeSubMenu
104
+ });
105
+ function calcMenuItemWidth(menuItem) {
106
+ const computedStyle = getComputedStyle(menuItem);
107
+ const marginLeft = Number.parseInt(computedStyle.marginLeft, 10);
108
+ const marginRight = Number.parseInt(computedStyle.marginRight, 10);
109
+ return menuItem.offsetWidth + marginLeft + marginRight || 0;
110
+ }
111
+ function calcSliceIndex() {
112
+ if (!menu.value) return -1;
113
+ const items = [...menu.value?.childNodes ?? []].filter((item) => item.nodeName !== "#comment" && (item.nodeName !== "#text" || item.nodeValue));
114
+ const moreItemWidth = 46;
115
+ const computedMenuStyle = getComputedStyle(menu?.value);
116
+ const paddingLeft = Number.parseInt(computedMenuStyle.paddingLeft, 10);
117
+ const paddingRight = Number.parseInt(computedMenuStyle.paddingRight, 10);
118
+ const menuWidth = menu.value?.clientWidth - paddingLeft - paddingRight;
119
+ let calcWidth = 0;
120
+ let sliceIndex = 0;
121
+ items.forEach((item, index) => {
122
+ calcWidth += calcMenuItemWidth(item);
123
+ if (calcWidth <= menuWidth - moreItemWidth) sliceIndex = index + 1;
124
+ });
125
+ return sliceIndex === items.length ? -1 : sliceIndex;
126
+ }
127
+ function debounce(fn, wait = 33.34) {
128
+ let timer;
129
+ return () => {
130
+ timer && clearTimeout(timer);
131
+ timer = setTimeout(() => {
132
+ fn();
133
+ }, wait);
134
+ };
135
+ }
136
+ let isFirstTimeRender = true;
137
+ function handleResize() {
138
+ if (sliceIndex.value === calcSliceIndex()) return;
139
+ const callback = () => {
140
+ sliceIndex.value = -1;
141
+ nextTick(() => {
142
+ sliceIndex.value = calcSliceIndex();
143
+ });
144
+ };
145
+ callback();
146
+ isFirstTimeRender ? callback() : debounce(callback)();
147
+ isFirstTimeRender = false;
148
+ }
149
+ const enableScroll = computed(() => props.scrollToActive && props.mode === "vertical" && !props.collapse);
150
+ useMenuScroll(activePath, {
151
+ enable: enableScroll,
152
+ delay: 320
153
+ });
154
+ function initMenu() {
155
+ getActivePaths().forEach((path) => {
156
+ const subMenu = subMenus.value[path];
157
+ subMenu && openMenu(path, subMenu.parentPaths);
158
+ });
159
+ }
160
+ function updateActiveName(val) {
161
+ const itemsInData = items.value;
162
+ const item = itemsInData[val] || activePath.value && itemsInData[activePath.value] || itemsInData[props.defaultActive || ""];
163
+ activePath.value = item ? item.path : val;
164
+ }
165
+ function handleMenuItemClick(data) {
166
+ const { collapse, mode } = props;
167
+ if (mode === "horizontal" || collapse) openedMenus.value = [];
168
+ const { parentPaths, path } = data;
169
+ if (!path || !parentPaths) return;
170
+ emit("select", path, parentPaths);
171
+ }
172
+ function handleSubMenuClick({ parentPaths, path }) {
173
+ if (openedMenus.value.includes(path)) closeMenu(path, parentPaths);
174
+ else openMenu(path, parentPaths);
175
+ }
176
+ function close(path) {
177
+ const i = openedMenus.value.indexOf(path);
178
+ if (i !== -1) openedMenus.value.splice(i, 1);
179
+ }
180
+ /**
181
+ * Close or collapse menu
182
+ */
183
+ function closeMenu(path, parentPaths) {
184
+ if (props.accordion) openedMenus.value = subMenus.value[path]?.parentPaths ?? [];
185
+ close(path);
186
+ emit("close", path, parentPaths);
187
+ }
188
+ /**
189
+ * Open menu on click
190
+ */
191
+ function openMenu(path, parentPaths) {
192
+ if (openedMenus.value.includes(path)) return;
193
+ if (props.accordion) {
194
+ const activeParentPaths = getActivePaths();
195
+ if (activeParentPaths.includes(path)) parentPaths = activeParentPaths;
196
+ openedMenus.value = openedMenus.value.filter((path) => parentPaths.includes(path));
197
+ }
198
+ openedMenus.value.push(path);
199
+ emit("open", path, parentPaths);
200
+ }
201
+ function addMenuItem(item) {
202
+ items.value[item.path] = item;
203
+ }
204
+ function addSubMenu(subMenu) {
205
+ subMenus.value[subMenu.path] = subMenu;
206
+ }
207
+ function removeSubMenu(subMenu) {
208
+ Reflect.deleteProperty(subMenus.value, subMenu.path);
209
+ }
210
+ function removeMenuItem(item) {
211
+ Reflect.deleteProperty(items.value, item.path);
212
+ }
213
+ function getActivePaths() {
214
+ const activeItem = activePath.value && items.value[activePath.value];
215
+ if (!activeItem || props.mode === "horizontal" || props.collapse) return [];
216
+ return activeItem.parentPaths;
217
+ }
218
+ return (_ctx, _cache) => {
219
+ return openBlock(), createElementBlock("ul", {
220
+ ref_key: "menu",
221
+ ref: menu,
222
+ class: normalizeClass(["taman-menu", [
223
+ __props.theme,
224
+ `is-${__props.mode}`,
225
+ `is-${__props.theme}`,
226
+ {
227
+ "is-rounded": __props.rounded,
228
+ "is-collapse": __props.collapse,
229
+ "is-menu-align": __props.mode === "horizontal"
230
+ }
231
+ ]]),
232
+ style: normalizeStyle(unref(menuStyle)),
233
+ role: "menu"
234
+ }, [__props.mode === "horizontal" && getSlot.value.showSlotMore ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [(openBlock(true), createElementBlock(Fragment, null, renderList(getSlot.value.slotDefault, (item, index) => {
235
+ return openBlock(), createBlock(resolveDynamicComponent(item), { key: index });
236
+ }), 128)), createVNode(_sfc_main$1, {
237
+ "is-sub-menu-more": "",
238
+ path: "sub-menu-more"
239
+ }, {
240
+ title: withCtx(() => [createVNode(PIcon, { name: "lucide:ellipsis" })]),
241
+ default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(getSlot.value.slotMore, (item, index) => {
242
+ return openBlock(), createBlock(resolveDynamicComponent(item), { key: index });
243
+ }), 128))]),
244
+ _: 1
245
+ })], 64)) : renderSlot(_ctx.$slots, "default", {}, void 0, void 0, 1)], 6);
246
+ };
247
+ }
248
+ });
249
+ //#endregion
250
+ export { _sfc_main as default };
@@ -0,0 +1,83 @@
1
+ import _sfc_main$1 from "../../components/icon/icon.mjs";
2
+ import "../../index.mjs";
3
+ import { useMenuContext } from "../composables/use-menu-context.mjs";
4
+ import "../composables/index.mjs";
5
+ import { computed, createBlock, createCommentVNode, createElementBlock, defineComponent, normalizeClass, normalizeStyle, openBlock, renderSlot, unref, vShow, withDirectives } from "vue";
6
+ //#region src/menu/components/taman-menu-sub-menu-content.vue
7
+ const _hoisted_1 = {
8
+ key: 1,
9
+ class: "taman-sub-menu-content__title"
10
+ };
11
+ const _sfc_main = /*@__PURE__*/ defineComponent({
12
+ name: "SubMenuContent",
13
+ __name: "taman-menu-sub-menu-content",
14
+ props: {
15
+ isMenuMore: {
16
+ type: Boolean,
17
+ default: false
18
+ },
19
+ isTopLevelMenuSubmenu: { type: Boolean },
20
+ level: { default: 0 },
21
+ activeIcon: {},
22
+ disabled: { type: Boolean },
23
+ icon: {},
24
+ path: {},
25
+ query: {},
26
+ badge: {},
27
+ badgeType: {},
28
+ badgeVariants: {}
29
+ },
30
+ setup(__props) {
31
+ const props = __props;
32
+ const rootMenu = useMenuContext();
33
+ const opened = computed(() => {
34
+ return rootMenu?.openedMenus.includes(props.path);
35
+ });
36
+ const collapse = computed(() => {
37
+ return rootMenu.props.collapse;
38
+ });
39
+ const isFirstLevel = computed(() => {
40
+ return props.level === 1;
41
+ });
42
+ const getCollapseShowTitle = computed(() => {
43
+ return rootMenu.props.collapseShowTitle && isFirstLevel.value && collapse.value;
44
+ });
45
+ const mode = computed(() => {
46
+ return rootMenu?.props.mode;
47
+ });
48
+ const showArrowIcon = computed(() => {
49
+ return mode.value === "horizontal" || !(isFirstLevel.value && collapse.value);
50
+ });
51
+ const hiddenTitle = computed(() => {
52
+ return mode.value === "vertical" && isFirstLevel.value && collapse.value && !getCollapseShowTitle.value;
53
+ });
54
+ const iconName = computed(() => {
55
+ return mode.value === "horizontal" && !isFirstLevel.value || mode.value === "vertical" && collapse.value ? "lucide:chevron-right" : "lucide:chevron-down";
56
+ });
57
+ const iconArrowStyle = computed(() => {
58
+ return opened.value ? { transform: "rotate(180deg)" } : {};
59
+ });
60
+ return (_ctx, _cache) => {
61
+ return openBlock(), createElementBlock("div", { class: normalizeClass(["taman-sub-menu-content", [{
62
+ "is-collapse-show-title": getCollapseShowTitle.value,
63
+ "is-more": __props.isMenuMore
64
+ }]]) }, [
65
+ renderSlot(_ctx.$slots, "default"),
66
+ !__props.isMenuMore ? (openBlock(), createBlock(unref(_sfc_main$1), {
67
+ key: 0,
68
+ class: "taman-menu__icon",
69
+ icon: __props.icon
70
+ }, null, 8, ["icon"])) : createCommentVNode("v-if", true),
71
+ !hiddenTitle.value ? (openBlock(), createElementBlock("div", _hoisted_1, [renderSlot(_ctx.$slots, "title")])) : createCommentVNode("v-if", true),
72
+ !__props.isMenuMore ? withDirectives((openBlock(), createBlock(unref(_sfc_main$1), {
73
+ key: 2,
74
+ icon: iconName.value,
75
+ style: normalizeStyle(iconArrowStyle.value),
76
+ class: "taman-sub-menu-content__icon-arrow size-4"
77
+ }, null, 8, ["icon", "style"])), [[vShow, showArrowIcon.value]]) : createCommentVNode("v-if", true)
78
+ ], 2);
79
+ };
80
+ }
81
+ });
82
+ //#endregion
83
+ export { _sfc_main as default };
@@ -0,0 +1,216 @@
1
+ import { TAMAN_MENU_ROOT_NAME, TAMAN_MENU_SUB_MENU_NAME } from "../menu.constants.mjs";
2
+ import { useMenu, useMenuStyle } from "../composables/use-menu.mjs";
3
+ import { createSubMenuContext, useMenuContext, useSubMenuContext } from "../composables/use-menu-context.mjs";
4
+ import "../composables/index.mjs";
5
+ import _sfc_main$1 from "./collapse-transition.mjs";
6
+ import _sfc_main$2 from "./taman-menu-sub-menu-content.mjs";
7
+ import { Fragment, computed, createBlock, createElementBlock, createElementVNode, createVNode, defineComponent, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, reactive, ref, renderSlot, unref, vShow, withCtx, withDirectives, withModifiers } from "vue";
8
+ import PPopover from "pohon-ui/components/Popover.vue";
9
+ //#region src/menu/components/taman-menu-sub-menu.vue
10
+ const _sfc_main = /*@__PURE__*/ defineComponent({
11
+ name: TAMAN_MENU_SUB_MENU_NAME,
12
+ __name: "taman-menu-sub-menu",
13
+ props: {
14
+ isSubMenuMore: {
15
+ type: Boolean,
16
+ default: false
17
+ },
18
+ activeIcon: {},
19
+ disabled: {
20
+ type: Boolean,
21
+ default: false
22
+ },
23
+ icon: {},
24
+ path: {},
25
+ badge: {},
26
+ badgeType: {},
27
+ badgeVariants: {}
28
+ },
29
+ setup(__props) {
30
+ const props = __props;
31
+ const { parentMenu, parentPaths } = useMenu();
32
+ const rootMenu = useMenuContext();
33
+ const subMenu = useSubMenuContext();
34
+ const subMenuStyle = useMenuStyle(subMenu);
35
+ const mouseInChild = ref(false);
36
+ const items = ref({});
37
+ const subMenus = ref({});
38
+ const timer = ref(null);
39
+ createSubMenuContext({
40
+ addSubMenu,
41
+ handleMouseleave,
42
+ level: (subMenu?.level ?? 0) + 1,
43
+ mouseInChild,
44
+ removeSubMenu
45
+ });
46
+ const opened = computed(() => {
47
+ return rootMenu?.openedMenus.includes(props.path);
48
+ });
49
+ const isTopLevelMenuSubmenu = computed(() => parentMenu.value?.type.name === TAMAN_MENU_ROOT_NAME);
50
+ const mode = computed(() => rootMenu?.props.mode ?? "vertical");
51
+ const rounded = computed(() => rootMenu?.props.rounded);
52
+ const currentLevel = computed(() => subMenu?.level ?? 0);
53
+ const isFirstLevel = computed(() => {
54
+ return currentLevel.value === 1;
55
+ });
56
+ const contentProps = computed(() => {
57
+ const isHorizontal = mode.value === "horizontal";
58
+ return {
59
+ collisionPadding: { top: 20 },
60
+ side: isHorizontal && isFirstLevel.value ? "bottom" : "right",
61
+ sideOffset: isHorizontal ? 5 : 12
62
+ };
63
+ });
64
+ const active = computed(() => {
65
+ let isActive = false;
66
+ Object.values(items.value).forEach((item) => {
67
+ if (item.active) isActive = true;
68
+ });
69
+ Object.values(subMenus.value).forEach((subItem) => {
70
+ if (subItem.active) isActive = true;
71
+ });
72
+ return isActive;
73
+ });
74
+ function addSubMenu(subMenu) {
75
+ subMenus.value[subMenu.path] = subMenu;
76
+ }
77
+ function removeSubMenu(subMenu) {
78
+ Reflect.deleteProperty(subMenus.value, subMenu.path);
79
+ }
80
+ /**
81
+ * Toggle submenu open/closed on click
82
+ */
83
+ function handleClick() {
84
+ const mode = rootMenu?.props.mode;
85
+ if (props.disabled || rootMenu?.props.collapse && mode === "vertical" || mode === "horizontal") return;
86
+ rootMenu?.handleSubMenuClick({
87
+ active: active.value,
88
+ parentPaths: parentPaths.value,
89
+ path: props.path
90
+ });
91
+ }
92
+ function handleMouseenter(event, showTimeout = 300) {
93
+ if (event.type === "focus") return;
94
+ if (!rootMenu?.props.collapse && rootMenu?.props.mode === "vertical" || props.disabled) {
95
+ if (subMenu) subMenu.mouseInChild.value = true;
96
+ return;
97
+ }
98
+ if (subMenu) subMenu.mouseInChild.value = true;
99
+ timer.value && window.clearTimeout(timer.value);
100
+ timer.value = setTimeout(() => {
101
+ rootMenu?.openMenu(props.path, parentPaths.value);
102
+ }, showTimeout);
103
+ parentMenu.value?.vnode.el?.dispatchEvent(new MouseEvent("mouseenter"));
104
+ }
105
+ function handleMouseleave(deepDispatch = false) {
106
+ if (!rootMenu?.props.collapse && rootMenu?.props.mode === "vertical" && subMenu) {
107
+ subMenu.mouseInChild.value = false;
108
+ return;
109
+ }
110
+ timer.value && window.clearTimeout(timer.value);
111
+ if (subMenu) subMenu.mouseInChild.value = false;
112
+ timer.value = setTimeout(() => {
113
+ !mouseInChild.value && rootMenu?.closeMenu(props.path, parentPaths.value);
114
+ }, 300);
115
+ if (deepDispatch) subMenu?.handleMouseleave?.(true);
116
+ }
117
+ const menuIcon = computed(() => active.value ? props.activeIcon || props.icon : props.icon);
118
+ const item = reactive({
119
+ active,
120
+ parentPaths,
121
+ path: props.path
122
+ });
123
+ onMounted(() => {
124
+ subMenu?.addSubMenu?.(item);
125
+ rootMenu?.addSubMenu?.(item);
126
+ });
127
+ onBeforeUnmount(() => {
128
+ subMenu?.removeSubMenu?.(item);
129
+ rootMenu?.removeSubMenu?.(item);
130
+ });
131
+ return (_ctx, _cache) => {
132
+ return openBlock(), createElementBlock("li", {
133
+ class: normalizeClass(["taman-sub-menu", [{
134
+ "is-active": active.value,
135
+ "is-disabled": __props.disabled,
136
+ "is-opened": opened.value
137
+ }]]),
138
+ onFocus: handleMouseenter,
139
+ onMouseenter: handleMouseenter,
140
+ onMouseleave: _cache[3] || (_cache[3] = () => handleMouseleave())
141
+ }, [unref(rootMenu).isMenuPopup ? (openBlock(), createBlock(PPopover, {
142
+ key: 0,
143
+ ui: { content: [
144
+ unref(rootMenu).theme,
145
+ "taman-menu__popup-container",
146
+ `is-${unref(rootMenu).theme}`,
147
+ opened.value ? "" : "hidden",
148
+ "overflow-auto",
149
+ "max-h-[calc(var(--akar-hover-card-content-available-height)-20px)]",
150
+ mode.value === "horizontal" ? "is-horizontal" : ""
151
+ ] },
152
+ content: contentProps.value,
153
+ mode: "hover",
154
+ open: "",
155
+ "open-delay": 0
156
+ }, {
157
+ content: withCtx(() => [createElementVNode("div", {
158
+ class: normalizeClass(["taman-menu__popup", [`is-${mode.value}`]]),
159
+ onFocus: _cache[0] || (_cache[0] = (e) => handleMouseenter(e, 100)),
160
+ onMouseenter: _cache[1] || (_cache[1] = (e) => handleMouseenter(e, 100)),
161
+ onMouseleave: _cache[2] || (_cache[2] = () => handleMouseleave(true))
162
+ }, [createElementVNode("ul", {
163
+ class: normalizeClass(["taman-menu", { "is-rounded": rounded.value }]),
164
+ style: normalizeStyle(unref(subMenuStyle))
165
+ }, [renderSlot(_ctx.$slots, "default")], 6)], 34)]),
166
+ default: withCtx(() => [createVNode(_sfc_main$2, {
167
+ class: normalizeClass({ "is-active": active.value }),
168
+ icon: menuIcon.value,
169
+ "is-menu-more": __props.isSubMenuMore,
170
+ "is-top-level-menu-submenu": isTopLevelMenuSubmenu.value,
171
+ level: currentLevel.value,
172
+ path: __props.path,
173
+ onClick: withModifiers(handleClick, ["stop"])
174
+ }, {
175
+ title: withCtx(() => [renderSlot(_ctx.$slots, "title")]),
176
+ _: 3
177
+ }, 8, [
178
+ "class",
179
+ "icon",
180
+ "is-menu-more",
181
+ "is-top-level-menu-submenu",
182
+ "level",
183
+ "path"
184
+ ])]),
185
+ _: 3
186
+ }, 8, ["ui", "content"])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createVNode(_sfc_main$2, {
187
+ class: normalizeClass({ "is-active": active.value }),
188
+ icon: menuIcon.value,
189
+ "is-menu-more": __props.isSubMenuMore,
190
+ "is-top-level-menu-submenu": isTopLevelMenuSubmenu.value,
191
+ level: currentLevel.value,
192
+ path: __props.path,
193
+ onClick: withModifiers(handleClick, ["stop"])
194
+ }, {
195
+ title: withCtx(() => [renderSlot(_ctx.$slots, "title")]),
196
+ default: withCtx(() => [renderSlot(_ctx.$slots, "content")]),
197
+ _: 3
198
+ }, 8, [
199
+ "class",
200
+ "icon",
201
+ "is-menu-more",
202
+ "is-top-level-menu-submenu",
203
+ "level",
204
+ "path"
205
+ ]), createVNode(_sfc_main$1, null, {
206
+ default: withCtx(() => [withDirectives(createElementVNode("ul", {
207
+ class: normalizeClass(["taman-menu", { "is-rounded": rounded.value }]),
208
+ style: normalizeStyle(unref(subMenuStyle))
209
+ }, [renderSlot(_ctx.$slots, "default")], 6), [[vShow, opened.value]])]),
210
+ _: 3
211
+ })], 64))], 34);
212
+ };
213
+ }
214
+ });
215
+ //#endregion
216
+ export { _sfc_main as default };
@@ -0,0 +1,3 @@
1
+ import { useMenu, useMenuStyle } from "./use-menu.mjs";
2
+ import { createMenuContext, createSubMenuContext, useMenuContext, useSubMenuContext } from "./use-menu-context.mjs";
3
+ export { createMenuContext, createSubMenuContext, useMenu, useMenuContext, useMenuStyle, useSubMenuContext };
@@ -0,0 +1,36 @@
1
+ import { TAMAN_MENU_ROOT_NAME, TAMAN_MENU_SUB_MENU_NAME } from "../menu.constants.mjs";
2
+ import { findComponentUpward } from "../menu.utils.mjs";
3
+ import { getCurrentInstance, inject, provide } from "vue";
4
+ //#region src/menu/composables/use-menu-context.ts
5
+ const menuContextKey = Symbol("menuContext");
6
+ /**
7
+ * Provide menu context
8
+ */
9
+ function createMenuContext(injectMenuData) {
10
+ provide(menuContextKey, injectMenuData);
11
+ }
12
+ /**
13
+ * Provide menu context
14
+ */
15
+ function createSubMenuContext(injectSubMenuData) {
16
+ const instance = getCurrentInstance();
17
+ provide(`subMenu:${instance?.uid}`, injectSubMenuData);
18
+ }
19
+ /**
20
+ * Inject menu context
21
+ */
22
+ function useMenuContext() {
23
+ if (!getCurrentInstance()) throw new Error("instance is required");
24
+ return inject(menuContextKey);
25
+ }
26
+ /**
27
+ * Inject menu context
28
+ */
29
+ function useSubMenuContext() {
30
+ const instance = getCurrentInstance();
31
+ if (!instance) throw new Error("instance is required");
32
+ const parentMenu = findComponentUpward(instance, [TAMAN_MENU_ROOT_NAME, TAMAN_MENU_SUB_MENU_NAME]);
33
+ return inject(`subMenu:${parentMenu?.uid}`);
34
+ }
35
+ //#endregion
36
+ export { createMenuContext, createSubMenuContext, useMenuContext, useSubMenuContext };
@@ -0,0 +1,23 @@
1
+ import { watch } from "vue";
2
+ import { useDebounceFn } from "@vueuse/core";
3
+ //#region src/menu/composables/use-menu-scroll.ts
4
+ function useMenuScroll(activePath, options = {}) {
5
+ const { enable = true, delay = 320 } = options;
6
+ function scrollToActiveItem() {
7
+ if (!(typeof enable === "boolean" ? enable : enable.value)) return;
8
+ const activeElement = document.querySelector("aside a[role=menuitem].is-active");
9
+ if (activeElement) activeElement.scrollIntoView({
10
+ behavior: "smooth",
11
+ block: "center",
12
+ inline: "center"
13
+ });
14
+ }
15
+ const debouncedScroll = useDebounceFn(scrollToActiveItem, delay);
16
+ watch(activePath, () => {
17
+ if (!(typeof enable === "boolean" ? enable : enable.value)) return;
18
+ debouncedScroll();
19
+ });
20
+ return { scrollToActiveItem };
21
+ }
22
+ //#endregion
23
+ export { useMenuScroll };
@@ -0,0 +1,33 @@
1
+ import { TAMAN_MENU_ROOT_NAME, TAMAN_MENU_SUB_MENU_NAME } from "../menu.constants.mjs";
2
+ import { findComponentUpward } from "../menu.utils.mjs";
3
+ import { computed, getCurrentInstance } from "vue";
4
+ //#region src/menu/composables/use-menu.ts
5
+ function useMenu() {
6
+ const instance = getCurrentInstance();
7
+ if (!instance) throw new Error("instance is required");
8
+ /**
9
+ * All parent menu paths for the current item
10
+ */
11
+ const parentPaths = computed(() => {
12
+ let parent = instance.parent;
13
+ const paths = [instance.props.path];
14
+ while (parent?.type.name !== TAMAN_MENU_ROOT_NAME) {
15
+ if (parent?.props.path) paths.unshift(parent.props.path);
16
+ parent = parent?.parent ?? null;
17
+ }
18
+ return paths;
19
+ });
20
+ return {
21
+ parentMenu: computed(() => {
22
+ return findComponentUpward(instance, [TAMAN_MENU_ROOT_NAME, TAMAN_MENU_SUB_MENU_NAME]);
23
+ }),
24
+ parentPaths
25
+ };
26
+ }
27
+ function useMenuStyle(menu) {
28
+ return computed(() => {
29
+ return { "--menu-level": menu ? menu?.level ?? 1 : 0 };
30
+ });
31
+ }
32
+ //#endregion
33
+ export { useMenu, useMenuStyle };
@@ -0,0 +1,7 @@
1
+ import { NormalMenuProps } from "./components/normal-menu/normal-menu.js";
2
+ import _default$1 from "./components/normal-menu/normal-menu.vue.js";
3
+ import "./components/normal-menu/index.js";
4
+ import _default from "./components/taman-menu-badge.vue.js";
5
+ import { MenuItemClicked, MenuItemProps, MenuItemRegistered, MenuProps, MenuProvider, SubMenuProps, SubMenuProvider } from "./menu.types.js";
6
+ import _default$2 from "./taman-menu.vue.js";
7
+ export { _default as MenuBadge, type MenuItemClicked, type MenuItemProps, type MenuItemRegistered, type MenuProps, type MenuProvider, _default$1 as NormalMenu, type NormalMenuProps, type SubMenuProps, type SubMenuProvider, _default$2 as TamanMenu };
@@ -0,0 +1,5 @@
1
+ import _sfc_main$1 from "./components/normal-menu/normal-menu.mjs";
2
+ import "./components/normal-menu/index.mjs";
3
+ import _sfc_main from "./components/taman-menu-badge.mjs";
4
+ import _sfc_main$2 from "./taman-menu.mjs";
5
+ export { _sfc_main as MenuBadge, _sfc_main$1 as NormalMenu, _sfc_main$2 as TamanMenu };
@@ -0,0 +1,5 @@
1
+ //#region src/menu/menu.constants.ts
2
+ const TAMAN_MENU_ROOT_NAME = "TamanMenuRoot";
3
+ const TAMAN_MENU_SUB_MENU_NAME = "TamanMenuSubMenu";
4
+ //#endregion
5
+ export { TAMAN_MENU_ROOT_NAME, TAMAN_MENU_SUB_MENU_NAME };