@melodicdev/components 2.0.3 → 3.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 (328) hide show
  1. package/README.md +7 -6
  2. package/assets/melodic-components.js +5681 -4145
  3. package/assets/melodic-components.js.map +1 -1
  4. package/assets/melodic-components.min.js +6573 -5141
  5. package/lib/components/data-display/activity-feed/activity-feed-item.component.d.ts +15 -14
  6. package/lib/components/data-display/activity-feed/activity-feed-item.component.d.ts.map +1 -1
  7. package/lib/components/data-display/activity-feed/activity-feed-item.component.js +36 -16
  8. package/lib/components/data-display/activity-feed/activity-feed-item.styles.d.ts.map +1 -1
  9. package/lib/components/data-display/activity-feed/activity-feed-item.styles.js +4 -0
  10. package/lib/components/data-display/activity-feed/activity-feed-item.template.d.ts.map +1 -1
  11. package/lib/components/data-display/activity-feed/activity-feed-item.template.js +15 -14
  12. package/lib/components/data-display/avatar/avatar.component.d.ts +9 -4
  13. package/lib/components/data-display/avatar/avatar.component.d.ts.map +1 -1
  14. package/lib/components/data-display/avatar/avatar.component.js +12 -3
  15. package/lib/components/data-display/avatar/avatar.template.js +1 -1
  16. package/lib/components/data-display/badge/badge.component.d.ts +2 -3
  17. package/lib/components/data-display/badge/badge.component.d.ts.map +1 -1
  18. package/lib/components/data-display/badge/badge.styles.d.ts.map +1 -1
  19. package/lib/components/data-display/badge/badge.styles.js +56 -35
  20. package/lib/components/data-display/badge/badge.types.d.ts +2 -0
  21. package/lib/components/data-display/badge/badge.types.d.ts.map +1 -1
  22. package/lib/components/data-display/calendar-view/calendar-view.utils.d.ts +10 -0
  23. package/lib/components/data-display/calendar-view/calendar-view.utils.d.ts.map +1 -1
  24. package/lib/components/data-display/calendar-view/calendar-view.utils.js +59 -27
  25. package/lib/components/data-display/data-grid/data-grid.component.d.ts +6 -5
  26. package/lib/components/data-display/data-grid/data-grid.component.d.ts.map +1 -1
  27. package/lib/components/data-display/data-grid/data-grid.component.js +49 -110
  28. package/lib/components/data-display/data-grid/data-grid.template.d.ts.map +1 -1
  29. package/lib/components/data-display/data-grid/data-grid.template.js +2 -6
  30. package/lib/components/data-display/list/list-item.component.d.ts +15 -6
  31. package/lib/components/data-display/list/list-item.component.d.ts.map +1 -1
  32. package/lib/components/data-display/list/list-item.component.js +57 -6
  33. package/lib/components/data-display/list/list-item.styles.d.ts.map +1 -1
  34. package/lib/components/data-display/list/list-item.styles.js +5 -0
  35. package/lib/components/data-display/list/list-item.template.d.ts.map +1 -1
  36. package/lib/components/data-display/list/list-item.template.js +18 -12
  37. package/lib/components/data-display/profile-card/profile-card.component.d.ts +2 -2
  38. package/lib/components/data-display/profile-card/profile-card.component.d.ts.map +1 -1
  39. package/lib/components/data-display/profile-card/profile-card.component.js +17 -15
  40. package/lib/components/data-display/profile-card/profile-card.template.js +1 -1
  41. package/lib/components/data-display/stat-card/stat-card.component.d.ts +6 -6
  42. package/lib/components/data-display/stat-card/stat-card.component.d.ts.map +1 -1
  43. package/lib/components/data-display/stat-card/stat-card.component.js +14 -6
  44. package/lib/components/data-display/stat-card/stat-card.template.js +4 -4
  45. package/lib/components/data-display/table/table.component.d.ts +7 -5
  46. package/lib/components/data-display/table/table.component.d.ts.map +1 -1
  47. package/lib/components/data-display/table/table.component.js +40 -117
  48. package/lib/components/data-display/table/table.template.d.ts.map +1 -1
  49. package/lib/components/data-display/table/table.template.js +1 -6
  50. package/lib/components/data-display/table-core/index.d.ts +3 -0
  51. package/lib/components/data-display/table-core/index.d.ts.map +1 -0
  52. package/lib/components/data-display/table-core/index.js +2 -0
  53. package/lib/components/data-display/table-core/table-core.d.ts +137 -0
  54. package/lib/components/data-display/table-core/table-core.d.ts.map +1 -0
  55. package/lib/components/data-display/table-core/table-core.js +225 -0
  56. package/lib/components/data-display/tag/tag.component.d.ts +14 -7
  57. package/lib/components/data-display/tag/tag.component.d.ts.map +1 -1
  58. package/lib/components/data-display/tag/tag.component.js +29 -5
  59. package/lib/components/data-display/tag/tag.template.js +2 -2
  60. package/lib/components/data-display/tag/tag.types.d.ts +8 -1
  61. package/lib/components/data-display/tag/tag.types.d.ts.map +1 -1
  62. package/lib/components/feedback/alert/alert.component.d.ts +6 -3
  63. package/lib/components/feedback/alert/alert.component.d.ts.map +1 -1
  64. package/lib/components/feedback/alert/alert.component.js +13 -4
  65. package/lib/components/feedback/alert/alert.template.js +1 -1
  66. package/lib/components/feedback/progress/progress.component.d.ts +4 -0
  67. package/lib/components/feedback/progress/progress.component.d.ts.map +1 -1
  68. package/lib/components/feedback/progress/progress.component.js +9 -0
  69. package/lib/components/feedback/progress/progress.template.d.ts.map +1 -1
  70. package/lib/components/feedback/progress/progress.template.js +19 -5
  71. package/lib/components/feedback/toast/toast.component.d.ts +6 -3
  72. package/lib/components/feedback/toast/toast.component.d.ts.map +1 -1
  73. package/lib/components/feedback/toast/toast.component.js +13 -4
  74. package/lib/components/feedback/toast/toast.service.d.ts.map +1 -1
  75. package/lib/components/feedback/toast/toast.service.js +2 -1
  76. package/lib/components/feedback/toast/toast.template.js +1 -1
  77. package/lib/components/forms/autocomplete/autocomplete.component.d.ts +12 -4
  78. package/lib/components/forms/autocomplete/autocomplete.component.d.ts.map +1 -1
  79. package/lib/components/forms/autocomplete/autocomplete.component.js +39 -30
  80. package/lib/components/forms/autocomplete/autocomplete.template.d.ts.map +1 -1
  81. package/lib/components/forms/autocomplete/autocomplete.template.js +14 -0
  82. package/lib/components/forms/button/button.component.d.ts +28 -3
  83. package/lib/components/forms/button/button.component.d.ts.map +1 -1
  84. package/lib/components/forms/button/button.component.js +81 -6
  85. package/lib/components/forms/button/button.template.js +1 -1
  86. package/lib/components/forms/button/button.types.d.ts +8 -1
  87. package/lib/components/forms/button/button.types.d.ts.map +1 -1
  88. package/lib/components/forms/button-group/button-group-item.component.d.ts +2 -2
  89. package/lib/components/forms/button-group/button-group-item.component.d.ts.map +1 -1
  90. package/lib/components/forms/button-group/button-group.component.d.ts +4 -2
  91. package/lib/components/forms/button-group/button-group.component.d.ts.map +1 -1
  92. package/lib/components/forms/button-group/button-group.component.js +3 -1
  93. package/lib/components/forms/button-group/button-group.styles.d.ts.map +1 -1
  94. package/lib/components/forms/button-group/button-group.styles.js +15 -1
  95. package/lib/components/forms/button-group/button-group.template.d.ts.map +1 -1
  96. package/lib/components/forms/button-group/button-group.template.js +4 -2
  97. package/lib/components/forms/checkbox/checkbox.component.d.ts +4 -2
  98. package/lib/components/forms/checkbox/checkbox.component.d.ts.map +1 -1
  99. package/lib/components/forms/checkbox/checkbox.component.js +3 -1
  100. package/lib/components/forms/checkbox/checkbox.styles.d.ts.map +1 -1
  101. package/lib/components/forms/checkbox/checkbox.styles.js +19 -0
  102. package/lib/components/forms/checkbox/checkbox.template.d.ts.map +1 -1
  103. package/lib/components/forms/checkbox/checkbox.template.js +4 -2
  104. package/lib/components/forms/date-picker/calendar.component.js +1 -1
  105. package/lib/components/forms/date-picker/date-picker.component.d.ts +11 -4
  106. package/lib/components/forms/date-picker/date-picker.component.d.ts.map +1 -1
  107. package/lib/components/forms/date-picker/date-picker.component.js +99 -32
  108. package/lib/components/forms/date-picker/date-picker.styles.d.ts.map +1 -1
  109. package/lib/components/forms/date-picker/date-picker.styles.js +0 -10
  110. package/lib/components/forms/date-picker/date-picker.template.d.ts.map +1 -1
  111. package/lib/components/forms/date-picker/date-picker.template.js +3 -4
  112. package/lib/components/forms/file-upload/file-upload-item.component.d.ts +7 -0
  113. package/lib/components/forms/file-upload/file-upload-item.component.d.ts.map +1 -1
  114. package/lib/components/forms/file-upload/file-upload-item.component.js +15 -0
  115. package/lib/components/forms/file-upload/file-upload.component.d.ts +15 -0
  116. package/lib/components/forms/file-upload/file-upload.component.d.ts.map +1 -1
  117. package/lib/components/forms/file-upload/file-upload.component.js +56 -0
  118. package/lib/components/forms/form-field/form-field.component.d.ts +12 -4
  119. package/lib/components/forms/form-field/form-field.component.d.ts.map +1 -1
  120. package/lib/components/forms/form-field/form-field.component.js +50 -31
  121. package/lib/components/forms/form-field/form-field.template.js +1 -1
  122. package/lib/components/forms/input/input.component.d.ts +2 -2
  123. package/lib/components/forms/input/input.component.d.ts.map +1 -1
  124. package/lib/components/forms/radio/radio-group.component.d.ts +6 -0
  125. package/lib/components/forms/radio/radio-group.component.d.ts.map +1 -1
  126. package/lib/components/forms/radio/radio-group.component.js +69 -2
  127. package/lib/components/forms/radio/radio-group.template.js +1 -1
  128. package/lib/components/forms/radio/radio.component.d.ts +7 -2
  129. package/lib/components/forms/radio/radio.component.d.ts.map +1 -1
  130. package/lib/components/forms/radio/radio.component.js +5 -0
  131. package/lib/components/forms/radio/radio.template.d.ts.map +1 -1
  132. package/lib/components/forms/radio/radio.template.js +1 -0
  133. package/lib/components/forms/select/select.component.d.ts +21 -6
  134. package/lib/components/forms/select/select.component.d.ts.map +1 -1
  135. package/lib/components/forms/select/select.component.js +94 -36
  136. package/lib/components/forms/select/select.template.d.ts.map +1 -1
  137. package/lib/components/forms/select/select.template.js +6 -2
  138. package/lib/components/forms/slider/slider.component.d.ts +2 -2
  139. package/lib/components/forms/slider/slider.component.d.ts.map +1 -1
  140. package/lib/components/forms/slider/slider.component.js +5 -1
  141. package/lib/components/forms/textarea/textarea.component.d.ts +2 -2
  142. package/lib/components/forms/textarea/textarea.component.d.ts.map +1 -1
  143. package/lib/components/forms/toggle/toggle.component.d.ts +4 -2
  144. package/lib/components/forms/toggle/toggle.component.d.ts.map +1 -1
  145. package/lib/components/forms/toggle/toggle.component.js +3 -1
  146. package/lib/components/forms/toggle/toggle.styles.d.ts.map +1 -1
  147. package/lib/components/forms/toggle/toggle.styles.js +19 -0
  148. package/lib/components/forms/toggle/toggle.template.d.ts.map +1 -1
  149. package/lib/components/forms/toggle/toggle.template.js +11 -3
  150. package/lib/components/foundation/card/card.component.d.ts +7 -6
  151. package/lib/components/foundation/card/card.component.d.ts.map +1 -1
  152. package/lib/components/foundation/card/card.component.js +18 -7
  153. package/lib/components/foundation/card/card.styles.d.ts.map +1 -1
  154. package/lib/components/foundation/card/card.styles.js +5 -0
  155. package/lib/components/foundation/card/card.template.d.ts.map +1 -1
  156. package/lib/components/foundation/card/card.template.js +16 -11
  157. package/lib/components/foundation/divider/divider.component.d.ts +5 -4
  158. package/lib/components/foundation/divider/divider.component.d.ts.map +1 -1
  159. package/lib/components/foundation/divider/divider.component.js +11 -3
  160. package/lib/components/foundation/divider/divider.styles.d.ts.map +1 -1
  161. package/lib/components/foundation/divider/divider.styles.js +6 -0
  162. package/lib/components/foundation/divider/divider.template.d.ts +5 -0
  163. package/lib/components/foundation/divider/divider.template.d.ts.map +1 -1
  164. package/lib/components/foundation/divider/divider.template.js +9 -6
  165. package/lib/components/general/icon/icon.template.d.ts.map +1 -1
  166. package/lib/components/general/icon/icon.template.js +3 -1
  167. package/lib/components/navigation/pagination/pagination.component.d.ts +5 -0
  168. package/lib/components/navigation/pagination/pagination.component.d.ts.map +1 -1
  169. package/lib/components/navigation/pagination/pagination.component.js +22 -10
  170. package/lib/components/navigation/pagination/pagination.styles.d.ts.map +1 -1
  171. package/lib/components/navigation/pagination/pagination.styles.js +6 -4
  172. package/lib/components/navigation/sidebar/sidebar-item.component.d.ts +4 -4
  173. package/lib/components/navigation/sidebar/sidebar-item.component.d.ts.map +1 -1
  174. package/lib/components/navigation/sidebar/sidebar-item.component.js +11 -4
  175. package/lib/components/navigation/sidebar/sidebar-item.template.js +2 -2
  176. package/lib/components/navigation/sidebar/sidebar.component.d.ts +7 -0
  177. package/lib/components/navigation/sidebar/sidebar.component.d.ts.map +1 -1
  178. package/lib/components/navigation/sidebar/sidebar.component.js +48 -5
  179. package/lib/components/navigation/steps/step-panel.component.d.ts +7 -0
  180. package/lib/components/navigation/steps/step-panel.component.d.ts.map +1 -1
  181. package/lib/components/navigation/steps/step-panel.component.js +7 -0
  182. package/lib/components/navigation/steps/step-panel.template.d.ts +1 -1
  183. package/lib/components/navigation/steps/step-panel.template.d.ts.map +1 -1
  184. package/lib/components/navigation/steps/step-panel.template.js +2 -2
  185. package/lib/components/navigation/steps/step.component.d.ts +2 -2
  186. package/lib/components/navigation/steps/step.component.d.ts.map +1 -1
  187. package/lib/components/navigation/steps/step.component.js +8 -2
  188. package/lib/components/navigation/steps/step.template.js +1 -1
  189. package/lib/components/navigation/steps/steps.component.d.ts +3 -1
  190. package/lib/components/navigation/steps/steps.component.d.ts.map +1 -1
  191. package/lib/components/navigation/steps/steps.component.js +47 -14
  192. package/lib/components/navigation/steps/steps.template.d.ts.map +1 -1
  193. package/lib/components/navigation/steps/steps.template.js +5 -1
  194. package/lib/components/navigation/tabs/tab-panel.component.d.ts +7 -0
  195. package/lib/components/navigation/tabs/tab-panel.component.d.ts.map +1 -1
  196. package/lib/components/navigation/tabs/tab-panel.component.js +7 -0
  197. package/lib/components/navigation/tabs/tab-panel.template.d.ts +1 -1
  198. package/lib/components/navigation/tabs/tab-panel.template.d.ts.map +1 -1
  199. package/lib/components/navigation/tabs/tab-panel.template.js +2 -2
  200. package/lib/components/navigation/tabs/tabs.component.d.ts +5 -3
  201. package/lib/components/navigation/tabs/tabs.component.d.ts.map +1 -1
  202. package/lib/components/navigation/tabs/tabs.component.js +49 -14
  203. package/lib/components/navigation/tabs/tabs.template.d.ts.map +1 -1
  204. package/lib/components/navigation/tabs/tabs.template.js +6 -1
  205. package/lib/components/overlays/dialog/dialog-ref.class.d.ts +17 -2
  206. package/lib/components/overlays/dialog/dialog-ref.class.d.ts.map +1 -1
  207. package/lib/components/overlays/dialog/dialog-ref.class.js +52 -6
  208. package/lib/components/overlays/dialog/dialog.component.d.ts.map +1 -1
  209. package/lib/components/overlays/dialog/dialog.component.js +5 -1
  210. package/lib/components/overlays/dialog/dialog.service.d.ts +2 -2
  211. package/lib/components/overlays/dialog/dialog.service.d.ts.map +1 -1
  212. package/lib/components/overlays/dialog/dialog.service.js +46 -18
  213. package/lib/components/overlays/drawer/drawer.component.d.ts +9 -2
  214. package/lib/components/overlays/drawer/drawer.component.d.ts.map +1 -1
  215. package/lib/components/overlays/drawer/drawer.component.js +34 -4
  216. package/lib/components/overlays/drawer/drawer.styles.d.ts.map +1 -1
  217. package/lib/components/overlays/drawer/drawer.styles.js +4 -0
  218. package/lib/components/overlays/dropdown/dropdown-item.component.d.ts +5 -2
  219. package/lib/components/overlays/dropdown/dropdown-item.component.d.ts.map +1 -1
  220. package/lib/components/overlays/dropdown/dropdown-item.component.js +18 -0
  221. package/lib/components/overlays/dropdown/dropdown-item.template.d.ts.map +1 -1
  222. package/lib/components/overlays/dropdown/dropdown-item.template.js +0 -3
  223. package/lib/components/overlays/dropdown/dropdown.component.d.ts +8 -4
  224. package/lib/components/overlays/dropdown/dropdown.component.d.ts.map +1 -1
  225. package/lib/components/overlays/dropdown/dropdown.component.js +61 -60
  226. package/lib/components/overlays/popover/popover.component.d.ts +6 -4
  227. package/lib/components/overlays/popover/popover.component.d.ts.map +1 -1
  228. package/lib/components/overlays/popover/popover.component.js +37 -51
  229. package/lib/components/overlays/tooltip/tooltip.component.d.ts +29 -4
  230. package/lib/components/overlays/tooltip/tooltip.component.d.ts.map +1 -1
  231. package/lib/components/overlays/tooltip/tooltip.component.js +73 -31
  232. package/lib/components/overlays/tooltip/tooltip.styles.d.ts.map +1 -1
  233. package/lib/components/overlays/tooltip/tooltip.styles.js +22 -10
  234. package/lib/components/overlays/tooltip/tooltip.template.d.ts.map +1 -1
  235. package/lib/components/overlays/tooltip/tooltip.template.js +3 -2
  236. package/lib/components/pages/auth/login-page.component.d.ts +11 -4
  237. package/lib/components/pages/auth/login-page.component.d.ts.map +1 -1
  238. package/lib/components/pages/auth/login-page.component.js +18 -5
  239. package/lib/components/pages/auth/login-page.template.d.ts.map +1 -1
  240. package/lib/components/pages/auth/login-page.template.js +9 -10
  241. package/lib/components/pages/auth/signup-page.component.d.ts +11 -4
  242. package/lib/components/pages/auth/signup-page.component.d.ts.map +1 -1
  243. package/lib/components/pages/auth/signup-page.component.js +18 -5
  244. package/lib/components/pages/auth/signup-page.template.d.ts.map +1 -1
  245. package/lib/components/pages/auth/signup-page.template.js +9 -10
  246. package/lib/components/pages/dashboard/dashboard-page.component.d.ts +18 -11
  247. package/lib/components/pages/dashboard/dashboard-page.component.d.ts.map +1 -1
  248. package/lib/components/pages/dashboard/dashboard-page.component.js +55 -13
  249. package/lib/components/pages/dashboard/dashboard-page.template.js +1 -1
  250. package/lib/components/sections/app-shell/app-shell.component.d.ts +6 -6
  251. package/lib/components/sections/app-shell/app-shell.component.d.ts.map +1 -1
  252. package/lib/components/sections/app-shell/app-shell.component.js +14 -6
  253. package/lib/components/sections/app-shell/app-shell.template.js +3 -3
  254. package/lib/components/sections/hero/hero-section.component.d.ts +6 -3
  255. package/lib/components/sections/hero/hero-section.component.d.ts.map +1 -1
  256. package/lib/components/sections/hero/hero-section.component.js +13 -4
  257. package/lib/components/sections/hero/hero-section.template.js +2 -2
  258. package/lib/components/sections/page-header/page-header.component.d.ts +16 -17
  259. package/lib/components/sections/page-header/page-header.component.d.ts.map +1 -1
  260. package/lib/components/sections/page-header/page-header.component.js +36 -25
  261. package/lib/components/sections/page-header/page-header.styles.d.ts.map +1 -1
  262. package/lib/components/sections/page-header/page-header.styles.js +9 -0
  263. package/lib/components/sections/page-header/page-header.template.d.ts +5 -0
  264. package/lib/components/sections/page-header/page-header.template.d.ts.map +1 -1
  265. package/lib/components/sections/page-header/page-header.template.js +42 -31
  266. package/lib/components/sections/page-section/page-section.component.d.ts +16 -12
  267. package/lib/components/sections/page-section/page-section.component.d.ts.map +1 -1
  268. package/lib/components/sections/page-section/page-section.component.js +34 -12
  269. package/lib/components/sections/page-section/page-section.styles.d.ts.map +1 -1
  270. package/lib/components/sections/page-section/page-section.styles.js +6 -0
  271. package/lib/components/sections/page-section/page-section.template.d.ts +6 -0
  272. package/lib/components/sections/page-section/page-section.template.d.ts.map +1 -1
  273. package/lib/components/sections/page-section/page-section.template.js +26 -15
  274. package/lib/components/sections/page-section/sanitize-href.function.d.ts +12 -0
  275. package/lib/components/sections/page-section/sanitize-href.function.d.ts.map +1 -0
  276. package/lib/components/sections/page-section/sanitize-href.function.js +15 -0
  277. package/lib/directives/tooltip.directive.d.ts +8 -2
  278. package/lib/directives/tooltip.directive.d.ts.map +1 -1
  279. package/lib/directives/tooltip.directive.js +103 -9
  280. package/lib/functions/deprecation.functions.d.ts +21 -0
  281. package/lib/functions/deprecation.functions.d.ts.map +1 -0
  282. package/lib/functions/deprecation.functions.js +44 -0
  283. package/lib/functions/index.d.ts +2 -0
  284. package/lib/functions/index.d.ts.map +1 -1
  285. package/lib/functions/index.js +2 -0
  286. package/lib/functions/watch-slot-presence.function.d.ts +17 -0
  287. package/lib/functions/watch-slot-presence.function.d.ts.map +1 -0
  288. package/lib/functions/watch-slot-presence.function.js +27 -0
  289. package/lib/theme/functions/create-theme.function.d.ts +15 -1
  290. package/lib/theme/functions/create-theme.function.d.ts.map +1 -1
  291. package/lib/theme/functions/create-theme.function.js +57 -11
  292. package/lib/theme/index.d.ts +1 -0
  293. package/lib/theme/index.d.ts.map +1 -1
  294. package/lib/types/index.d.ts +8 -2
  295. package/lib/types/index.d.ts.map +1 -1
  296. package/lib/utils/accessibility/focus-trap.d.ts +19 -1
  297. package/lib/utils/accessibility/focus-trap.d.ts.map +1 -1
  298. package/lib/utils/accessibility/focus-trap.js +77 -8
  299. package/lib/utils/accessibility/index.d.ts +2 -1
  300. package/lib/utils/accessibility/index.d.ts.map +1 -1
  301. package/lib/utils/accessibility/index.js +1 -1
  302. package/lib/utils/accessibility/live-region.d.ts +10 -3
  303. package/lib/utils/accessibility/live-region.d.ts.map +1 -1
  304. package/lib/utils/accessibility/live-region.js +64 -35
  305. package/lib/utils/directives/click-outside.directive.d.ts.map +1 -1
  306. package/lib/utils/directives/click-outside.directive.js +5 -3
  307. package/lib/utils/overlay/index.d.ts +4 -0
  308. package/lib/utils/overlay/index.d.ts.map +1 -0
  309. package/lib/utils/overlay/index.js +2 -0
  310. package/lib/utils/overlay/overlay-positioner.d.ts +54 -0
  311. package/lib/utils/overlay/overlay-positioner.d.ts.map +1 -0
  312. package/lib/utils/overlay/overlay-positioner.js +85 -0
  313. package/lib/utils/overlay/toggle-dismiss-guard.d.ts +24 -0
  314. package/lib/utils/overlay/toggle-dismiss-guard.d.ts.map +1 -0
  315. package/lib/utils/overlay/toggle-dismiss-guard.js +36 -0
  316. package/lib/utils/positioning/auto-update.d.ts.map +1 -1
  317. package/lib/utils/positioning/auto-update.js +3 -0
  318. package/lib/utils/positioning/compute-position.d.ts.map +1 -1
  319. package/lib/utils/positioning/compute-position.js +8 -4
  320. package/lib/utils/positioning/middlewares/flip.middleware.d.ts.map +1 -1
  321. package/lib/utils/positioning/middlewares/flip.middleware.js +10 -3
  322. package/lib/utils/positioning/middlewares/offset.middleware.d.ts +15 -0
  323. package/lib/utils/positioning/middlewares/offset.middleware.d.ts.map +1 -1
  324. package/lib/utils/positioning/middlewares/offset.middleware.js +31 -1
  325. package/lib/utils/positioning/middlewares/shift.middleware.d.ts +13 -3
  326. package/lib/utils/positioning/middlewares/shift.middleware.d.ts.map +1 -1
  327. package/lib/utils/positioning/middlewares/shift.middleware.js +15 -7
  328. package/package.json +6 -2
@@ -18,8 +18,10 @@ type DrawerSize = 'sm' | 'md' | 'lg' | 'xl';
18
18
  * @slot drawer-header - Header content (title)
19
19
  * @slot default - Body content
20
20
  * @slot drawer-footer - Footer content (actions)
21
- * @fires ml:open - Emitted when opened
22
- * @fires ml:close - Emitted when closed
21
+ * @fires ml:open - Emitted when opening starts
22
+ * @fires ml:opened - Emitted after the open animation finishes
23
+ * @fires ml:close - Emitted when closing starts
24
+ * @fires ml:closed - Emitted after the close animation finishes (dialog closed)
23
25
  */
24
26
  export declare class DrawerComponent implements IElementRef, OnCreate, OnDestroy {
25
27
  elementRef: HTMLElement;
@@ -32,6 +34,11 @@ export declare class DrawerComponent implements IElementRef, OnCreate, OnDestroy
32
34
  private _dialogEl;
33
35
  private _panelEl;
34
36
  private get _positionProp();
37
+ /**
38
+ * Resolve slide animation timing from the component-scoped tokens
39
+ * (--ml-drawer-transition-duration / --ml-drawer-transition-easing).
40
+ */
41
+ private getAnimationTiming;
35
42
  private cancelAnimations;
36
43
  onCreate(): void;
37
44
  onDestroy(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"drawer.component.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/drawer/drawer.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAIzE,KAAK,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC;AACnC,KAAK,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAMa,eAAgB,YAAW,WAAW,EAAE,QAAQ,EAAE,SAAS;IAChE,UAAU,EAAG,WAAW,CAAC;IAEhC,wCAAwC;IACjC,IAAI,EAAE,UAAU,CAAW;IAElC,mBAAmB;IACZ,IAAI,EAAE,UAAU,CAAQ;IAE/B,kCAAkC;IAC3B,SAAS,UAAQ;IAExB,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,QAAQ,CAAe;IAE/B,OAAO,KAAK,aAAa,GAExB;IAED,OAAO,CAAC,gBAAgB;IAMjB,QAAQ,IAAI,IAAI;IAOhB,SAAS,IAAI,IAAI;IAKxB,sBAAsB;IACf,IAAI,IAAI,IAAI;IAqBnB,uBAAuB;IAChB,KAAK,QAAO,IAAI,CAiBrB;IAEF,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAIlC;IAEF,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAGjC;CACF"}
1
+ {"version":3,"file":"drawer.component.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/drawer/drawer.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAIzE,KAAK,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC;AACnC,KAAK,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAMa,eAAgB,YAAW,WAAW,EAAE,QAAQ,EAAE,SAAS;IAChE,UAAU,EAAG,WAAW,CAAC;IAEhC,wCAAwC;IACjC,IAAI,EAAE,UAAU,CAAW;IAElC,mBAAmB;IACZ,IAAI,EAAE,UAAU,CAAQ;IAE/B,kCAAkC;IAC3B,SAAS,UAAQ;IAExB,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,QAAQ,CAAe;IAE/B,OAAO,KAAK,aAAa,GAExB;IAED;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAkB1B,OAAO,CAAC,gBAAgB;IAMjB,QAAQ,IAAI,IAAI;IAOhB,SAAS,IAAI,IAAI;IAKxB,sBAAsB;IACf,IAAI,IAAI,IAAI;IA2BnB,uBAAuB;IAChB,KAAK,QAAO,IAAI,CAuBrB;IAEF,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAIlC;IAEF,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAGjC;CACF"}
@@ -24,8 +24,10 @@ import { drawerStyles } from './drawer.styles.js';
24
24
  * @slot drawer-header - Header content (title)
25
25
  * @slot default - Body content
26
26
  * @slot drawer-footer - Footer content (actions)
27
- * @fires ml:open - Emitted when opened
28
- * @fires ml:close - Emitted when closed
27
+ * @fires ml:open - Emitted when opening starts
28
+ * @fires ml:opened - Emitted after the open animation finishes
29
+ * @fires ml:close - Emitted when closing starts
30
+ * @fires ml:closed - Emitted after the close animation finishes (dialog closed)
29
31
  */
30
32
  let DrawerComponent = class DrawerComponent {
31
33
  constructor() {
@@ -42,11 +44,15 @@ let DrawerComponent = class DrawerComponent {
42
44
  this.cancelAnimations();
43
45
  const prop = this._positionProp;
44
46
  const width = this._panelEl.offsetWidth;
45
- const anim = this._panelEl.animate([{ [prop]: '0px' }, { [prop]: `${-width}px` }], { duration: 300, easing: 'cubic-bezier(0.16, 1, 0.3, 1)', fill: 'forwards' });
47
+ const { duration, easing } = this.getAnimationTiming();
48
+ const anim = this._panelEl.animate([{ [prop]: '0px' }, { [prop]: `${-width}px` }], { duration, easing, fill: 'forwards' });
46
49
  anim.onfinish = () => {
47
50
  this._panelEl.style[prop] = '';
48
51
  this._dialogEl.close();
52
+ this.elementRef.dispatchEvent(new CustomEvent('ml:closed', { bubbles: true, composed: true }));
49
53
  };
54
+ // ml:close keeps its historical fire-at-start timing; ml:closed fires
55
+ // once the slide-out animation completes and the dialog is closed.
50
56
  this.elementRef.dispatchEvent(new CustomEvent('ml:close', { bubbles: true, composed: true }));
51
57
  };
52
58
  this.handleBackdropClick = (event) => {
@@ -62,6 +68,26 @@ let DrawerComponent = class DrawerComponent {
62
68
  get _positionProp() {
63
69
  return this.side === 'left' ? 'left' : 'right';
64
70
  }
71
+ /**
72
+ * Resolve slide animation timing from the component-scoped tokens
73
+ * (--ml-drawer-transition-duration / --ml-drawer-transition-easing).
74
+ */
75
+ getAnimationTiming() {
76
+ const styles = getComputedStyle(this._panelEl);
77
+ const rawDuration = styles.getPropertyValue('--ml-drawer-transition-duration').trim();
78
+ const rawEasing = styles.getPropertyValue('--ml-drawer-transition-easing').trim();
79
+ let duration = NaN;
80
+ if (rawDuration.endsWith('ms')) {
81
+ duration = Number.parseFloat(rawDuration);
82
+ }
83
+ else if (rawDuration.endsWith('s')) {
84
+ duration = Number.parseFloat(rawDuration) * 1000;
85
+ }
86
+ if (!Number.isFinite(duration)) {
87
+ duration = 300;
88
+ }
89
+ return { duration, easing: rawEasing || 'cubic-bezier(0.16, 1, 0.3, 1)' };
90
+ }
65
91
  cancelAnimations() {
66
92
  for (const anim of this._panelEl.getAnimations()) {
67
93
  anim.cancel();
@@ -85,12 +111,16 @@ let DrawerComponent = class DrawerComponent {
85
111
  this._dialogEl.showModal();
86
112
  const prop = this._positionProp;
87
113
  const width = this._panelEl.offsetWidth;
114
+ const { duration, easing } = this.getAnimationTiming();
88
115
  this._panelEl.style[prop] = `${-width}px`;
89
116
  this._panelEl.getBoundingClientRect();
90
- const anim = this._panelEl.animate([{ [prop]: `${-width}px` }, { [prop]: '0px' }], { duration: 300, easing: 'cubic-bezier(0.16, 1, 0.3, 1)', fill: 'forwards' });
117
+ const anim = this._panelEl.animate([{ [prop]: `${-width}px` }, { [prop]: '0px' }], { duration, easing, fill: 'forwards' });
91
118
  anim.onfinish = () => {
92
119
  this._panelEl.style[prop] = '0px';
120
+ this.elementRef.dispatchEvent(new CustomEvent('ml:opened', { bubbles: true, composed: true }));
93
121
  };
122
+ // ml:open keeps its historical fire-at-start timing; ml:opened fires
123
+ // after the slide-in animation completes.
94
124
  this.elementRef.dispatchEvent(new CustomEvent('ml:open', { bubbles: true, composed: true }));
95
125
  }
96
126
  };
@@ -1 +1 @@
1
- {"version":3,"file":"drawer.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/drawer/drawer.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,iDAoNxB,CAAC"}
1
+ {"version":3,"file":"drawer.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/drawer/drawer.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,iDAwNxB,CAAC"}
@@ -9,6 +9,10 @@ export const drawerStyles = () => css `
9
9
  --ml-drawer-bg: var(--ml-color-surface);
10
10
  --ml-drawer-shadow: var(--ml-shadow-xl);
11
11
 
12
+ /* Slide animation (read by the component for the panel animation) */
13
+ --ml-drawer-transition-duration: var(--ml-duration-300);
14
+ --ml-drawer-transition-easing: cubic-bezier(0.16, 1, 0.3, 1);
15
+
12
16
  /* Size variants */
13
17
  --ml-drawer-sm-width: 320px;
14
18
  --ml-drawer-md-width: 480px;
@@ -1,4 +1,4 @@
1
- import type { IElementRef } from '@melodicdev/core';
1
+ import type { IElementRef, OnCreate, OnRender } from '@melodicdev/core';
2
2
  /**
3
3
  * ml-dropdown-item - Individual menu item within a dropdown
4
4
  *
@@ -11,7 +11,7 @@ import type { IElementRef } from '@melodicdev/core';
11
11
  * @slot default - The item label text
12
12
  * @fires ml:item-select - Internal event caught by parent dropdown
13
13
  */
14
- export declare class DropdownItemComponent implements IElementRef {
14
+ export declare class DropdownItemComponent implements IElementRef, OnCreate, OnRender {
15
15
  elementRef: HTMLElement;
16
16
  /** Selection value emitted on click */
17
17
  value: string;
@@ -25,6 +25,9 @@ export declare class DropdownItemComponent implements IElementRef {
25
25
  destructive: boolean;
26
26
  /** Set by parent dropdown for keyboard navigation highlight */
27
27
  focused: boolean;
28
+ onCreate(): void;
29
+ onRender(): void;
30
+ private syncHostAria;
28
31
  handleClick: () => void;
29
32
  }
30
33
  //# sourceMappingURL=dropdown-item.component.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown-item.component.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/dropdown/dropdown-item.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAIpD;;;;;;;;;;;GAWG;AACH,qBAMa,qBAAsB,YAAW,WAAW;IACjD,UAAU,EAAG,WAAW,CAAC;IAEhC,uCAAuC;IAChC,KAAK,SAAM;IAElB,gCAAgC;IACzB,IAAI,SAAM;IAEjB,gDAAgD;IACzC,KAAK,SAAM;IAElB,4BAA4B;IACrB,QAAQ,UAAS;IAExB,yBAAyB;IAClB,WAAW,UAAS;IAE3B,+DAA+D;IACxD,OAAO,UAAS;IAEhB,WAAW,QAAO,IAAI,CAU3B;CACF"}
1
+ {"version":3,"file":"dropdown-item.component.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/dropdown/dropdown-item.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAKxE;;;;;;;;;;;GAWG;AACH,qBAMa,qBAAsB,YAAW,WAAW,EAAE,QAAQ,EAAE,QAAQ;IACrE,UAAU,EAAG,WAAW,CAAC;IAEhC,uCAAuC;IAChC,KAAK,SAAM;IAElB,gCAAgC;IACzB,IAAI,SAAM;IAEjB,gDAAgD;IACzC,KAAK,SAAM;IAElB,4BAA4B;IACrB,QAAQ,UAAS;IAExB,yBAAyB;IAClB,WAAW,UAAS;IAE3B,+DAA+D;IACxD,OAAO,UAAS;IAEhB,QAAQ,IAAI,IAAI;IAYhB,QAAQ,IAAI,IAAI;IAIvB,OAAO,CAAC,YAAY;IAIb,WAAW,QAAO,IAAI,CAU3B;CACF"}
@@ -5,6 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { MelodicComponent } from '@melodicdev/core';
8
+ import { newID } from '../../../functions/new-id.function.js';
8
9
  import { dropdownItemTemplate } from './dropdown-item.template.js';
9
10
  import { dropdownItemStyles } from './dropdown-item.styles.js';
10
11
  /**
@@ -43,6 +44,23 @@ let DropdownItemComponent = class DropdownItemComponent {
43
44
  }));
44
45
  };
45
46
  }
47
+ onCreate() {
48
+ // The host carries the menuitem semantics: it lives in the same (light
49
+ // DOM) tree as the dropdown trigger, so its id is a valid
50
+ // aria-activedescendant reference for the trigger.
51
+ if (!this.elementRef.id) {
52
+ this.elementRef.id = newID();
53
+ }
54
+ this.elementRef.setAttribute('role', 'menuitem');
55
+ this.elementRef.setAttribute('tabindex', '-1');
56
+ this.syncHostAria();
57
+ }
58
+ onRender() {
59
+ this.syncHostAria();
60
+ }
61
+ syncHostAria() {
62
+ this.elementRef.setAttribute('aria-disabled', String(this.disabled));
63
+ }
46
64
  };
47
65
  DropdownItemComponent = __decorate([
48
66
  MelodicComponent({
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown-item.template.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/dropdown/dropdown-item.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE1E,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,qBAAqB,6CAyB5D"}
1
+ {"version":3,"file":"dropdown-item.template.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/dropdown/dropdown-item.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE1E,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,qBAAqB,6CAsB5D"}
@@ -8,9 +8,6 @@ export function dropdownItemTemplate(c) {
8
8
  'ml-dropdown-item--disabled': c.disabled,
9
9
  'ml-dropdown-item--destructive': c.destructive
10
10
  })}
11
- role="menuitem"
12
- tabindex="-1"
13
- aria-disabled=${c.disabled || false}
14
11
  @click=${c.handleClick}
15
12
  >
16
13
  ${when(!!c.icon, () => html `<ml-icon class="ml-dropdown-item__icon" icon=${c.icon} size="sm"></ml-icon>`)}
@@ -29,8 +29,9 @@ export declare class DropdownComponent implements IElementRef, OnCreate, OnDestr
29
29
  /** Current open state */
30
30
  isOpen: boolean;
31
31
  private _focusedIndex;
32
- private _cleanupAutoUpdate;
33
- private _justDismissed;
32
+ private readonly _positioner;
33
+ private readonly _dismissGuard;
34
+ private _restoreFocusOnClose;
34
35
  onCreate(): void;
35
36
  onDestroy(): void;
36
37
  /** Open the menu */
@@ -51,9 +52,12 @@ export declare class DropdownComponent implements IElementRef, OnCreate, OnDestr
51
52
  private findFirstEnabled;
52
53
  private findLastEnabled;
53
54
  private returnFocusToTrigger;
55
+ /** First element assigned to the trigger slot (light DOM). */
56
+ private getAssignedTrigger;
57
+ /** Keep the slotted trigger's menu-button ARIA in sync with open state. */
58
+ private readonly syncTriggerAria;
59
+ /** True when the (deep) focused element is inside this dropdown. */
54
60
  private startPositioning;
55
- private updatePosition;
56
- private positionArrow;
57
61
  private getTriggerEl;
58
62
  private getMenuEl;
59
63
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown.component.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/dropdown/dropdown.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAMzD;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAMa,iBAAkB,YAAW,WAAW,EAAE,QAAQ,EAAE,SAAS;IAClE,UAAU,EAAG,WAAW,CAAC;IAEhC,yCAAyC;IAClC,SAAS,EAAE,SAAS,CAAkB;IAE7C,yCAAyC;IAClC,MAAM,SAAK;IAElB,qCAAqC;IAC9B,KAAK,UAAS;IAErB,yBAAyB;IAClB,MAAM,UAAS;IAEtB,OAAO,CAAC,aAAa,CAAM;IAC3B,OAAO,CAAC,kBAAkB,CAA6B;IAGvD,OAAO,CAAC,cAAc,CAAS;IAExB,QAAQ,IAAI,IAAI;IAUhB,SAAS,IAAI,IAAI;IAUxB,oBAAoB;IACb,IAAI,IAAI,IAAI;IAOnB,qBAAqB;IACd,KAAK,IAAI,IAAI;IAOpB,sBAAsB;IACf,MAAM,QAAO,IAAI,CAWtB;IAEF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAuB3B;IAEF,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAW/B;IAEF,OAAO,CAAC,QAAQ,CAAC,aAAa,CAwD5B;IAEF,OAAO,CAAC,iBAAiB;IAyBzB,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,aAAa;IAWrB,OAAO,CAAC,iBAAiB;IAWzB,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,UAAU;IAQlB,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,oBAAoB;IAU5B,OAAO,CAAC,gBAAgB;IAYxB,OAAO,CAAC,cAAc;IAuBtB,OAAO,CAAC,aAAa;IAsBrB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,SAAS;CAGjB"}
1
+ {"version":3,"file":"dropdown.component.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/dropdown/dropdown.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AASzD;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAMa,iBAAkB,YAAW,WAAW,EAAE,QAAQ,EAAE,SAAS;IAClE,UAAU,EAAG,WAAW,CAAC;IAEhC,yCAAyC;IAClC,SAAS,EAAE,SAAS,CAAkB;IAE7C,yCAAyC;IAClC,MAAM,SAAK;IAElB,qCAAqC;IAC9B,KAAK,UAAS;IAErB,yBAAyB;IAClB,MAAM,UAAS;IAEtB,OAAO,CAAC,aAAa,CAAM;IAC3B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAKxB;IAGJ,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA4B;IAI1D,OAAO,CAAC,oBAAoB,CAAS;IAE9B,QAAQ,IAAI,IAAI;IAYhB,SAAS,IAAI,IAAI;IAWxB,oBAAoB;IACb,IAAI,IAAI,IAAI;IAOnB,qBAAqB;IACd,KAAK,IAAI,IAAI;IAOpB,sBAAsB;IACf,MAAM,QAAO,IAAI,CAUtB;IAEF,OAAO,CAAC,QAAQ,CAAC,YAAY,CA6B3B;IAEF,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAW/B;IAEF,OAAO,CAAC,QAAQ,CAAC,aAAa,CA6D5B;IAEF,OAAO,CAAC,iBAAiB;IAyBzB,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,aAAa;IAWrB,OAAO,CAAC,iBAAiB;IAWzB,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,UAAU;IASlB,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,oBAAoB;IAI5B,8DAA8D;IAC9D,OAAO,CAAC,kBAAkB;IAM1B,2EAA2E;IAC3E,OAAO,CAAC,QAAQ,CAAC,eAAe,CAK9B;IAEF,oEAAoE;IACpE,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,SAAS;CAGjB"}
@@ -5,7 +5,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { MelodicComponent } from '@melodicdev/core';
8
- import { computePosition, autoUpdate, offset, flip, shift, arrow as arrowMiddleware } from '../../../utils/positioning/index.js';
8
+ import { OverlayPositioner, ToggleDismissGuard } from '../../../utils/overlay/index.js';
9
+ import { isDeepFocusWithin } from '../../../utils/accessibility/focus-trap.js';
9
10
  import { dropdownTemplate } from './dropdown.template.js';
10
11
  import { dropdownStyles } from './dropdown.styles.js';
11
12
  /**
@@ -37,16 +38,24 @@ let DropdownComponent = class DropdownComponent {
37
38
  /** Current open state */
38
39
  this.isOpen = false;
39
40
  this._focusedIndex = -1;
40
- this._cleanupAutoUpdate = null;
41
- // Set when the popover light-dismisses, consumed by the next toggle() so a
42
- // click on the trigger that just dismissed the menu doesn't immediately reopen it.
43
- this._justDismissed = false;
41
+ this._positioner = new OverlayPositioner(() => ({
42
+ placement: this.placement,
43
+ offset: this.offset,
44
+ arrowElement: this.arrow ? this.elementRef.shadowRoot?.querySelector('.ml-dropdown__arrow') : null,
45
+ placementAttribute: true
46
+ }));
47
+ // Swallows the trigger click that just light-dismissed the open menu so it
48
+ // doesn't immediately reopen it.
49
+ this._dismissGuard = new ToggleDismissGuard();
50
+ // Set by keyboard-initiated closes (Escape/Tab/Enter selection) so focus is
51
+ // returned to the trigger only for keyboard or inside-overlay dismissals —
52
+ // never yanked away from an element the user just clicked outside the menu.
53
+ this._restoreFocusOnClose = false;
44
54
  /** Toggle the menu */
45
55
  this.toggle = () => {
46
56
  // A click on the trigger that just light-dismissed the open menu would
47
57
  // otherwise reopen it. Swallow that one toggle.
48
- if (this._justDismissed) {
49
- this._justDismissed = false;
58
+ if (this._dismissGuard.shouldSkipToggle()) {
50
59
  return;
51
60
  }
52
61
  const menuEl = this.getMenuEl();
@@ -65,15 +74,21 @@ let DropdownComponent = class DropdownComponent {
65
74
  else {
66
75
  this.isOpen = false;
67
76
  // Guard the immediately-following trigger click (if this dismiss was
68
- // caused by clicking the trigger). Cleared next macrotask otherwise.
69
- this._justDismissed = true;
70
- setTimeout(() => { this._justDismissed = false; }, 0);
77
+ // caused by clicking the trigger).
78
+ this._dismissGuard.dismissed();
79
+ // Restore trigger focus only for keyboard dismissals or when focus is
80
+ // still inside the dropdown (e.g. an item was clicked). A pointer
81
+ // light-dismiss that moved focus elsewhere must not steal it back.
82
+ const shouldRestoreFocus = this._restoreFocusOnClose || isDeepFocusWithin(this.elementRef);
83
+ this._restoreFocusOnClose = false;
71
84
  this.clearFocus();
72
- this._cleanupAutoUpdate?.();
73
- this._cleanupAutoUpdate = null;
74
- this.returnFocusToTrigger();
85
+ this._positioner.stop();
86
+ if (shouldRestoreFocus) {
87
+ this.returnFocusToTrigger();
88
+ }
75
89
  this.elementRef.dispatchEvent(new CustomEvent('ml:close', { bubbles: true, composed: true }));
76
90
  }
91
+ this.syncTriggerAria();
77
92
  };
78
93
  this.handleItemSelect = (event) => {
79
94
  event.stopPropagation();
@@ -111,12 +126,17 @@ let DropdownComponent = class DropdownComponent {
111
126
  if (this._focusedIndex >= 0 && this._focusedIndex < items.length) {
112
127
  const item = items[this._focusedIndex];
113
128
  if (!item.disabled) {
114
- item.handleClick();
129
+ this._restoreFocusOnClose = true;
130
+ // Methods aren't reflected on the host element; fall back to
131
+ // the component instance when needed.
132
+ const instance = item.component ?? item;
133
+ instance.handleClick();
115
134
  }
116
135
  }
117
136
  break;
118
137
  case 'Escape':
119
138
  event.preventDefault();
139
+ this._restoreFocusOnClose = true;
120
140
  this.close();
121
141
  break;
122
142
  case 'Tab':
@@ -134,6 +154,14 @@ let DropdownComponent = class DropdownComponent {
134
154
  break;
135
155
  }
136
156
  };
157
+ /** Keep the slotted trigger's menu-button ARIA in sync with open state. */
158
+ this.syncTriggerAria = () => {
159
+ const trigger = this.getAssignedTrigger();
160
+ if (!trigger)
161
+ return;
162
+ trigger.setAttribute('aria-haspopup', 'menu');
163
+ trigger.setAttribute('aria-expanded', String(this.isOpen));
164
+ };
137
165
  }
138
166
  onCreate() {
139
167
  const menuEl = this.getMenuEl();
@@ -142,15 +170,18 @@ let DropdownComponent = class DropdownComponent {
142
170
  }
143
171
  this.elementRef.addEventListener('ml:item-select', this.handleItemSelect);
144
172
  this.elementRef.addEventListener('keydown', this.handleKeyDown);
173
+ this.elementRef.shadowRoot?.addEventListener('slotchange', this.syncTriggerAria);
174
+ this.syncTriggerAria();
145
175
  }
146
176
  onDestroy() {
147
- this._cleanupAutoUpdate?.();
177
+ this._positioner.stop();
148
178
  const menuEl = this.getMenuEl();
149
179
  if (menuEl) {
150
180
  menuEl.removeEventListener('toggle', this.handleToggle);
151
181
  }
152
182
  this.elementRef.removeEventListener('ml:item-select', this.handleItemSelect);
153
183
  this.elementRef.removeEventListener('keydown', this.handleKeyDown);
184
+ this.elementRef.shadowRoot?.removeEventListener('slotchange', this.syncTriggerAria);
154
185
  }
155
186
  /** Open the menu */
156
187
  open() {
@@ -221,6 +252,12 @@ let DropdownComponent = class DropdownComponent {
221
252
  items[i].focused = i === index;
222
253
  }
223
254
  this._focusedIndex = index;
255
+ // The item host lives in the same tree as the trigger, so its id is a
256
+ // valid aria-activedescendant reference for screen readers.
257
+ const itemID = items[index].id;
258
+ if (itemID) {
259
+ this.getAssignedTrigger()?.setAttribute('aria-activedescendant', itemID);
260
+ }
224
261
  }
225
262
  clearFocus() {
226
263
  const items = this.getNavigableItems();
@@ -228,6 +265,7 @@ let DropdownComponent = class DropdownComponent {
228
265
  item.focused = false;
229
266
  }
230
267
  this._focusedIndex = -1;
268
+ this.getAssignedTrigger()?.removeAttribute('aria-activedescendant');
231
269
  }
232
270
  findFirstEnabled(items) {
233
271
  return items.findIndex((item) => !item.disabled);
@@ -240,58 +278,21 @@ let DropdownComponent = class DropdownComponent {
240
278
  return -1;
241
279
  }
242
280
  returnFocusToTrigger() {
281
+ this.getAssignedTrigger()?.focus();
282
+ }
283
+ /** First element assigned to the trigger slot (light DOM). */
284
+ getAssignedTrigger() {
243
285
  const triggerSlot = this.elementRef.shadowRoot?.querySelector('slot[name="trigger"]');
244
- if (triggerSlot) {
245
- const assigned = triggerSlot.assignedElements();
246
- if (assigned.length > 0) {
247
- assigned[0].focus();
248
- }
249
- }
286
+ const assigned = triggerSlot?.assignedElements() ?? [];
287
+ return assigned[0] ?? null;
250
288
  }
289
+ /** True when the (deep) focused element is inside this dropdown. */
251
290
  startPositioning() {
252
291
  const triggerEl = this.getTriggerEl();
253
292
  const menuEl = this.getMenuEl();
254
293
  if (!triggerEl || !menuEl)
255
294
  return;
256
- const update = () => this.updatePosition(triggerEl, menuEl);
257
- this._cleanupAutoUpdate?.();
258
- this._cleanupAutoUpdate = autoUpdate(triggerEl, menuEl, update);
259
- }
260
- updatePosition(triggerEl, menuEl) {
261
- const arrowEl = this.arrow ? this.elementRef.shadowRoot?.querySelector('.ml-dropdown__arrow') : null;
262
- const middleware = [offset(this.offset), flip(), shift({ padding: 8 })];
263
- if (arrowEl) {
264
- middleware.push(arrowMiddleware({ element: arrowEl, padding: 8 }));
265
- }
266
- const { x, y, placement, middlewareData } = computePosition(triggerEl, menuEl, {
267
- placement: this.placement,
268
- middleware
269
- });
270
- menuEl.style.left = `${x}px`;
271
- menuEl.style.top = `${y}px`;
272
- menuEl.dataset.placement = placement;
273
- if (arrowEl && middlewareData.arrow) {
274
- this.positionArrow(arrowEl, placement, middlewareData.arrow);
275
- }
276
- }
277
- positionArrow(arrowEl, placement, arrowData) {
278
- const side = placement.split('-')[0];
279
- arrowEl.style.left = arrowData.x === undefined ? '' : `${arrowData.x}px`;
280
- arrowEl.style.right = '';
281
- arrowEl.style.top = arrowData.y === undefined ? '' : `${arrowData.y}px`;
282
- arrowEl.style.bottom = '';
283
- if (side === 'top') {
284
- arrowEl.style.bottom = '-4px';
285
- }
286
- if (side === 'bottom') {
287
- arrowEl.style.top = '-4px';
288
- }
289
- if (side === 'left') {
290
- arrowEl.style.right = '-4px';
291
- }
292
- if (side === 'right') {
293
- arrowEl.style.left = '-4px';
294
- }
295
+ this._positioner.start(triggerEl, menuEl);
295
296
  }
296
297
  getTriggerEl() {
297
298
  return this.elementRef.shadowRoot?.querySelector('.ml-dropdown__trigger');
@@ -21,6 +21,8 @@ import type { Placement } from '../../../types/index.js';
21
21
  *
22
22
  * @slot trigger - The element that toggles the popover
23
23
  * @slot default - The popover content
24
+ * @fires ml:open - Emitted when the popover opens
25
+ * @fires ml:close - Emitted when the popover closes
24
26
  */
25
27
  export declare class PopoverComponent implements IElementRef, OnCreate, OnDestroy {
26
28
  elementRef: HTMLElement;
@@ -34,8 +36,9 @@ export declare class PopoverComponent implements IElementRef, OnCreate, OnDestro
34
36
  arrow: boolean;
35
37
  /** Current open state */
36
38
  isOpen: boolean;
37
- private _cleanupAutoUpdate;
38
- private _justDismissed;
39
+ private readonly _positioner;
40
+ private _focusTrap;
41
+ private readonly _dismissGuard;
39
42
  onCreate(): void;
40
43
  onDestroy(): void;
41
44
  /** Open the popover */
@@ -45,9 +48,8 @@ export declare class PopoverComponent implements IElementRef, OnCreate, OnDestro
45
48
  /** Toggle the popover */
46
49
  toggle: () => void;
47
50
  private readonly handleToggle;
51
+ private activateFocusTrap;
48
52
  private startPositioning;
49
- private updatePosition;
50
- private positionArrow;
51
53
  private getTriggerEl;
52
54
  private getPopoverEl;
53
55
  }
@@ -1 +1 @@
1
- {"version":3,"file":"popover.component.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/popover/popover.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAKzD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAMa,gBAAiB,YAAW,WAAW,EAAE,QAAQ,EAAE,SAAS;IACjE,UAAU,EAAG,WAAW,CAAC;IAEhC,4CAA4C;IACrC,SAAS,EAAE,SAAS,CAAY;IAEvC,4CAA4C;IACrC,MAAM,SAAK;IAElB,0DAA0D;IACnD,MAAM,UAAS;IAEtB,wDAAwD;IACjD,KAAK,UAAS;IAErB,yBAAyB;IAClB,MAAM,UAAS;IAEtB,OAAO,CAAC,kBAAkB,CAA6B;IAGvD,OAAO,CAAC,cAAc,CAAS;IAExB,QAAQ,IAAI,IAAI;IAOhB,SAAS,IAAI,IAAI;IAQxB,uBAAuB;IAChB,IAAI,IAAI,IAAI;IAOnB,wBAAwB;IACjB,KAAK,IAAI,IAAI;IAOpB,yBAAyB;IAClB,MAAM,QAAO,IAAI,CAWtB;IAEF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAY3B;IAEF,OAAO,CAAC,gBAAgB;IAYxB,OAAO,CAAC,cAAc;IAuBtB,OAAO,CAAC,aAAa;IAsBrB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,YAAY;CAGpB"}
1
+ {"version":3,"file":"popover.component.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/popover/popover.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAMzD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAMa,gBAAiB,YAAW,WAAW,EAAE,QAAQ,EAAE,SAAS;IACjE,UAAU,EAAG,WAAW,CAAC;IAEhC,4CAA4C;IACrC,SAAS,EAAE,SAAS,CAAY;IAEvC,4CAA4C;IACrC,MAAM,SAAK;IAElB,0DAA0D;IACnD,MAAM,UAAS;IAEtB,wDAAwD;IACjD,KAAK,UAAS;IAErB,yBAAyB;IAClB,MAAM,UAAS;IAEtB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAKxB;IACJ,OAAO,CAAC,UAAU,CAA0B;IAG5C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA4B;IAEnD,QAAQ,IAAI,IAAI;IAOhB,SAAS,IAAI,IAAI;IAUxB,uBAAuB;IAChB,IAAI,IAAI,IAAI;IAOnB,wBAAwB;IACjB,KAAK,IAAI,IAAI;IAOpB,yBAAyB;IAClB,MAAM,QAAO,IAAI,CAUtB;IAEF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAsB3B;IAEF,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,YAAY;CAGpB"}
@@ -5,7 +5,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { MelodicComponent } from '@melodicdev/core';
8
- import { computePosition, autoUpdate, offset, flip, shift, arrow as arrowMiddleware } from '../../../utils/positioning/index.js';
8
+ import { OverlayPositioner, ToggleDismissGuard } from '../../../utils/overlay/index.js';
9
+ import { createFocusTrap, isDeepFocusWithin } from '../../../utils/accessibility/focus-trap.js';
9
10
  import { popoverTemplate } from './popover.template.js';
10
11
  import { popoverStyles } from './popover.styles.js';
11
12
  /**
@@ -29,6 +30,8 @@ import { popoverStyles } from './popover.styles.js';
29
30
  *
30
31
  * @slot trigger - The element that toggles the popover
31
32
  * @slot default - The popover content
33
+ * @fires ml:open - Emitted when the popover opens
34
+ * @fires ml:close - Emitted when the popover closes
32
35
  */
33
36
  let PopoverComponent = class PopoverComponent {
34
37
  constructor() {
@@ -42,16 +45,21 @@ let PopoverComponent = class PopoverComponent {
42
45
  this.arrow = false;
43
46
  /** Current open state */
44
47
  this.isOpen = false;
45
- this._cleanupAutoUpdate = null;
46
- // Set when the popover light-dismisses, consumed by the next toggle() so a
47
- // click on the trigger that just dismissed it doesn't immediately reopen it.
48
- this._justDismissed = false;
48
+ this._positioner = new OverlayPositioner(() => ({
49
+ placement: this.placement,
50
+ offset: this.offset,
51
+ arrowElement: this.arrow ? this.elementRef.shadowRoot?.querySelector('.ml-popover__arrow') : null,
52
+ placementAttribute: true
53
+ }));
54
+ this._focusTrap = null;
55
+ // Swallows the trigger click that just light-dismissed the open popover so
56
+ // it doesn't immediately reopen it.
57
+ this._dismissGuard = new ToggleDismissGuard();
49
58
  /** Toggle the popover */
50
59
  this.toggle = () => {
51
60
  // Swallow the click that just light-dismissed the open popover, so the
52
61
  // trigger doesn't immediately reopen it.
53
- if (this._justDismissed) {
54
- this._justDismissed = false;
62
+ if (this._dismissGuard.shouldSkipToggle()) {
55
63
  return;
56
64
  }
57
65
  const popoverEl = this.getPopoverEl();
@@ -64,13 +72,19 @@ let PopoverComponent = class PopoverComponent {
64
72
  if (toggleEvent.newState === 'open') {
65
73
  this.isOpen = true;
66
74
  this.startPositioning();
75
+ this.activateFocusTrap();
76
+ this.elementRef.dispatchEvent(new CustomEvent('ml:open', { bubbles: true, composed: true }));
67
77
  }
68
78
  else {
69
79
  this.isOpen = false;
70
- this._justDismissed = true;
71
- setTimeout(() => { this._justDismissed = false; }, 0);
72
- this._cleanupAutoUpdate?.();
73
- this._cleanupAutoUpdate = null;
80
+ this._dismissGuard.dismissed();
81
+ this._positioner.stop();
82
+ // Restore focus only when it is still inside the popover (keyboard
83
+ // dismiss / focus parked in the content); a pointer light-dismiss
84
+ // that moved focus elsewhere must not have it yanked back.
85
+ this._focusTrap?.deactivate({ returnFocus: isDeepFocusWithin(this.elementRef) });
86
+ this._focusTrap = null;
87
+ this.elementRef.dispatchEvent(new CustomEvent('ml:close', { bubbles: true, composed: true }));
74
88
  }
75
89
  };
76
90
  }
@@ -81,7 +95,9 @@ let PopoverComponent = class PopoverComponent {
81
95
  }
82
96
  }
83
97
  onDestroy() {
84
- this._cleanupAutoUpdate?.();
98
+ this._positioner.stop();
99
+ this._focusTrap?.deactivate({ returnFocus: false });
100
+ this._focusTrap = null;
85
101
  const popoverEl = this.getPopoverEl();
86
102
  if (popoverEl) {
87
103
  popoverEl.removeEventListener('toggle', this.handleToggle);
@@ -101,50 +117,20 @@ let PopoverComponent = class PopoverComponent {
101
117
  popoverEl.hidePopover();
102
118
  }
103
119
  }
120
+ activateFocusTrap() {
121
+ const popoverEl = this.getPopoverEl();
122
+ if (!popoverEl)
123
+ return;
124
+ this._focusTrap?.deactivate({ returnFocus: false });
125
+ this._focusTrap = createFocusTrap(popoverEl);
126
+ this._focusTrap.activate();
127
+ }
104
128
  startPositioning() {
105
129
  const triggerEl = this.getTriggerEl();
106
130
  const popoverEl = this.getPopoverEl();
107
131
  if (!triggerEl || !popoverEl)
108
132
  return;
109
- const update = () => this.updatePosition(triggerEl, popoverEl);
110
- this._cleanupAutoUpdate?.();
111
- this._cleanupAutoUpdate = autoUpdate(triggerEl, popoverEl, update);
112
- }
113
- updatePosition(triggerEl, popoverEl) {
114
- const arrowEl = this.arrow ? this.elementRef.shadowRoot?.querySelector('.ml-popover__arrow') : null;
115
- const middleware = [offset(this.offset), flip(), shift({ padding: 8 })];
116
- if (arrowEl) {
117
- middleware.push(arrowMiddleware({ element: arrowEl, padding: 8 }));
118
- }
119
- const { x, y, placement, middlewareData } = computePosition(triggerEl, popoverEl, {
120
- placement: this.placement,
121
- middleware
122
- });
123
- popoverEl.style.left = `${x}px`;
124
- popoverEl.style.top = `${y}px`;
125
- popoverEl.dataset.placement = placement;
126
- if (arrowEl && middlewareData.arrow) {
127
- this.positionArrow(arrowEl, placement, middlewareData.arrow);
128
- }
129
- }
130
- positionArrow(arrowEl, placement, arrowData) {
131
- const side = placement.split('-')[0];
132
- arrowEl.style.left = arrowData.x === undefined ? '' : `${arrowData.x}px`;
133
- arrowEl.style.right = '';
134
- arrowEl.style.top = arrowData.y === undefined ? '' : `${arrowData.y}px`;
135
- arrowEl.style.bottom = '';
136
- if (side === 'top') {
137
- arrowEl.style.bottom = '-4px';
138
- }
139
- if (side === 'bottom') {
140
- arrowEl.style.top = '-4px';
141
- }
142
- if (side === 'left') {
143
- arrowEl.style.right = '-4px';
144
- }
145
- if (side === 'right') {
146
- arrowEl.style.left = '-4px';
147
- }
133
+ this._positioner.start(triggerEl, popoverEl);
148
134
  }
149
135
  getTriggerEl() {
150
136
  return this.elementRef.shadowRoot?.querySelector('.ml-popover__trigger');