mood-ui 0.10.0 → 0.11.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 (255) hide show
  1. package/dist/components/data-display/Chart.cjs +6 -0
  2. package/dist/components/data-display/Chart.cjs.map +1 -0
  3. package/dist/components/data-display/Chart.mjs +7 -0
  4. package/dist/components/data-display/Chart.mjs.map +1 -0
  5. package/dist/components/data-display/Chart.vue_vue_type_script_setup_true_lang.cjs +48 -0
  6. package/dist/components/data-display/Chart.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
  7. package/dist/components/data-display/Chart.vue_vue_type_script_setup_true_lang.mjs +47 -0
  8. package/dist/components/data-display/Chart.vue_vue_type_script_setup_true_lang.mjs.map +1 -0
  9. package/dist/components/data-display/Stat.cjs.map +1 -1
  10. package/dist/components/data-display/Stat.mjs.map +1 -1
  11. package/dist/components/data-display/Stat.vue_vue_type_script_setup_true_lang.cjs +88 -75
  12. package/dist/components/data-display/Stat.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  13. package/dist/components/data-display/Stat.vue_vue_type_script_setup_true_lang.mjs +90 -77
  14. package/dist/components/data-display/Stat.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  15. package/dist/components/data-display/chart/Cartesian.cjs +6 -0
  16. package/dist/components/data-display/chart/Cartesian.cjs.map +1 -0
  17. package/dist/components/data-display/chart/Cartesian.mjs +7 -0
  18. package/dist/components/data-display/chart/Cartesian.mjs.map +1 -0
  19. package/dist/components/data-display/chart/Cartesian.vue_vue_type_script_setup_true_lang.cjs +573 -0
  20. package/dist/components/data-display/chart/Cartesian.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
  21. package/dist/components/data-display/chart/Cartesian.vue_vue_type_script_setup_true_lang.mjs +572 -0
  22. package/dist/components/data-display/chart/Cartesian.vue_vue_type_script_setup_true_lang.mjs.map +1 -0
  23. package/dist/components/data-display/chart/Heatmap.cjs +6 -0
  24. package/dist/components/data-display/chart/Heatmap.cjs.map +1 -0
  25. package/dist/components/data-display/chart/Heatmap.mjs +7 -0
  26. package/dist/components/data-display/chart/Heatmap.mjs.map +1 -0
  27. package/dist/components/data-display/chart/Heatmap.vue_vue_type_script_setup_true_lang.cjs +332 -0
  28. package/dist/components/data-display/chart/Heatmap.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
  29. package/dist/components/data-display/chart/Heatmap.vue_vue_type_script_setup_true_lang.mjs +331 -0
  30. package/dist/components/data-display/chart/Heatmap.vue_vue_type_script_setup_true_lang.mjs.map +1 -0
  31. package/dist/components/data-display/chart/Polar.cjs +6 -0
  32. package/dist/components/data-display/chart/Polar.cjs.map +1 -0
  33. package/dist/components/data-display/chart/Polar.mjs +7 -0
  34. package/dist/components/data-display/chart/Polar.mjs.map +1 -0
  35. package/dist/components/data-display/chart/Polar.vue_vue_type_script_setup_true_lang.cjs +361 -0
  36. package/dist/components/data-display/chart/Polar.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
  37. package/dist/components/data-display/chart/Polar.vue_vue_type_script_setup_true_lang.mjs +360 -0
  38. package/dist/components/data-display/chart/Polar.vue_vue_type_script_setup_true_lang.mjs.map +1 -0
  39. package/dist/components/data-display/chart/Radar.cjs +6 -0
  40. package/dist/components/data-display/chart/Radar.cjs.map +1 -0
  41. package/dist/components/data-display/chart/Radar.mjs +7 -0
  42. package/dist/components/data-display/chart/Radar.mjs.map +1 -0
  43. package/dist/components/data-display/chart/Radar.vue_vue_type_script_setup_true_lang.cjs +347 -0
  44. package/dist/components/data-display/chart/Radar.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
  45. package/dist/components/data-display/chart/Radar.vue_vue_type_script_setup_true_lang.mjs +346 -0
  46. package/dist/components/data-display/chart/Radar.vue_vue_type_script_setup_true_lang.mjs.map +1 -0
  47. package/dist/components/data-display/chart/Sparkline.cjs +6 -0
  48. package/dist/components/data-display/chart/Sparkline.cjs.map +1 -0
  49. package/dist/components/data-display/chart/Sparkline.mjs +7 -0
  50. package/dist/components/data-display/chart/Sparkline.mjs.map +1 -0
  51. package/dist/components/data-display/chart/Sparkline.vue_vue_type_script_setup_true_lang.cjs +293 -0
  52. package/dist/components/data-display/chart/Sparkline.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
  53. package/dist/components/data-display/chart/Sparkline.vue_vue_type_script_setup_true_lang.mjs +292 -0
  54. package/dist/components/data-display/chart/Sparkline.vue_vue_type_script_setup_true_lang.mjs.map +1 -0
  55. package/dist/components/data-display/chart/useChart.cjs +189 -0
  56. package/dist/components/data-display/chart/useChart.cjs.map +1 -0
  57. package/dist/components/data-display/chart/useChart.mjs +182 -0
  58. package/dist/components/data-display/chart/useChart.mjs.map +1 -0
  59. package/dist/components/data-display/date-picker/DateRangePicker.cjs.map +1 -1
  60. package/dist/components/data-display/date-picker/DateRangePicker.mjs.map +1 -1
  61. package/dist/components/data-display/date-picker/DateRangePicker.vue_vue_type_script_setup_true_lang.cjs +1 -7
  62. package/dist/components/data-display/date-picker/DateRangePicker.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  63. package/dist/components/data-display/date-picker/DateRangePicker.vue_vue_type_script_setup_true_lang.mjs +1 -7
  64. package/dist/components/data-display/date-picker/DateRangePicker.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  65. package/dist/components/data-display/table/Table.vue_vue_type_script_setup_true_lang.cjs +1 -1
  66. package/dist/components/data-display/table/Table.vue_vue_type_script_setup_true_lang.mjs +1 -1
  67. package/dist/components/feedback/Tooltip.cjs.map +1 -1
  68. package/dist/components/feedback/Tooltip.mjs.map +1 -1
  69. package/dist/components/feedback/Tooltip.vue_vue_type_script_setup_true_lang.cjs +20 -3
  70. package/dist/components/feedback/Tooltip.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  71. package/dist/components/feedback/Tooltip.vue_vue_type_script_setup_true_lang.mjs +20 -3
  72. package/dist/components/feedback/Tooltip.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  73. package/dist/components/forms/Button.cjs +1 -1
  74. package/dist/components/forms/Button.cjs.map +1 -1
  75. package/dist/components/forms/Button.mjs +1 -1
  76. package/dist/components/forms/Button.mjs.map +1 -1
  77. package/dist/components/forms/Button.vue_vue_type_script_setup_true_lang.cjs +76 -63
  78. package/dist/components/forms/Button.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  79. package/dist/components/forms/Button.vue_vue_type_script_setup_true_lang.mjs +77 -64
  80. package/dist/components/forms/Button.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  81. package/dist/components/forms/ButtonGroup.cjs +1 -1
  82. package/dist/components/forms/ButtonGroup.cjs.map +1 -1
  83. package/dist/components/forms/ButtonGroup.mjs +1 -1
  84. package/dist/components/forms/ButtonGroup.mjs.map +1 -1
  85. package/dist/components/forms/ButtonGroup.vue_vue_type_script_setup_true_lang.cjs +2 -2
  86. package/dist/components/forms/ButtonGroup.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  87. package/dist/components/forms/ButtonGroup.vue_vue_type_script_setup_true_lang.mjs +2 -2
  88. package/dist/components/forms/ButtonGroup.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  89. package/dist/components/forms/Checkbox.cjs +1 -1
  90. package/dist/components/forms/Checkbox.cjs.map +1 -1
  91. package/dist/components/forms/Checkbox.mjs +1 -1
  92. package/dist/components/forms/Checkbox.mjs.map +1 -1
  93. package/dist/components/forms/Checkbox.vue_vue_type_script_setup_true_lang.cjs +7 -7
  94. package/dist/components/forms/Checkbox.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  95. package/dist/components/forms/Checkbox.vue_vue_type_script_setup_true_lang.mjs +7 -7
  96. package/dist/components/forms/Checkbox.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  97. package/dist/components/forms/ColorPicker.vue_vue_type_script_setup_true_lang.cjs +1 -1
  98. package/dist/components/forms/ColorPicker.vue_vue_type_script_setup_true_lang.mjs +1 -1
  99. package/dist/components/forms/Combobox.vue_vue_type_script_setup_true_lang.cjs +2 -2
  100. package/dist/components/forms/Combobox.vue_vue_type_script_setup_true_lang.mjs +2 -2
  101. package/dist/components/forms/DateField.vue_vue_type_script_setup_true_lang.cjs +2 -2
  102. package/dist/components/forms/DateField.vue_vue_type_script_setup_true_lang.mjs +2 -2
  103. package/dist/components/forms/DateRangeField.vue_vue_type_script_setup_true_lang.cjs +2 -2
  104. package/dist/components/forms/DateRangeField.vue_vue_type_script_setup_true_lang.mjs +2 -2
  105. package/dist/components/forms/DateTimeField.vue_vue_type_script_setup_true_lang.cjs +2 -2
  106. package/dist/components/forms/DateTimeField.vue_vue_type_script_setup_true_lang.mjs +2 -2
  107. package/dist/components/forms/FileInput.vue_vue_type_script_setup_true_lang.cjs +1 -1
  108. package/dist/components/forms/FileInput.vue_vue_type_script_setup_true_lang.mjs +1 -1
  109. package/dist/components/forms/FormField.vue_vue_type_script_setup_true_lang.cjs +1 -1
  110. package/dist/components/forms/FormField.vue_vue_type_script_setup_true_lang.mjs +1 -1
  111. package/dist/components/forms/Input.vue_vue_type_script_setup_true_lang.cjs +1 -1
  112. package/dist/components/forms/Input.vue_vue_type_script_setup_true_lang.mjs +1 -1
  113. package/dist/components/forms/MenuButton.cjs +6 -0
  114. package/dist/components/forms/MenuButton.cjs.map +1 -0
  115. package/dist/components/forms/MenuButton.mjs +7 -0
  116. package/dist/components/forms/MenuButton.mjs.map +1 -0
  117. package/dist/components/forms/MenuButton.vue_vue_type_script_setup_true_lang.cjs +270 -0
  118. package/dist/components/forms/MenuButton.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
  119. package/dist/components/forms/MenuButton.vue_vue_type_script_setup_true_lang.mjs +269 -0
  120. package/dist/components/forms/MenuButton.vue_vue_type_script_setup_true_lang.mjs.map +1 -0
  121. package/dist/components/forms/MultiSelect.vue_vue_type_script_setup_true_lang.cjs +2 -2
  122. package/dist/components/forms/MultiSelect.vue_vue_type_script_setup_true_lang.mjs +2 -2
  123. package/dist/components/forms/NumberInput.vue_vue_type_script_setup_true_lang.cjs +1 -1
  124. package/dist/components/forms/NumberInput.vue_vue_type_script_setup_true_lang.mjs +1 -1
  125. package/dist/components/forms/OTPInput.vue_vue_type_script_setup_true_lang.cjs +1 -1
  126. package/dist/components/forms/OTPInput.vue_vue_type_script_setup_true_lang.mjs +1 -1
  127. package/dist/components/forms/PasswordInput.vue_vue_type_script_setup_true_lang.cjs +1 -1
  128. package/dist/components/forms/PasswordInput.vue_vue_type_script_setup_true_lang.mjs +1 -1
  129. package/dist/components/forms/PhoneInput.vue_vue_type_script_setup_true_lang.cjs +2 -2
  130. package/dist/components/forms/PhoneInput.vue_vue_type_script_setup_true_lang.mjs +2 -2
  131. package/dist/components/forms/Radio.cjs +1 -1
  132. package/dist/components/forms/Radio.cjs.map +1 -1
  133. package/dist/components/forms/Radio.mjs +1 -1
  134. package/dist/components/forms/Radio.mjs.map +1 -1
  135. package/dist/components/forms/Radio.vue_vue_type_script_setup_true_lang.cjs +6 -6
  136. package/dist/components/forms/Radio.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  137. package/dist/components/forms/Radio.vue_vue_type_script_setup_true_lang.mjs +6 -6
  138. package/dist/components/forms/Radio.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  139. package/dist/components/forms/RangeSlider.cjs.map +1 -1
  140. package/dist/components/forms/RangeSlider.mjs.map +1 -1
  141. package/dist/components/forms/RangeSlider.vue_vue_type_script_setup_true_lang.cjs +6 -6
  142. package/dist/components/forms/RangeSlider.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  143. package/dist/components/forms/RangeSlider.vue_vue_type_script_setup_true_lang.mjs +6 -6
  144. package/dist/components/forms/RangeSlider.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  145. package/dist/components/forms/SearchInput.cjs.map +1 -1
  146. package/dist/components/forms/SearchInput.mjs.map +1 -1
  147. package/dist/components/forms/SearchInput.vue_vue_type_script_setup_true_lang.cjs +225 -20
  148. package/dist/components/forms/SearchInput.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  149. package/dist/components/forms/SearchInput.vue_vue_type_script_setup_true_lang.mjs +227 -22
  150. package/dist/components/forms/SearchInput.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  151. package/dist/components/forms/Segmented.cjs +1 -1
  152. package/dist/components/forms/Segmented.cjs.map +1 -1
  153. package/dist/components/forms/Segmented.mjs +1 -1
  154. package/dist/components/forms/Segmented.mjs.map +1 -1
  155. package/dist/components/forms/Segmented.vue_vue_type_script_setup_true_lang.cjs +4 -12
  156. package/dist/components/forms/Segmented.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  157. package/dist/components/forms/Segmented.vue_vue_type_script_setup_true_lang.mjs +4 -12
  158. package/dist/components/forms/Segmented.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  159. package/dist/components/forms/Select.vue_vue_type_script_setup_true_lang.cjs +2 -2
  160. package/dist/components/forms/Select.vue_vue_type_script_setup_true_lang.mjs +2 -2
  161. package/dist/components/forms/Slider.cjs.map +1 -1
  162. package/dist/components/forms/Slider.mjs.map +1 -1
  163. package/dist/components/forms/Slider.vue_vue_type_script_setup_true_lang.cjs +6 -6
  164. package/dist/components/forms/Slider.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  165. package/dist/components/forms/Slider.vue_vue_type_script_setup_true_lang.mjs +6 -6
  166. package/dist/components/forms/Slider.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  167. package/dist/components/forms/Switch.cjs +1 -1
  168. package/dist/components/forms/Switch.cjs.map +1 -1
  169. package/dist/components/forms/Switch.mjs +1 -1
  170. package/dist/components/forms/Switch.mjs.map +1 -1
  171. package/dist/components/forms/Switch.vue_vue_type_script_setup_true_lang.cjs +7 -7
  172. package/dist/components/forms/Switch.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  173. package/dist/components/forms/Switch.vue_vue_type_script_setup_true_lang.mjs +7 -7
  174. package/dist/components/forms/Switch.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  175. package/dist/components/forms/Textarea.vue_vue_type_script_setup_true_lang.cjs +1 -1
  176. package/dist/components/forms/Textarea.vue_vue_type_script_setup_true_lang.mjs +1 -1
  177. package/dist/components/layout/AppShell.cjs.map +1 -1
  178. package/dist/components/layout/AppShell.mjs.map +1 -1
  179. package/dist/components/layout/AppShell.vue_vue_type_script_setup_true_lang.cjs +8 -8
  180. package/dist/components/layout/AppShell.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  181. package/dist/components/layout/AppShell.vue_vue_type_script_setup_true_lang.mjs +8 -8
  182. package/dist/components/layout/AppShell.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  183. package/dist/components/layout/Sidebar.cjs.map +1 -1
  184. package/dist/components/layout/Sidebar.mjs.map +1 -1
  185. package/dist/components/layout/Sidebar.vue_vue_type_script_setup_true_lang.cjs +36 -21
  186. package/dist/components/layout/Sidebar.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  187. package/dist/components/layout/Sidebar.vue_vue_type_script_setup_true_lang.mjs +36 -21
  188. package/dist/components/layout/Sidebar.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  189. package/dist/components/layout/Topbar.cjs.map +1 -1
  190. package/dist/components/layout/Topbar.mjs.map +1 -1
  191. package/dist/components/layout/Topbar.vue_vue_type_script_setup_true_lang.cjs +2 -2
  192. package/dist/components/layout/Topbar.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  193. package/dist/components/layout/Topbar.vue_vue_type_script_setup_true_lang.mjs +2 -2
  194. package/dist/components/layout/Topbar.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  195. package/dist/components/navigation/Switcher.cjs.map +1 -1
  196. package/dist/components/navigation/Switcher.mjs.map +1 -1
  197. package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.cjs +4 -4
  198. package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  199. package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.mjs +4 -4
  200. package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  201. package/dist/components/navigation/Tabs.cjs +1 -1
  202. package/dist/components/navigation/Tabs.cjs.map +1 -1
  203. package/dist/components/navigation/Tabs.mjs +1 -1
  204. package/dist/components/navigation/Tabs.mjs.map +1 -1
  205. package/dist/components/navigation/Tabs.vue_vue_type_script_setup_true_lang.cjs +1 -9
  206. package/dist/components/navigation/Tabs.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  207. package/dist/components/navigation/Tabs.vue_vue_type_script_setup_true_lang.mjs +1 -9
  208. package/dist/components/navigation/Tabs.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  209. package/dist/composables/useField.cjs +21 -23
  210. package/dist/composables/useField.cjs.map +1 -1
  211. package/dist/composables/useField.mjs +21 -24
  212. package/dist/composables/useField.mjs.map +1 -1
  213. package/dist/composables/usePopover.cjs +5 -1
  214. package/dist/composables/usePopover.cjs.map +1 -1
  215. package/dist/composables/usePopover.mjs +5 -1
  216. package/dist/composables/usePopover.mjs.map +1 -1
  217. package/dist/index.cjs +5 -1
  218. package/dist/index.mjs +4 -2
  219. package/dist/mood-ui.css +107 -473
  220. package/dist/types/components/data-display/Chart.vue.d.ts +8 -0
  221. package/dist/types/components/data-display/Stat.vue.d.ts +12 -2
  222. package/dist/types/components/data-display/chart/Cartesian.vue.d.ts +17 -0
  223. package/dist/types/components/data-display/chart/Heatmap.vue.d.ts +10 -0
  224. package/dist/types/components/data-display/chart/Polar.vue.d.ts +9 -0
  225. package/dist/types/components/data-display/chart/Radar.vue.d.ts +10 -0
  226. package/dist/types/components/data-display/chart/Sparkline.vue.d.ts +13 -0
  227. package/dist/types/components/data-display/chart/useChart.d.ts +49 -0
  228. package/dist/types/components/feedback/Drawer.vue.d.ts +2 -2
  229. package/dist/types/components/feedback/Modal.vue.d.ts +2 -2
  230. package/dist/types/components/feedback/Tooltip.vue.d.ts +1 -1
  231. package/dist/types/components/forms/Button.vue.d.ts +3 -2
  232. package/dist/types/components/forms/Combobox.vue.d.ts +3 -3
  233. package/dist/types/components/forms/DateField.vue.d.ts +3 -3
  234. package/dist/types/components/forms/DateRangeField.vue.d.ts +3 -3
  235. package/dist/types/components/forms/DateTimeField.vue.d.ts +3 -3
  236. package/dist/types/components/forms/MenuButton.vue.d.ts +23 -0
  237. package/dist/types/components/forms/MultiSelect.vue.d.ts +3 -3
  238. package/dist/types/components/forms/SearchInput.vue.d.ts +33 -2
  239. package/dist/types/components/forms/Select.vue.d.ts +2 -2
  240. package/dist/types/components/layout/AppShell.vue.d.ts +1 -1
  241. package/dist/types/components/layout/PageHeader.vue.d.ts +1 -1
  242. package/dist/types/components/layout/Sidebar.vue.d.ts +4 -4
  243. package/dist/types/components/layout/Stack.vue.d.ts +1 -1
  244. package/dist/types/components/layout/Topbar.vue.d.ts +1 -1
  245. package/dist/types/components/navigation/Breadcrumbs.vue.d.ts +1 -1
  246. package/dist/types/components/navigation/Switcher.vue.d.ts +3 -3
  247. package/dist/types/composables/useField.d.ts +10 -0
  248. package/dist/types/composables/usePopover.d.ts +7 -0
  249. package/dist/types/index.d.ts +4 -0
  250. package/dist/types/interfaces/data-display/Chart.interface.d.ts +97 -0
  251. package/dist/types/interfaces/data-display/Stat.interface.d.ts +17 -6
  252. package/dist/types/interfaces/feedback/Tooltip.interface.d.ts +11 -0
  253. package/dist/types/interfaces/forms/MenuButton.interface.d.ts +38 -0
  254. package/dist/types/interfaces/forms/SearchInput.interface.d.ts +36 -0
  255. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useField.cjs","names":[],"sources":["../../src/composables/useField.ts"],"sourcesContent":["import { computed, inject, useId, toValue, type ComputedRef, type InjectionKey, type MaybeRefOrGetter, type Ref } from 'vue';\nimport { useResolvedHalo } from './useModoConfig';\nimport type { ModoHalo } from '../config/ModoConfig';\nimport { useResolvedColor, useResolvedRadius } from './useModoConfig';\n\n/**\n * Injection key provided by FormField so child form controls can:\n * 1. Use the FormField's id as their own (connecting `<label for=\"...\">` automatically).\n * 2. Suppress the \"no label\" a11y warning — the FormField already renders a visible label.\n */\nexport const FORM_FIELD_ID_KEY: InjectionKey<Ref<string>> = Symbol('FormFieldId');\n \n/** \n * Props del campo de formulario que necesita `useFieldState`. \n * Se definen aquí para que cualquier componente (Input, Textarea, Password…) \n * pueda extenderlas y pasar su reactive `props` directamente. \n */ \nexport interface FieldStateSource { \n modelValue?: unknown; \n id?: string; \n label?: string; \n ariaLabel?: string; \n color?: 'default' | 'primary' | 'danger' | 'success' | 'warning'; \n radius?: 'none' | 'small' | 'medium' | 'large' | 'full'; \n errorText?: string; \n helperText?: string; \n /** Cuando es true, fuerza estado inválido sin renderizar errorText. Útil al envolver con FormField. */ \n invalid?: boolean; \n /** IDs adicionales para concatenar en aria-describedby (ej. provistos por un wrapper). */ \n ariaDescribedBy?: string; \n maxLength?: number; \n showCounter?: boolean; \n disabled?: boolean; \n loading?: boolean; \n} \n \nexport interface UseFieldStateOptions { \n /** Nombre del componente para el warning DEV. */ \n componentName: string; \n /** Prefijo para el id autogenerado (ej. 'modo-input'). */ \n idPrefix: string; \n} \n \n/** \n * Estado compartido entre campos de formulario (Input, Textarea, Password…). \n * \n * Resuelve: \n * - `fieldId` (prop.id o autogenerado). \n * - Color/radius resueltos desde el provider. \n * - `stateColor` (danger si hay error, si no el color resuelto). \n * - `describedBy` con los IDs de helper/error/counter. \n * - Contador y flags derivadas. \n * - Warning DEV cuando falta label/ariaLabel. \n */ \nexport function useFieldState(\n props: FieldStateSource,\n options: UseFieldStateOptions,\n) {\n const autoId = useId();\n // If a parent FormField provides its id, use it — this connects the FormField's\n // `<label for=\"...\">` to this input automatically without needing v-slot binding.\n const formFieldId = inject(FORM_FIELD_ID_KEY, null);\n const fieldId = computed(() => props.id ?? formFieldId?.value ?? `${options.idPrefix}-${autoId}`);\n \n const color = useResolvedColor(() => props.color); \n const radius = useResolvedRadius(() => props.radius); \n \n const hasError = computed(() => !!props.errorText || !!props.invalid); \n const isDisabled = computed(() => !!props.disabled || !!props.loading); \n \n const stateColor = computed(() => \n hasError.value ? 'danger' : color.value, \n ) as ComputedRef<'default' | 'primary' | 'danger' | 'success' | 'warning'>; \n \n const hasValue = computed(() => { \n const v = props.modelValue; \n return v !== null && v !== undefined && String(v).length > 0; \n }); \n \n const currentLength = computed(() => String(props.modelValue ?? '').length); \n const showCounterEffective = computed( \n () => !!props.showCounter && !!props.maxLength, \n ); \n const counterOverflow = computed( \n () => !!props.maxLength && currentLength.value >= props.maxLength, \n ); \n \n const errorId = computed(() => `${fieldId.value}-error`); \n const helperId = computed(() => `${fieldId.value}-helper`); \n const counterId = computed(() => `${fieldId.value}-counter`); \n \n const describedBy = computed(() => { \n const ids: string[] = []; \n if (hasError.value && props.errorText) ids.push(errorId.value); \n else if (props.helperText) ids.push(helperId.value); \n if (showCounterEffective.value) ids.push(counterId.value); \n if (props.ariaDescribedBy) ids.push(props.ariaDescribedBy); \n return ids.length ? ids.join(' ') : undefined; \n }); \n \n // Warn only when there is genuinely no accessible label: no label/ariaLabel prop\n // AND no parent FormField providing one (detected via injection key).\n if (import.meta.env.DEV && !props.label && !props.ariaLabel && !props.id && !formFieldId) {\n console.warn(\n `[mood-ui ${options.componentName}] Se requiere \\`label\\` o \\`ariaLabel\\` para accesibilidad.`,\n );\n }\n \n return { \n fieldId, \n color, \n radius, \n stateColor, \n hasError, \n hasValue, \n isDisabled, \n currentLength, \n showCounterEffective, \n counterOverflow, \n errorId, \n helperId, \n counterId, \n describedBy, \n }; \n} \n \nexport type FieldVariant = 'outline' | 'filled' | 'ghost'; \n \nexport interface UseFieldClassesSource { \n variant: MaybeRefOrGetter<FieldVariant>; \n stateColor: MaybeRefOrGetter<'default' | 'primary' | 'danger' | 'success' | 'warning'>; \n hasError: MaybeRefOrGetter<boolean>; \n radius: MaybeRefOrGetter<'none' | 'small' | 'medium' | 'large' | 'full'>; \n /** radius utility para 'full' (Input usa 'full', Textarea usa '2xl'). */ \n fullRadiusClass?: string; \n /** \n * Cuando es true, fuerza los estilos de focus (halo + borde) aunque \n * el foco esté fuera del wrapper. Útil para Select/Combobox cuando \n * el popover teleportado roba el foco pero el campo sigue \"activo\". \n */ \n forceFocus?: MaybeRefOrGetter<boolean>; \n /** \n * Estilo del halo del campo. Si no se pasa, se usa el valor resuelto \n * vía ModoProvider/useResolvedHalo. \n * - `'tinted'`: tintado al color (default) \n * - `'neutral'`: siempre gris \n * - `'off'`: sin halo persistente (solo focus-visible ring a11y) \n */ \n halo?: MaybeRefOrGetter<ModoHalo | undefined>; \n} \n\nexport const FIELD_AFFORDANCE_ICON_BY_COLOR: Record<string, string> = {\n default: 'modo-affordance-icon',\n primary: 'modo-affordance-icon',\n danger: 'text-destructive/85',\n success: 'modo-affordance-icon',\n warning: 'modo-affordance-icon',\n};\n\nexport const FIELD_AFFORDANCE_ACTION_BY_COLOR: Record<string, string> = {\n default: 'modo-affordance-action',\n primary: 'modo-affordance-action',\n danger: 'text-destructive/80 hover:text-destructive',\n success: 'modo-affordance-action',\n warning: 'modo-affordance-action',\n};\n \nconst FOCUS_RING_BY_COLOR: Record<string, string> = { \n default: 'focus-within:ring-ring/10', \n primary: 'focus-within:ring-primary/12', \n danger: 'focus-within:ring-destructive/12', \n success: 'focus-within:ring-success/12', \n warning: 'focus-within:ring-warning/12', \n}; \n \nconst FORCED_RING_BY_COLOR: Record<string, string> = { \n default: 'ring-ring/10', \n primary: 'ring-primary/12', \n danger: 'ring-destructive/12', \n success: 'ring-success/12', \n warning: 'ring-warning/12', \n}; \n \nconst FOCUS_BORDER_BY_COLOR: Record<string, string> = { \n default: 'focus-within:border-foreground/50', \n primary: 'focus-within:border-primary/60', \n danger: 'focus-within:border-destructive/60', \n success: 'focus-within:border-success/60', \n warning: 'focus-within:border-warning/60', \n}; \n \nconst FORCED_BORDER_BY_COLOR: Record<string, string> = { \n default: 'border-foreground/50', \n primary: 'border-primary/60', \n danger: 'border-destructive/60', \n success: 'border-success/60', \n warning: 'border-warning/60', \n}; \n \n/** \n * Resuelve las clases de wrapper (variante + halo + error) y el radius \n * para cualquier campo de formulario que siga el patrón Input/Textarea. \n */ \nexport function useFieldClasses(source: UseFieldClassesSource) { \n const resolvedHalo = useResolvedHalo(() => { \n const local = source.halo ? toValue(source.halo) : undefined; \n return local; \n }); \n \n const wrapperVariantClasses = computed(() => { \n const variant = toValue(source.variant); \n const stateColor = toValue(source.stateColor); \n const hasError = toValue(source.hasError); \n const forceFocus = source.forceFocus ? toValue(source.forceFocus) : false; \n const halo = resolvedHalo.value; \n const errBorder = hasError ? 'border-destructive' : ''; \n // En modo `neutral` el focus también queda gris; en `tinted` toma color. \n const focusRing = halo === 'neutral' ? 'focus-within:ring-ring/12' : FOCUS_RING_BY_COLOR[stateColor]; \n const focusBorder = FOCUS_BORDER_BY_COLOR[stateColor]; \n const forcedRing = forceFocus \n ? (halo === 'neutral' ? 'ring-ring/12' : FORCED_RING_BY_COLOR[stateColor]) \n : ''; \n const forcedBorder = forceFocus ? FORCED_BORDER_BY_COLOR[stateColor] : ''; \n const forcedBg = forceFocus ? 'bg-background' : ''; \n \n // Halo persistente (ring idle) — se omite cuando halo === 'off'. \n // En 'off' aparece solo en focus-within, neutro (no tintado al color). \n const idleRing = halo === 'off' ? '' : 'ring-4 ring-border/25'; \n const offFocusRingUtil = 'focus-within:ring-4 focus-within:ring-ring/15'; \n const focusRingUtil = halo === 'off' ? offFocusRingUtil : `focus-within:ring-4 ${focusRing}`; \n const offForcedRing = 'ring-4 ring-ring/15'; \n const forcedRingUtil = halo === 'off' \n ? (forceFocus ? offForcedRing : '') \n : (forceFocus ? `ring-4 ${forcedRing}` : ''); \n \n switch (variant) { \n case 'filled': \n return [ \n 'bg-muted border border-transparent', \n idleRing, \n 'focus-within:bg-background', \n focusRingUtil, \n forceFocus ? `${forcedRingUtil} ${forcedBg}` : forcedBg, \n errBorder, \n ].join(' '); \n case 'ghost': \n return [ \n 'bg-transparent border-b border-border rounded-none', \n focusBorder, \n forcedBorder, \n hasError ? 'border-destructive' : '', \n ].join(' '); \n case 'outline': \n default: \n return [ \n 'bg-background border border-input', \n idleRing, \n focusRingUtil, \n forcedRingUtil, \n errBorder, \n ].join(' '); \n } \n }); \n \n const radiusClasses = computed(() => { \n const variant = toValue(source.variant); \n if (variant === 'ghost') return ''; \n const radius = toValue(source.radius); \n switch (radius) { \n case 'none': return 'rounded-none'; \n case 'small': return 'rounded-sm'; \n case 'large': return 'rounded-xl'; \n case 'full': return source.fullRadiusClass ?? 'rounded-full'; \n case 'medium': \n default: return 'rounded-md'; \n } \n }); \n \n return { wrapperVariantClasses, radiusClasses }; \n}\n"],"mappings":";;;;;;;;;AAUA,IAAa,oBAA+C,OAAO,cAAc;;;;;;;;;;;;AA4CjF,SAAgB,cACZ,OACA,SACF;CACE,MAAM,UAAA,GAAA,IAAA,QAAgB;CAGtB,MAAM,eAAA,GAAA,IAAA,QAAqB,mBAAmB,KAAK;CACnD,MAAM,WAAA,GAAA,IAAA,gBAAyB,MAAM,MAAM,aAAa,SAAS,GAAG,QAAQ,SAAS,GAAG,SAAS;CAEjG,MAAM,QAAQ,sBAAA,uBAAuB,MAAM,MAAM;CACjD,MAAM,SAAS,sBAAA,wBAAwB,MAAM,OAAO;CAEpD,MAAM,YAAA,GAAA,IAAA,gBAA0B,CAAC,CAAC,MAAM,aAAa,CAAC,CAAC,MAAM,QAAQ;CACrE,MAAM,cAAA,GAAA,IAAA,gBAA4B,CAAC,CAAC,MAAM,YAAY,CAAC,CAAC,MAAM,QAAQ;CAEtE,MAAM,cAAA,GAAA,IAAA,gBACF,SAAS,QAAQ,WAAW,MAAM,MACrC;CAED,MAAM,YAAA,GAAA,IAAA,gBAA0B;EAC5B,MAAM,IAAI,MAAM;EAChB,OAAO,MAAM,QAAQ,MAAM,KAAA,KAAa,OAAO,EAAE,CAAC,SAAS;GAC7D;CAEF,MAAM,iBAAA,GAAA,IAAA,gBAA+B,OAAO,MAAM,cAAc,GAAG,CAAC,OAAO;CAC3E,MAAM,wBAAA,GAAA,IAAA,gBACI,CAAC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,SADuB,OAAO,OACtB,EAAR;IACI,KAAK,QAAQ,OAAO;IACpB,KAAK,SAAS,OAAO;IACrB,KAAK,SAAS,OAAO;IACrB,KAAK,QAAQ,OAAO,OAAO,mBAAmB;IAE9C,SAAS,OAAO;;IAIQ;EAAe"}
1
+ {"version":3,"file":"useField.cjs","names":[],"sources":["../../src/composables/useField.ts"],"sourcesContent":["import { computed, inject, useId, toValue, type ComputedRef, type InjectionKey, type MaybeRefOrGetter, type Ref } from 'vue';\nimport { useResolvedHalo } from './useModoConfig';\nimport type { ModoHalo } from '../config/ModoConfig';\nimport { useResolvedColor, useResolvedRadius } from './useModoConfig';\n\n/**\n * Injection key provided by FormField so child form controls can:\n * 1. Use the FormField's id as their own (connecting `<label for=\"...\">` automatically).\n * 2. Suppress the \"no label\" a11y warning — the FormField already renders a visible label.\n */\nexport const FORM_FIELD_ID_KEY: InjectionKey<Ref<string>> = Symbol('FormFieldId');\n \n/** \n * Props del campo de formulario que necesita `useFieldState`. \n * Se definen aquí para que cualquier componente (Input, Textarea, Password…) \n * pueda extenderlas y pasar su reactive `props` directamente. \n */ \nexport interface FieldStateSource { \n modelValue?: unknown; \n id?: string; \n label?: string; \n ariaLabel?: string; \n color?: 'default' | 'primary' | 'danger' | 'success' | 'warning'; \n radius?: 'none' | 'small' | 'medium' | 'large' | 'full'; \n errorText?: string; \n helperText?: string; \n /** Cuando es true, fuerza estado inválido sin renderizar errorText. Útil al envolver con FormField. */ \n invalid?: boolean; \n /** IDs adicionales para concatenar en aria-describedby (ej. provistos por un wrapper). */ \n ariaDescribedBy?: string; \n maxLength?: number; \n showCounter?: boolean; \n disabled?: boolean; \n loading?: boolean; \n} \n \nexport interface UseFieldStateOptions { \n /** Nombre del componente para el warning DEV. */ \n componentName: string; \n /** Prefijo para el id autogenerado (ej. 'modo-input'). */ \n idPrefix: string; \n} \n \n/** \n * Estado compartido entre campos de formulario (Input, Textarea, Password…). \n * \n * Resuelve: \n * - `fieldId` (prop.id o autogenerado). \n * - Color/radius resueltos desde el provider. \n * - `stateColor` (danger si hay error, si no el color resuelto). \n * - `describedBy` con los IDs de helper/error/counter. \n * - Contador y flags derivadas. \n * - Warning DEV cuando falta label/ariaLabel. \n */ \nexport function useFieldState(\n props: FieldStateSource,\n options: UseFieldStateOptions,\n) {\n const autoId = useId();\n // If a parent FormField provides its id, use it — this connects the FormField's\n // `<label for=\"...\">` to this input automatically without needing v-slot binding.\n const formFieldId = inject(FORM_FIELD_ID_KEY, null);\n const fieldId = computed(() => props.id ?? formFieldId?.value ?? `${options.idPrefix}-${autoId}`);\n \n const color = useResolvedColor(() => props.color); \n const radius = useResolvedRadius(() => props.radius); \n \n const hasError = computed(() => !!props.errorText || !!props.invalid); \n const isDisabled = computed(() => !!props.disabled || !!props.loading); \n \n const stateColor = computed(() => \n hasError.value ? 'danger' : color.value, \n ) as ComputedRef<'default' | 'primary' | 'danger' | 'success' | 'warning'>; \n \n const hasValue = computed(() => { \n const v = props.modelValue; \n return v !== null && v !== undefined && String(v).length > 0; \n }); \n \n const currentLength = computed(() => String(props.modelValue ?? '').length); \n const showCounterEffective = computed( \n () => !!props.showCounter && !!props.maxLength, \n ); \n const counterOverflow = computed( \n () => !!props.maxLength && currentLength.value >= props.maxLength, \n ); \n \n const errorId = computed(() => `${fieldId.value}-error`); \n const helperId = computed(() => `${fieldId.value}-helper`); \n const counterId = computed(() => `${fieldId.value}-counter`); \n \n const describedBy = computed(() => { \n const ids: string[] = []; \n if (hasError.value && props.errorText) ids.push(errorId.value); \n else if (props.helperText) ids.push(helperId.value); \n if (showCounterEffective.value) ids.push(counterId.value); \n if (props.ariaDescribedBy) ids.push(props.ariaDescribedBy); \n return ids.length ? ids.join(' ') : undefined; \n }); \n \n // Warn only when there is genuinely no accessible label: no label/ariaLabel prop\n // AND no parent FormField providing one (detected via injection key).\n if (import.meta.env.DEV && !props.label && !props.ariaLabel && !props.id && !formFieldId) {\n console.warn(\n `[mood-ui ${options.componentName}] Se requiere \\`label\\` o \\`ariaLabel\\` para accesibilidad.`,\n );\n }\n \n return { \n fieldId, \n color, \n radius, \n stateColor, \n hasError, \n hasValue, \n isDisabled, \n currentLength, \n showCounterEffective, \n counterOverflow, \n errorId, \n helperId, \n counterId, \n describedBy, \n }; \n} \n \nexport type FieldVariant = 'outline' | 'filled' | 'ghost'; \n \nexport interface UseFieldClassesSource { \n variant: MaybeRefOrGetter<FieldVariant>; \n stateColor: MaybeRefOrGetter<'default' | 'primary' | 'danger' | 'success' | 'warning'>; \n hasError: MaybeRefOrGetter<boolean>; \n radius: MaybeRefOrGetter<'none' | 'small' | 'medium' | 'large' | 'full'>; \n /** radius utility para 'full' (Input usa 'full', Textarea usa '2xl'). */ \n fullRadiusClass?: string; \n /** \n * Cuando es true, fuerza los estilos de focus (halo + borde) aunque \n * el foco esté fuera del wrapper. Útil para Select/Combobox cuando \n * el popover teleportado roba el foco pero el campo sigue \"activo\". \n */ \n forceFocus?: MaybeRefOrGetter<boolean>; \n /** \n * Estilo del halo del campo. Si no se pasa, se usa el valor resuelto \n * vía ModoProvider/useResolvedHalo. \n * - `'tinted'`: tintado al color (default) \n * - `'neutral'`: siempre gris \n * - `'off'`: sin halo persistente (solo focus-visible ring a11y) \n */ \n halo?: MaybeRefOrGetter<ModoHalo | undefined>; \n} \n\nexport const FIELD_AFFORDANCE_ICON_BY_COLOR: Record<string, string> = {\n default: 'modo-affordance-icon',\n primary: 'modo-affordance-icon',\n danger: 'text-destructive/85',\n success: 'modo-affordance-icon',\n warning: 'modo-affordance-icon',\n};\n\nexport const FIELD_AFFORDANCE_ACTION_BY_COLOR: Record<string, string> = {\n default: 'modo-affordance-action',\n primary: 'modo-affordance-action',\n danger: 'text-destructive/80 hover:text-destructive',\n success: 'modo-affordance-action',\n warning: 'modo-affordance-action',\n};\n \nconst FOCUS_BORDER_BY_COLOR: Record<string, string> = { \n default: 'focus-within:border-foreground/50', \n primary: 'focus-within:border-primary/60', \n danger: 'focus-within:border-destructive/60', \n success: 'focus-within:border-success/60', \n warning: 'focus-within:border-warning/60', \n}; \n \nconst FORCED_BORDER_BY_COLOR: Record<string, string> = { \n default: 'border-foreground/50', \n primary: 'border-primary/60', \n danger: 'border-destructive/60', \n success: 'border-success/60', \n warning: 'border-warning/60', \n}; \n \n/**\n * THE single focus indicator for the whole system. Every interactive component\n * uses this exact ring so tabbing through a form/toolbar shows one consistent\n * focus — a soft ring, no offset gap. `FIELD_FOCUS_RING` is the `focus-within`\n * variant for field wrappers; `CONTROL_FOCUS_RING` is the `focus-visible`\n * variant for buttons and other single-element controls.\n */\nexport const MODO_FOCUS_RING = 'ring-2 ring-ring/60';\nexport const FIELD_FOCUS_RING = 'focus-within:ring-2 focus-within:ring-ring/60';\nexport const CONTROL_FOCUS_RING =\n 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60';\n\n/**\n * Resuelve las clases de wrapper (variante + halo + error) y el radius\n * para cualquier campo de formulario que siga el patrón Input/Textarea.\n */\nexport function useFieldClasses(source: UseFieldClassesSource) {\n const resolvedHalo = useResolvedHalo(() => { \n const local = source.halo ? toValue(source.halo) : undefined; \n return local; \n }); \n \n const wrapperVariantClasses = computed(() => {\n const variant = toValue(source.variant);\n const stateColor = toValue(source.stateColor);\n const hasError = toValue(source.hasError);\n const forceFocus = source.forceFocus ? toValue(source.forceFocus) : false;\n const halo = resolvedHalo.value;\n const errBorder = hasError ? 'border-destructive' : '';\n const focusBorder = FOCUS_BORDER_BY_COLOR[stateColor];\n const forcedBorder = forceFocus ? FORCED_BORDER_BY_COLOR[stateColor] : '';\n const forcedBg = forceFocus ? 'bg-background' : '';\n\n // The persistent halo (idle ring) is opt-in via `neutral`/`tinted`.\n // The FOCUS ring is the SAME everywhere (see MODO_FOCUS_RING) so a field\n // and a button show an identical indicator when you tab to them.\n const idleRing = halo === 'off' ? '' : 'ring-4 ring-border/25';\n const focusRingUtil = FIELD_FOCUS_RING;\n const forcedRingUtil = forceFocus ? MODO_FOCUS_RING : '';\n\n switch (variant) {\n case 'filled':\n return [\n 'bg-muted border border-transparent',\n idleRing,\n 'focus-within:bg-background',\n focusBorder,\n focusRingUtil,\n forceFocus ? `${forcedRingUtil} ${forcedBorder} ${forcedBg}` : forcedBg,\n errBorder,\n ].join(' ');\n case 'ghost':\n return [\n 'bg-transparent border-b border-border rounded-none',\n focusBorder,\n forcedBorder,\n hasError ? 'border-destructive' : '',\n ].join(' ');\n case 'outline':\n default:\n return [\n 'bg-background border border-input',\n idleRing,\n focusBorder,\n focusRingUtil,\n forcedRingUtil,\n forcedBorder,\n errBorder,\n ].join(' ');\n }\n });\n \n const radiusClasses = computed(() => { \n const variant = toValue(source.variant); \n if (variant === 'ghost') return ''; \n const radius = toValue(source.radius); \n switch (radius) { \n case 'none': return 'rounded-none'; \n case 'small': return 'rounded-sm'; \n case 'large': return 'rounded-xl'; \n // `rounded-full` compiles to an effectively-infinite radius which\n // Chrome clamps differently for box-shadows than for the border,\n // making any ring render boxy corners. A large *finite* radius is a\n // visually-identical pill that shadows follow correctly.\n case 'full': return source.fullRadiusClass ?? 'rounded-[999px]';\n case 'medium': \n default: return 'rounded-md'; \n } \n }); \n \n return { wrapperVariantClasses, radiusClasses }; \n}\n"],"mappings":";;;;;;;;;AAUA,IAAa,oBAA+C,OAAO,cAAc;;;;;;;;;;;;AA4CjF,SAAgB,cACZ,OACA,SACF;CACE,MAAM,UAAA,GAAA,IAAA,QAAgB;CAGtB,MAAM,eAAA,GAAA,IAAA,QAAqB,mBAAmB,KAAK;CACnD,MAAM,WAAA,GAAA,IAAA,gBAAyB,MAAM,MAAM,aAAa,SAAS,GAAG,QAAQ,SAAS,GAAG,SAAS;CAEjG,MAAM,QAAQ,sBAAA,uBAAuB,MAAM,MAAM;CACjD,MAAM,SAAS,sBAAA,wBAAwB,MAAM,OAAO;CAEpD,MAAM,YAAA,GAAA,IAAA,gBAA0B,CAAC,CAAC,MAAM,aAAa,CAAC,CAAC,MAAM,QAAQ;CACrE,MAAM,cAAA,GAAA,IAAA,gBAA4B,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;IAsBd;EAAuB,gBAAA,GAAA,IAAA,gBAlBK;GAEjC,KAAA,GAAA,IAAA,SADwB,OAAO,QAC3B,KAAY,SAAS,OAAO;GAEhC,SAAA,GAAA,IAAA,SADuB,OAAO,OACtB,EAAR;IACI,KAAK,QAAQ,OAAO;IACpB,KAAK,SAAS,OAAO;IACrB,KAAK,SAAS,OAAO;IAKrB,KAAK,QAAQ,OAAO,OAAO,mBAAmB;IAE9C,SAAS,OAAO;;IAIQ;EAAe"}
@@ -75,20 +75,6 @@ var FIELD_AFFORDANCE_ACTION_BY_COLOR = {
75
75
  success: "modo-affordance-action",
76
76
  warning: "modo-affordance-action"
77
77
  };
78
- var FOCUS_RING_BY_COLOR = {
79
- default: "focus-within:ring-ring/10",
80
- primary: "focus-within:ring-primary/12",
81
- danger: "focus-within:ring-destructive/12",
82
- success: "focus-within:ring-success/12",
83
- warning: "focus-within:ring-warning/12"
84
- };
85
- var FORCED_RING_BY_COLOR = {
86
- default: "ring-ring/10",
87
- primary: "ring-primary/12",
88
- danger: "ring-destructive/12",
89
- success: "ring-success/12",
90
- warning: "ring-warning/12"
91
- };
92
78
  var FOCUS_BORDER_BY_COLOR = {
93
79
  default: "focus-within:border-foreground/50",
94
80
  primary: "focus-within:border-primary/60",
@@ -103,9 +89,19 @@ var FORCED_BORDER_BY_COLOR = {
103
89
  success: "border-success/60",
104
90
  warning: "border-warning/60"
105
91
  };
106
- /**
107
- * Resuelve las clases de wrapper (variante + halo + error) y el radius
108
- * para cualquier campo de formulario que siga el patrón Input/Textarea.
92
+ /**
93
+ * THE single focus indicator for the whole system. Every interactive component
94
+ * uses this exact ring so tabbing through a form/toolbar shows one consistent
95
+ * focus — a soft ring, no offset gap. `FIELD_FOCUS_RING` is the `focus-within`
96
+ * variant for field wrappers; `CONTROL_FOCUS_RING` is the `focus-visible`
97
+ * variant for buttons and other single-element controls.
98
+ */
99
+ var MODO_FOCUS_RING = "ring-2 ring-ring/60";
100
+ var FIELD_FOCUS_RING = "focus-within:ring-2 focus-within:ring-ring/60";
101
+ var CONTROL_FOCUS_RING = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60";
102
+ /**
103
+ * Resuelve las clases de wrapper (variante + halo + error) y el radius
104
+ * para cualquier campo de formulario que siga el patrón Input/Textarea.
109
105
  */
110
106
  function useFieldClasses(source) {
111
107
  const resolvedHalo = useResolvedHalo(() => {
@@ -119,21 +115,20 @@ function useFieldClasses(source) {
119
115
  const forceFocus = source.forceFocus ? toValue(source.forceFocus) : false;
120
116
  const halo = resolvedHalo.value;
121
117
  const errBorder = hasError ? "border-destructive" : "";
122
- const focusRing = halo === "neutral" ? "focus-within:ring-ring/12" : FOCUS_RING_BY_COLOR[stateColor];
123
118
  const focusBorder = FOCUS_BORDER_BY_COLOR[stateColor];
124
- const forcedRing = forceFocus ? halo === "neutral" ? "ring-ring/12" : FORCED_RING_BY_COLOR[stateColor] : "";
125
119
  const forcedBorder = forceFocus ? FORCED_BORDER_BY_COLOR[stateColor] : "";
126
120
  const forcedBg = forceFocus ? "bg-background" : "";
127
121
  const idleRing = halo === "off" ? "" : "ring-4 ring-border/25";
128
- const focusRingUtil = halo === "off" ? "focus-within:ring-4 focus-within:ring-ring/15" : `focus-within:ring-4 ${focusRing}`;
129
- const forcedRingUtil = halo === "off" ? forceFocus ? "ring-4 ring-ring/15" : "" : forceFocus ? `ring-4 ${forcedRing}` : "";
122
+ const focusRingUtil = FIELD_FOCUS_RING;
123
+ const forcedRingUtil = forceFocus ? MODO_FOCUS_RING : "";
130
124
  switch (variant) {
131
125
  case "filled": return [
132
126
  "bg-muted border border-transparent",
133
127
  idleRing,
134
128
  "focus-within:bg-background",
129
+ focusBorder,
135
130
  focusRingUtil,
136
- forceFocus ? `${forcedRingUtil} ${forcedBg}` : forcedBg,
131
+ forceFocus ? `${forcedRingUtil} ${forcedBorder} ${forcedBg}` : forcedBg,
137
132
  errBorder
138
133
  ].join(" ");
139
134
  case "ghost": return [
@@ -145,8 +140,10 @@ function useFieldClasses(source) {
145
140
  default: return [
146
141
  "bg-background border border-input",
147
142
  idleRing,
143
+ focusBorder,
148
144
  focusRingUtil,
149
145
  forcedRingUtil,
146
+ forcedBorder,
150
147
  errBorder
151
148
  ].join(" ");
152
149
  }
@@ -157,13 +154,13 @@ function useFieldClasses(source) {
157
154
  case "none": return "rounded-none";
158
155
  case "small": return "rounded-sm";
159
156
  case "large": return "rounded-xl";
160
- case "full": return source.fullRadiusClass ?? "rounded-full";
157
+ case "full": return source.fullRadiusClass ?? "rounded-[999px]";
161
158
  default: return "rounded-md";
162
159
  }
163
160
  })
164
161
  };
165
162
  }
166
163
  //#endregion
167
- export { FIELD_AFFORDANCE_ACTION_BY_COLOR, FIELD_AFFORDANCE_ICON_BY_COLOR, FORM_FIELD_ID_KEY, useFieldClasses, useFieldState };
164
+ export { CONTROL_FOCUS_RING, FIELD_AFFORDANCE_ACTION_BY_COLOR, FIELD_AFFORDANCE_ICON_BY_COLOR, FORM_FIELD_ID_KEY, useFieldClasses, useFieldState };
168
165
 
169
166
  //# sourceMappingURL=useField.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useField.mjs","names":[],"sources":["../../src/composables/useField.ts"],"sourcesContent":["import { computed, inject, useId, toValue, type ComputedRef, type InjectionKey, type MaybeRefOrGetter, type Ref } from 'vue';\nimport { useResolvedHalo } from './useModoConfig';\nimport type { ModoHalo } from '../config/ModoConfig';\nimport { useResolvedColor, useResolvedRadius } from './useModoConfig';\n\n/**\n * Injection key provided by FormField so child form controls can:\n * 1. Use the FormField's id as their own (connecting `<label for=\"...\">` automatically).\n * 2. Suppress the \"no label\" a11y warning — the FormField already renders a visible label.\n */\nexport const FORM_FIELD_ID_KEY: InjectionKey<Ref<string>> = Symbol('FormFieldId');\n \n/** \n * Props del campo de formulario que necesita `useFieldState`. \n * Se definen aquí para que cualquier componente (Input, Textarea, Password…) \n * pueda extenderlas y pasar su reactive `props` directamente. \n */ \nexport interface FieldStateSource { \n modelValue?: unknown; \n id?: string; \n label?: string; \n ariaLabel?: string; \n color?: 'default' | 'primary' | 'danger' | 'success' | 'warning'; \n radius?: 'none' | 'small' | 'medium' | 'large' | 'full'; \n errorText?: string; \n helperText?: string; \n /** Cuando es true, fuerza estado inválido sin renderizar errorText. Útil al envolver con FormField. */ \n invalid?: boolean; \n /** IDs adicionales para concatenar en aria-describedby (ej. provistos por un wrapper). */ \n ariaDescribedBy?: string; \n maxLength?: number; \n showCounter?: boolean; \n disabled?: boolean; \n loading?: boolean; \n} \n \nexport interface UseFieldStateOptions { \n /** Nombre del componente para el warning DEV. */ \n componentName: string; \n /** Prefijo para el id autogenerado (ej. 'modo-input'). */ \n idPrefix: string; \n} \n \n/** \n * Estado compartido entre campos de formulario (Input, Textarea, Password…). \n * \n * Resuelve: \n * - `fieldId` (prop.id o autogenerado). \n * - Color/radius resueltos desde el provider. \n * - `stateColor` (danger si hay error, si no el color resuelto). \n * - `describedBy` con los IDs de helper/error/counter. \n * - Contador y flags derivadas. \n * - Warning DEV cuando falta label/ariaLabel. \n */ \nexport function useFieldState(\n props: FieldStateSource,\n options: UseFieldStateOptions,\n) {\n const autoId = useId();\n // If a parent FormField provides its id, use it — this connects the FormField's\n // `<label for=\"...\">` to this input automatically without needing v-slot binding.\n const formFieldId = inject(FORM_FIELD_ID_KEY, null);\n const fieldId = computed(() => props.id ?? formFieldId?.value ?? `${options.idPrefix}-${autoId}`);\n \n const color = useResolvedColor(() => props.color); \n const radius = useResolvedRadius(() => props.radius); \n \n const hasError = computed(() => !!props.errorText || !!props.invalid); \n const isDisabled = computed(() => !!props.disabled || !!props.loading); \n \n const stateColor = computed(() => \n hasError.value ? 'danger' : color.value, \n ) as ComputedRef<'default' | 'primary' | 'danger' | 'success' | 'warning'>; \n \n const hasValue = computed(() => { \n const v = props.modelValue; \n return v !== null && v !== undefined && String(v).length > 0; \n }); \n \n const currentLength = computed(() => String(props.modelValue ?? '').length); \n const showCounterEffective = computed( \n () => !!props.showCounter && !!props.maxLength, \n ); \n const counterOverflow = computed( \n () => !!props.maxLength && currentLength.value >= props.maxLength, \n ); \n \n const errorId = computed(() => `${fieldId.value}-error`); \n const helperId = computed(() => `${fieldId.value}-helper`); \n const counterId = computed(() => `${fieldId.value}-counter`); \n \n const describedBy = computed(() => { \n const ids: string[] = []; \n if (hasError.value && props.errorText) ids.push(errorId.value); \n else if (props.helperText) ids.push(helperId.value); \n if (showCounterEffective.value) ids.push(counterId.value); \n if (props.ariaDescribedBy) ids.push(props.ariaDescribedBy); \n return ids.length ? ids.join(' ') : undefined; \n }); \n \n // Warn only when there is genuinely no accessible label: no label/ariaLabel prop\n // AND no parent FormField providing one (detected via injection key).\n if (import.meta.env.DEV && !props.label && !props.ariaLabel && !props.id && !formFieldId) {\n console.warn(\n `[mood-ui ${options.componentName}] Se requiere \\`label\\` o \\`ariaLabel\\` para accesibilidad.`,\n );\n }\n \n return { \n fieldId, \n color, \n radius, \n stateColor, \n hasError, \n hasValue, \n isDisabled, \n currentLength, \n showCounterEffective, \n counterOverflow, \n errorId, \n helperId, \n counterId, \n describedBy, \n }; \n} \n \nexport type FieldVariant = 'outline' | 'filled' | 'ghost'; \n \nexport interface UseFieldClassesSource { \n variant: MaybeRefOrGetter<FieldVariant>; \n stateColor: MaybeRefOrGetter<'default' | 'primary' | 'danger' | 'success' | 'warning'>; \n hasError: MaybeRefOrGetter<boolean>; \n radius: MaybeRefOrGetter<'none' | 'small' | 'medium' | 'large' | 'full'>; \n /** radius utility para 'full' (Input usa 'full', Textarea usa '2xl'). */ \n fullRadiusClass?: string; \n /** \n * Cuando es true, fuerza los estilos de focus (halo + borde) aunque \n * el foco esté fuera del wrapper. Útil para Select/Combobox cuando \n * el popover teleportado roba el foco pero el campo sigue \"activo\". \n */ \n forceFocus?: MaybeRefOrGetter<boolean>; \n /** \n * Estilo del halo del campo. Si no se pasa, se usa el valor resuelto \n * vía ModoProvider/useResolvedHalo. \n * - `'tinted'`: tintado al color (default) \n * - `'neutral'`: siempre gris \n * - `'off'`: sin halo persistente (solo focus-visible ring a11y) \n */ \n halo?: MaybeRefOrGetter<ModoHalo | undefined>; \n} \n\nexport const FIELD_AFFORDANCE_ICON_BY_COLOR: Record<string, string> = {\n default: 'modo-affordance-icon',\n primary: 'modo-affordance-icon',\n danger: 'text-destructive/85',\n success: 'modo-affordance-icon',\n warning: 'modo-affordance-icon',\n};\n\nexport const FIELD_AFFORDANCE_ACTION_BY_COLOR: Record<string, string> = {\n default: 'modo-affordance-action',\n primary: 'modo-affordance-action',\n danger: 'text-destructive/80 hover:text-destructive',\n success: 'modo-affordance-action',\n warning: 'modo-affordance-action',\n};\n \nconst FOCUS_RING_BY_COLOR: Record<string, string> = { \n default: 'focus-within:ring-ring/10', \n primary: 'focus-within:ring-primary/12', \n danger: 'focus-within:ring-destructive/12', \n success: 'focus-within:ring-success/12', \n warning: 'focus-within:ring-warning/12', \n}; \n \nconst FORCED_RING_BY_COLOR: Record<string, string> = { \n default: 'ring-ring/10', \n primary: 'ring-primary/12', \n danger: 'ring-destructive/12', \n success: 'ring-success/12', \n warning: 'ring-warning/12', \n}; \n \nconst FOCUS_BORDER_BY_COLOR: Record<string, string> = { \n default: 'focus-within:border-foreground/50', \n primary: 'focus-within:border-primary/60', \n danger: 'focus-within:border-destructive/60', \n success: 'focus-within:border-success/60', \n warning: 'focus-within:border-warning/60', \n}; \n \nconst FORCED_BORDER_BY_COLOR: Record<string, string> = { \n default: 'border-foreground/50', \n primary: 'border-primary/60', \n danger: 'border-destructive/60', \n success: 'border-success/60', \n warning: 'border-warning/60', \n}; \n \n/** \n * Resuelve las clases de wrapper (variante + halo + error) y el radius \n * para cualquier campo de formulario que siga el patrón Input/Textarea. \n */ \nexport function useFieldClasses(source: UseFieldClassesSource) { \n const resolvedHalo = useResolvedHalo(() => { \n const local = source.halo ? toValue(source.halo) : undefined; \n return local; \n }); \n \n const wrapperVariantClasses = computed(() => { \n const variant = toValue(source.variant); \n const stateColor = toValue(source.stateColor); \n const hasError = toValue(source.hasError); \n const forceFocus = source.forceFocus ? toValue(source.forceFocus) : false; \n const halo = resolvedHalo.value; \n const errBorder = hasError ? 'border-destructive' : ''; \n // En modo `neutral` el focus también queda gris; en `tinted` toma color. \n const focusRing = halo === 'neutral' ? 'focus-within:ring-ring/12' : FOCUS_RING_BY_COLOR[stateColor]; \n const focusBorder = FOCUS_BORDER_BY_COLOR[stateColor]; \n const forcedRing = forceFocus \n ? (halo === 'neutral' ? 'ring-ring/12' : FORCED_RING_BY_COLOR[stateColor]) \n : ''; \n const forcedBorder = forceFocus ? FORCED_BORDER_BY_COLOR[stateColor] : ''; \n const forcedBg = forceFocus ? 'bg-background' : ''; \n \n // Halo persistente (ring idle) — se omite cuando halo === 'off'. \n // En 'off' aparece solo en focus-within, neutro (no tintado al color). \n const idleRing = halo === 'off' ? '' : 'ring-4 ring-border/25'; \n const offFocusRingUtil = 'focus-within:ring-4 focus-within:ring-ring/15'; \n const focusRingUtil = halo === 'off' ? offFocusRingUtil : `focus-within:ring-4 ${focusRing}`; \n const offForcedRing = 'ring-4 ring-ring/15'; \n const forcedRingUtil = halo === 'off' \n ? (forceFocus ? offForcedRing : '') \n : (forceFocus ? `ring-4 ${forcedRing}` : ''); \n \n switch (variant) { \n case 'filled': \n return [ \n 'bg-muted border border-transparent', \n idleRing, \n 'focus-within:bg-background', \n focusRingUtil, \n forceFocus ? `${forcedRingUtil} ${forcedBg}` : forcedBg, \n errBorder, \n ].join(' '); \n case 'ghost': \n return [ \n 'bg-transparent border-b border-border rounded-none', \n focusBorder, \n forcedBorder, \n hasError ? 'border-destructive' : '', \n ].join(' '); \n case 'outline': \n default: \n return [ \n 'bg-background border border-input', \n idleRing, \n focusRingUtil, \n forcedRingUtil, \n errBorder, \n ].join(' '); \n } \n }); \n \n const radiusClasses = computed(() => { \n const variant = toValue(source.variant); \n if (variant === 'ghost') return ''; \n const radius = toValue(source.radius); \n switch (radius) { \n case 'none': return 'rounded-none'; \n case 'small': return 'rounded-sm'; \n case 'large': return 'rounded-xl'; \n case 'full': return source.fullRadiusClass ?? 'rounded-full'; \n case 'medium': \n default: return 'rounded-md'; \n } \n }); \n \n return { wrapperVariantClasses, radiusClasses }; \n}\n"],"mappings":";;;;;;;;AAUA,IAAa,oBAA+C,OAAO,cAAc;;;;;;;;;;;;AA4CjF,SAAgB,cACZ,OACA,SACF;CACE,MAAM,SAAS,OAAO;CAGtB,MAAM,cAAc,OAAO,mBAAmB,KAAK;CACnD,MAAM,UAAU,eAAe,MAAM,MAAM,aAAa,SAAS,GAAG,QAAQ,SAAS,GAAG,SAAS;CAEjG,MAAM,QAAQ,uBAAuB,MAAM,MAAM;CACjD,MAAM,SAAS,wBAAwB,MAAM,OAAO;CAEpD,MAAM,WAAW,eAAe,CAAC,CAAC,MAAM,aAAa,CAAC,CAAC,MAAM,QAAQ;CACrE,MAAM,aAAa,eAAe,CAAC,CAAC,MAAM,YAAY,CAAC,CAAC,MAAM,QAAQ;CAEtE,MAAM,aAAa,eACf,SAAS,QAAQ,WAAW,MAAM,MACrC;CAED,MAAM,WAAW,eAAe;EAC5B,MAAM,IAAI,MAAM;EAChB,OAAO,MAAM,QAAQ,MAAM,KAAA,KAAa,OAAO,EAAE,CAAC,SAAS;GAC7D;CAEF,MAAM,gBAAgB,eAAe,OAAO,MAAM,cAAc,GAAG,CAAC,OAAO;CAC3E,MAAM,uBAAuB,eACnB,CAAC,CAAC,MAAM,eAAe,CAAC,CAAC,MAAM,UACxC;CACD,MAAM,kBAAkB,eACd,CAAC,CAAC,MAAM,aAAa,cAAc,SAAS,MAAM,UAC3D;CAED,MAAM,UAAU,eAAe,GAAG,QAAQ,MAAM,QAAQ;CACxD,MAAM,WAAW,eAAe,GAAG,QAAQ,MAAM,SAAS;CAC1D,MAAM,YAAY,eAAe,GAAG,QAAQ,MAAM,UAAU;CAmB5D,OAAO;EACH;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aA/BgB,eAAe;GAC/B,MAAM,MAAgB,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sBAAsB;GAC1C,MAAM,aAAa,aACZ,SAAS,YAAY,iBAAiB,qBAAqB,cAC5D;GACN,MAAM,eAAe,aAAa,uBAAuB,cAAc;GACvE,MAAM,WAAW,aAAa,kBAAkB;GAIhD,MAAM,WAAW,SAAS,QAAQ,KAAK;GAEvC,MAAM,gBAAgB,SAAS,QAAQ,kDAAmB,uBAAuB;GAEjF,MAAM,iBAAiB,SAAS,QACzB,aAAa,wBAAgB,KAC7B,aAAa,UAAU,eAAe;GAE7C,QAAQ,SAAR;IACI,KAAK,UACD,OAAO;KACH;KACA;KACA;KACA;KACA,aAAa,GAAG,eAAe,GAAG,aAAa;KAC/C;KACH,CAAC,KAAK,IAAI;IACf,KAAK,SACD,OAAO;KACH;KACA;KACA;KACA,WAAW,uBAAuB;KACrC,CAAC,KAAK,IAAI;IAEf,SACI,OAAO;KACH;KACA;KACA;KACA;KACA;KACH,CAAC,KAAK,IAAI;;IAkBd;EAAuB,eAdV,eAAe;GAEjC,IADgB,QAAQ,OAAO,QAC3B,KAAY,SAAS,OAAO;GAEhC,QADe,QAAQ,OAAO,OACtB,EAAR;IACI,KAAK,QAAQ,OAAO;IACpB,KAAK,SAAS,OAAO;IACrB,KAAK,SAAS,OAAO;IACrB,KAAK,QAAQ,OAAO,OAAO,mBAAmB;IAE9C,SAAS,OAAO;;IAIQ;EAAe"}
1
+ {"version":3,"file":"useField.mjs","names":[],"sources":["../../src/composables/useField.ts"],"sourcesContent":["import { computed, inject, useId, toValue, type ComputedRef, type InjectionKey, type MaybeRefOrGetter, type Ref } from 'vue';\nimport { useResolvedHalo } from './useModoConfig';\nimport type { ModoHalo } from '../config/ModoConfig';\nimport { useResolvedColor, useResolvedRadius } from './useModoConfig';\n\n/**\n * Injection key provided by FormField so child form controls can:\n * 1. Use the FormField's id as their own (connecting `<label for=\"...\">` automatically).\n * 2. Suppress the \"no label\" a11y warning — the FormField already renders a visible label.\n */\nexport const FORM_FIELD_ID_KEY: InjectionKey<Ref<string>> = Symbol('FormFieldId');\n \n/** \n * Props del campo de formulario que necesita `useFieldState`. \n * Se definen aquí para que cualquier componente (Input, Textarea, Password…) \n * pueda extenderlas y pasar su reactive `props` directamente. \n */ \nexport interface FieldStateSource { \n modelValue?: unknown; \n id?: string; \n label?: string; \n ariaLabel?: string; \n color?: 'default' | 'primary' | 'danger' | 'success' | 'warning'; \n radius?: 'none' | 'small' | 'medium' | 'large' | 'full'; \n errorText?: string; \n helperText?: string; \n /** Cuando es true, fuerza estado inválido sin renderizar errorText. Útil al envolver con FormField. */ \n invalid?: boolean; \n /** IDs adicionales para concatenar en aria-describedby (ej. provistos por un wrapper). */ \n ariaDescribedBy?: string; \n maxLength?: number; \n showCounter?: boolean; \n disabled?: boolean; \n loading?: boolean; \n} \n \nexport interface UseFieldStateOptions { \n /** Nombre del componente para el warning DEV. */ \n componentName: string; \n /** Prefijo para el id autogenerado (ej. 'modo-input'). */ \n idPrefix: string; \n} \n \n/** \n * Estado compartido entre campos de formulario (Input, Textarea, Password…). \n * \n * Resuelve: \n * - `fieldId` (prop.id o autogenerado). \n * - Color/radius resueltos desde el provider. \n * - `stateColor` (danger si hay error, si no el color resuelto). \n * - `describedBy` con los IDs de helper/error/counter. \n * - Contador y flags derivadas. \n * - Warning DEV cuando falta label/ariaLabel. \n */ \nexport function useFieldState(\n props: FieldStateSource,\n options: UseFieldStateOptions,\n) {\n const autoId = useId();\n // If a parent FormField provides its id, use it — this connects the FormField's\n // `<label for=\"...\">` to this input automatically without needing v-slot binding.\n const formFieldId = inject(FORM_FIELD_ID_KEY, null);\n const fieldId = computed(() => props.id ?? formFieldId?.value ?? `${options.idPrefix}-${autoId}`);\n \n const color = useResolvedColor(() => props.color); \n const radius = useResolvedRadius(() => props.radius); \n \n const hasError = computed(() => !!props.errorText || !!props.invalid); \n const isDisabled = computed(() => !!props.disabled || !!props.loading); \n \n const stateColor = computed(() => \n hasError.value ? 'danger' : color.value, \n ) as ComputedRef<'default' | 'primary' | 'danger' | 'success' | 'warning'>; \n \n const hasValue = computed(() => { \n const v = props.modelValue; \n return v !== null && v !== undefined && String(v).length > 0; \n }); \n \n const currentLength = computed(() => String(props.modelValue ?? '').length); \n const showCounterEffective = computed( \n () => !!props.showCounter && !!props.maxLength, \n ); \n const counterOverflow = computed( \n () => !!props.maxLength && currentLength.value >= props.maxLength, \n ); \n \n const errorId = computed(() => `${fieldId.value}-error`); \n const helperId = computed(() => `${fieldId.value}-helper`); \n const counterId = computed(() => `${fieldId.value}-counter`); \n \n const describedBy = computed(() => { \n const ids: string[] = []; \n if (hasError.value && props.errorText) ids.push(errorId.value); \n else if (props.helperText) ids.push(helperId.value); \n if (showCounterEffective.value) ids.push(counterId.value); \n if (props.ariaDescribedBy) ids.push(props.ariaDescribedBy); \n return ids.length ? ids.join(' ') : undefined; \n }); \n \n // Warn only when there is genuinely no accessible label: no label/ariaLabel prop\n // AND no parent FormField providing one (detected via injection key).\n if (import.meta.env.DEV && !props.label && !props.ariaLabel && !props.id && !formFieldId) {\n console.warn(\n `[mood-ui ${options.componentName}] Se requiere \\`label\\` o \\`ariaLabel\\` para accesibilidad.`,\n );\n }\n \n return { \n fieldId, \n color, \n radius, \n stateColor, \n hasError, \n hasValue, \n isDisabled, \n currentLength, \n showCounterEffective, \n counterOverflow, \n errorId, \n helperId, \n counterId, \n describedBy, \n }; \n} \n \nexport type FieldVariant = 'outline' | 'filled' | 'ghost'; \n \nexport interface UseFieldClassesSource { \n variant: MaybeRefOrGetter<FieldVariant>; \n stateColor: MaybeRefOrGetter<'default' | 'primary' | 'danger' | 'success' | 'warning'>; \n hasError: MaybeRefOrGetter<boolean>; \n radius: MaybeRefOrGetter<'none' | 'small' | 'medium' | 'large' | 'full'>; \n /** radius utility para 'full' (Input usa 'full', Textarea usa '2xl'). */ \n fullRadiusClass?: string; \n /** \n * Cuando es true, fuerza los estilos de focus (halo + borde) aunque \n * el foco esté fuera del wrapper. Útil para Select/Combobox cuando \n * el popover teleportado roba el foco pero el campo sigue \"activo\". \n */ \n forceFocus?: MaybeRefOrGetter<boolean>; \n /** \n * Estilo del halo del campo. Si no se pasa, se usa el valor resuelto \n * vía ModoProvider/useResolvedHalo. \n * - `'tinted'`: tintado al color (default) \n * - `'neutral'`: siempre gris \n * - `'off'`: sin halo persistente (solo focus-visible ring a11y) \n */ \n halo?: MaybeRefOrGetter<ModoHalo | undefined>; \n} \n\nexport const FIELD_AFFORDANCE_ICON_BY_COLOR: Record<string, string> = {\n default: 'modo-affordance-icon',\n primary: 'modo-affordance-icon',\n danger: 'text-destructive/85',\n success: 'modo-affordance-icon',\n warning: 'modo-affordance-icon',\n};\n\nexport const FIELD_AFFORDANCE_ACTION_BY_COLOR: Record<string, string> = {\n default: 'modo-affordance-action',\n primary: 'modo-affordance-action',\n danger: 'text-destructive/80 hover:text-destructive',\n success: 'modo-affordance-action',\n warning: 'modo-affordance-action',\n};\n \nconst FOCUS_BORDER_BY_COLOR: Record<string, string> = { \n default: 'focus-within:border-foreground/50', \n primary: 'focus-within:border-primary/60', \n danger: 'focus-within:border-destructive/60', \n success: 'focus-within:border-success/60', \n warning: 'focus-within:border-warning/60', \n}; \n \nconst FORCED_BORDER_BY_COLOR: Record<string, string> = { \n default: 'border-foreground/50', \n primary: 'border-primary/60', \n danger: 'border-destructive/60', \n success: 'border-success/60', \n warning: 'border-warning/60', \n}; \n \n/**\n * THE single focus indicator for the whole system. Every interactive component\n * uses this exact ring so tabbing through a form/toolbar shows one consistent\n * focus — a soft ring, no offset gap. `FIELD_FOCUS_RING` is the `focus-within`\n * variant for field wrappers; `CONTROL_FOCUS_RING` is the `focus-visible`\n * variant for buttons and other single-element controls.\n */\nexport const MODO_FOCUS_RING = 'ring-2 ring-ring/60';\nexport const FIELD_FOCUS_RING = 'focus-within:ring-2 focus-within:ring-ring/60';\nexport const CONTROL_FOCUS_RING =\n 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60';\n\n/**\n * Resuelve las clases de wrapper (variante + halo + error) y el radius\n * para cualquier campo de formulario que siga el patrón Input/Textarea.\n */\nexport function useFieldClasses(source: UseFieldClassesSource) {\n const resolvedHalo = useResolvedHalo(() => { \n const local = source.halo ? toValue(source.halo) : undefined; \n return local; \n }); \n \n const wrapperVariantClasses = computed(() => {\n const variant = toValue(source.variant);\n const stateColor = toValue(source.stateColor);\n const hasError = toValue(source.hasError);\n const forceFocus = source.forceFocus ? toValue(source.forceFocus) : false;\n const halo = resolvedHalo.value;\n const errBorder = hasError ? 'border-destructive' : '';\n const focusBorder = FOCUS_BORDER_BY_COLOR[stateColor];\n const forcedBorder = forceFocus ? FORCED_BORDER_BY_COLOR[stateColor] : '';\n const forcedBg = forceFocus ? 'bg-background' : '';\n\n // The persistent halo (idle ring) is opt-in via `neutral`/`tinted`.\n // The FOCUS ring is the SAME everywhere (see MODO_FOCUS_RING) so a field\n // and a button show an identical indicator when you tab to them.\n const idleRing = halo === 'off' ? '' : 'ring-4 ring-border/25';\n const focusRingUtil = FIELD_FOCUS_RING;\n const forcedRingUtil = forceFocus ? MODO_FOCUS_RING : '';\n\n switch (variant) {\n case 'filled':\n return [\n 'bg-muted border border-transparent',\n idleRing,\n 'focus-within:bg-background',\n focusBorder,\n focusRingUtil,\n forceFocus ? `${forcedRingUtil} ${forcedBorder} ${forcedBg}` : forcedBg,\n errBorder,\n ].join(' ');\n case 'ghost':\n return [\n 'bg-transparent border-b border-border rounded-none',\n focusBorder,\n forcedBorder,\n hasError ? 'border-destructive' : '',\n ].join(' ');\n case 'outline':\n default:\n return [\n 'bg-background border border-input',\n idleRing,\n focusBorder,\n focusRingUtil,\n forcedRingUtil,\n forcedBorder,\n errBorder,\n ].join(' ');\n }\n });\n \n const radiusClasses = computed(() => { \n const variant = toValue(source.variant); \n if (variant === 'ghost') return ''; \n const radius = toValue(source.radius); \n switch (radius) { \n case 'none': return 'rounded-none'; \n case 'small': return 'rounded-sm'; \n case 'large': return 'rounded-xl'; \n // `rounded-full` compiles to an effectively-infinite radius which\n // Chrome clamps differently for box-shadows than for the border,\n // making any ring render boxy corners. A large *finite* radius is a\n // visually-identical pill that shadows follow correctly.\n case 'full': return source.fullRadiusClass ?? 'rounded-[999px]';\n case 'medium': \n default: return 'rounded-md'; \n } \n }); \n \n return { wrapperVariantClasses, radiusClasses }; \n}\n"],"mappings":";;;;;;;;AAUA,IAAa,oBAA+C,OAAO,cAAc;;;;;;;;;;;;AA4CjF,SAAgB,cACZ,OACA,SACF;CACE,MAAM,SAAS,OAAO;CAGtB,MAAM,cAAc,OAAO,mBAAmB,KAAK;CACnD,MAAM,UAAU,eAAe,MAAM,MAAM,aAAa,SAAS,GAAG,QAAQ,SAAS,GAAG,SAAS;CAEjG,MAAM,QAAQ,uBAAuB,MAAM,MAAM;CACjD,MAAM,SAAS,wBAAwB,MAAM,OAAO;CAEpD,MAAM,WAAW,eAAe,CAAC,CAAC,MAAM,aAAa,CAAC,CAAC,MAAM,QAAQ;CACrE,MAAM,aAAa,eAAe,CAAC,CAAC,MAAM,YAAY,CAAC,CAAC,MAAM,QAAQ;CAEtE,MAAM,aAAa,eACf,SAAS,QAAQ,WAAW,MAAM,MACrC;CAED,MAAM,WAAW,eAAe;EAC5B,MAAM,IAAI,MAAM;EAChB,OAAO,MAAM,QAAQ,MAAM,KAAA,KAAa,OAAO,EAAE,CAAC,SAAS;GAC7D;CAEF,MAAM,gBAAgB,eAAe,OAAO,MAAM,cAAc,GAAG,CAAC,OAAO;CAC3E,MAAM,uBAAuB,eACnB,CAAC,CAAC,MAAM,eAAe,CAAC,CAAC,MAAM,UACxC;CACD,MAAM,kBAAkB,eACd,CAAC,CAAC,MAAM,aAAa,cAAc,SAAS,MAAM,UAC3D;CAED,MAAM,UAAU,eAAe,GAAG,QAAQ,MAAM,QAAQ;CACxD,MAAM,WAAW,eAAe,GAAG,QAAQ,MAAM,SAAS;CAC1D,MAAM,YAAY,eAAe,GAAG,QAAQ,MAAM,UAAU;CAmB5D,OAAO;EACH;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAC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M,WAAW,SAAS,QAAQ,KAAK;GACvC,MAAM,gBAAgB;GACtB,MAAM,iBAAiB,aAAa,kBAAkB;GAEtD,QAAQ,SAAR;IACI,KAAK,UACD,OAAO;KACH;KACA;KACA;KACA;KACA;KACA,aAAa,GAAG,eAAe,GAAG,aAAa,GAAG,aAAa;KAC/D;KACH,CAAC,KAAK,IAAI;IACf,KAAK,SACD,OAAO;KACH;KACA;KACA;KACA,WAAW,uBAAuB;KACrC,CAAC,KAAK,IAAI;IAEf,SACI,OAAO;KACH;KACA;KACA;KACA;KACA;KACA;KACA;KACH,CAAC,KAAK,IAAI;;IAsBd;EAAuB,eAlBV,eAAe;GAEjC,IADgB,QAAQ,OAAO,QAC3B,KAAY,SAAS,OAAO;GAEhC,QADe,QAAQ,OAAO,OACtB,EAAR;IACI,KAAK,QAAQ,OAAO;IACpB,KAAK,SAAS,OAAO;IACrB,KAAK,SAAS,OAAO;IAKrB,KAAK,QAAQ,OAAO,OAAO,mBAAmB;IAE9C,SAAS,OAAO;;IAIQ;EAAe"}
@@ -13,7 +13,7 @@ let vue = require("vue");
13
13
  * sólo devuelve refs y estado.
14
14
  */
15
15
  function usePopover(options = {}) {
16
- const { placement: placementOption = "bottom-start", offset = 6, flip = true, matchTriggerWidth: matchTriggerWidthOption = false, closeOnClickOutside = true, closeOnEscape = true, onOpen, onClose } = options;
16
+ const { placement: placementOption = "bottom-start", offset = 6, flip = true, matchTriggerWidth: matchTriggerWidthOption = false, closeOnClickOutside = true, closeOnEscape = true, closeOnScroll = true, onOpen, onClose } = options;
17
17
  const triggerRef = (0, vue.ref)(null);
18
18
  const panelRef = (0, vue.ref)(null);
19
19
  const isOpen = (0, vue.ref)(false);
@@ -122,6 +122,10 @@ function usePopover(options = {}) {
122
122
  const target = e.target;
123
123
  if (target && panelRef.value && panelRef.value.contains(target)) return;
124
124
  if (target instanceof Element && target.closest(".modo-popover")) return;
125
+ if (!closeOnScroll) {
126
+ measure();
127
+ return;
128
+ }
125
129
  close();
126
130
  }
127
131
  let resizeObserver = null;
@@ -1 +1 @@
1
- {"version":3,"file":"usePopover.cjs","names":[],"sources":["../../src/composables/usePopover.ts"],"sourcesContent":["import { ref, computed, onBeforeUnmount, watch, toValue, type Ref, type MaybeRefOrGetter } from 'vue'; \n \nexport type PopoverPlacement = \n | 'bottom-start' | 'bottom-end' | 'bottom-center' \n | 'top-start' | 'top-end' | 'top-center'; \n \nexport interface UsePopoverOptions { \n /** Placement inicial. @default 'bottom-start' */ \n placement?: MaybeRefOrGetter<PopoverPlacement>; \n /** Offset vertical entre trigger y panel (px). @default 6 */ \n offset?: number; \n /** Auto-flip cuando no cabe en el viewport. @default true */ \n flip?: boolean; \n /** Hacer que el panel tenga el mismo ancho del trigger. @default false */ \n matchTriggerWidth?: MaybeRefOrGetter<boolean>; \n /** Cerrar al hacer click fuera del trigger y del panel. @default true */ \n closeOnClickOutside?: boolean; \n /** Cerrar con Escape. @default true */ \n closeOnEscape?: boolean; \n /** Callback cuando se abre. */ \n onOpen?: () => void; \n /** Callback cuando se cierra. */ \n onClose?: () => void; \n} \n \nexport interface PopoverPosition {\n top: number;\n left: number;\n width?: number;\n maxHeight?: number;\n /** Placement final (puede diferir del solicitado si hubo flip). */\n placement: PopoverPlacement;\n} \n \n/** \n * Headless composable para lógica de popover/dropdown: \n * - estado abierto/cerrado \n * - click outside + Escape \n * - posición absoluta relativa al viewport (para usar con `position: fixed`) \n * - auto-flip vertical cuando no cabe \n * - reposicionado en scroll + resize + ResizeObserver del trigger \n * \n * El caller se encarga de renderizar el trigger y el panel; este composable \n * sólo devuelve refs y estado. \n */ \nexport function usePopover(options: UsePopoverOptions = {}) { \n const { \n placement: placementOption = 'bottom-start', \n offset = 6, \n flip = true, \n matchTriggerWidth: matchTriggerWidthOption = false, \n closeOnClickOutside = true, \n closeOnEscape = true, \n onOpen, \n onClose, \n } = options; \n \n const triggerRef = ref<HTMLElement | null>(null); \n const panelRef = ref<HTMLElement | null>(null); \n const isOpen = ref(false); \n \n const position = ref<PopoverPosition>({ \n top: 0, \n left: 0, \n placement: toValue(placementOption), \n }); \n \n const panelStyle = computed(() => {\n const style: Record<string, string> = {\n position: 'fixed',\n top: `${position.value.top}px`,\n left: `${position.value.left}px`,\n zIndex: '1300',\n };\n if (position.value.width !== undefined) {\n style.width = `${position.value.width}px`;\n }\n if (position.value.maxHeight !== undefined) {\n style.maxHeight = `${position.value.maxHeight}px`;\n }\n return style;\n }); \n \n function measure(): void { \n const trigger = triggerRef.value; \n const panel = panelRef.value; \n if (!trigger) return; \n \n const initialPlacement = toValue(placementOption); \n const matchTriggerWidth = toValue(matchTriggerWidthOption); \n \n const tRect = trigger.getBoundingClientRect(); \n const pRect = panel?.getBoundingClientRect(); \n const panelW = pRect?.width ?? tRect.width; \n const panelH = pRect?.height ?? 0; \n const vw = window.innerWidth; \n const vh = window.innerHeight; \n const margin = 8; \n \n let resolved: PopoverPlacement = initialPlacement; \n \n // Vertical flip check. \n if (flip) { \n const wantsTop = initialPlacement.startsWith('top'); \n const spaceBelow = vh - tRect.bottom - margin; \n const spaceAbove = tRect.top - margin; \n if (!wantsTop && spaceBelow < panelH && spaceAbove > spaceBelow) { \n resolved = initialPlacement.replace('bottom', 'top') as PopoverPlacement; \n } else if (wantsTop && spaceAbove < panelH && spaceBelow > spaceAbove) { \n resolved = initialPlacement.replace('top', 'bottom') as PopoverPlacement; \n } \n } \n \n const isBottom = resolved.startsWith('bottom'); \n const align = resolved.split('-')[1] as 'start' | 'end' | 'center'; \n \n let top = isBottom ? tRect.bottom + offset : tRect.top - panelH - offset; \n \n let left: number; \n if (align === 'start') left = tRect.left; \n else if (align === 'end') left = tRect.right - panelW; \n else left = tRect.left + tRect.width / 2 - panelW / 2; \n \n // Horizontal clamp (simple, sin variante de flip lateral). \n if (left + panelW > vw - margin) left = vw - panelW - margin; \n if (left < margin) left = margin; \n \n // Vertical clamp: if panel taller than available space, cap it so it stays in viewport.\n const availableH = isBottom\n ? vh - margin - (tRect.bottom + offset)\n : tRect.top - offset - margin;\n const clampedMaxH = panelH > availableH ? Math.max(availableH, 120) : undefined;\n\n if (top + panelH > vh - margin) top = Math.max(margin, vh - panelH - margin);\n if (top < margin) top = margin;\n\n position.value = {\n top,\n left,\n width: matchTriggerWidth ? tRect.width : undefined,\n maxHeight: clampedMaxH,\n placement: resolved,\n }; \n } \n \n /* ---------- API ---------- */ \n \n function open() { \n if (isOpen.value) return; \n isOpen.value = true; \n onOpen?.(); \n // Medir en el próximo frame, cuando el panel ya esté en el DOM. \n requestAnimationFrame(() => { \n measure(); \n // Segunda pasada para corregir si aparecieron scrollbars. \n requestAnimationFrame(measure); \n }); \n } \n \n function close() { \n if (!isOpen.value) return; \n isOpen.value = false; \n onClose?.(); \n } \n \n function toggle() { \n isOpen.value ? close() : open(); \n } \n \n /* ---------- Listeners ---------- */ \n \n function onDocumentPointerDown(e: PointerEvent) { \n if (!isOpen.value || !closeOnClickOutside) return; \n const target = e.target as Element | null; \n if (!target) return; \n if (triggerRef.value?.contains(target)) return; \n if (panelRef.value?.contains(target)) return; \n // Click landed inside a *different* popover (e.g. a Select's \n // dropdown teleported to <body> from a child of our panel). \n // Treat any click on a `.modo-popover` ancestor as \"inside\" so \n // nested popovers don't close their parent. The parent will be \n // closed normally when the user clicks truly outside. \n if (typeof (target as Element).closest === 'function' && (target as Element).closest('.modo-popover')) { \n return; \n } \n close(); \n } \n \n function onDocumentKeyDown(e: KeyboardEvent) { \n if (!isOpen.value) return; \n if (closeOnEscape && e.key === 'Escape') { \n e.preventDefault(); \n close(); \n triggerRef.value?.focus?.(); \n } \n } \n \n function onScrollOrResize() { \n if (isOpen.value) measure(); \n } \n \n /** \n * Scroll outside del panel → cerrar. Scroll dentro del panel (p. ej. lista \n * de opciones) → no hace nada. Scroll en window/body → cerrar. \n * Se usa el evento \"scroll\" con capture para recibir cualquier scroll. \n */ \n function onWindowScroll(e: Event) { \n if (!isOpen.value) return; \n const target = e.target as Node | null; \n if (target && panelRef.value && panelRef.value.contains(target)) { \n // Scroll interno del panel — ignorar. \n return; \n } \n // Scroll inside a nested popover (Select's option list teleported \n // to <body>) should not close us either. \n if (target instanceof Element && target.closest('.modo-popover')) { \n return; \n } \n close(); \n } \n \n let resizeObserver: ResizeObserver | null = null; \n \n watch(isOpen, (open) => { \n if (open) { \n document.addEventListener('pointerdown', onDocumentPointerDown, true); \n document.addEventListener('keydown', onDocumentKeyDown); \n // Scroll en cualquier contenedor (incluido window) cierra el popover \n // salvo si el scroll viene desde dentro del propio panel. \n window.addEventListener('scroll', onWindowScroll, true); \n window.addEventListener('resize', onScrollOrResize); \n if (triggerRef.value && typeof ResizeObserver !== 'undefined') { \n resizeObserver = new ResizeObserver(onScrollOrResize); \n resizeObserver.observe(triggerRef.value); \n if (panelRef.value) resizeObserver.observe(panelRef.value); \n } \n } else { \n document.removeEventListener('pointerdown', onDocumentPointerDown, true); \n document.removeEventListener('keydown', onDocumentKeyDown); \n window.removeEventListener('scroll', onWindowScroll, true); \n window.removeEventListener('resize', onScrollOrResize); \n resizeObserver?.disconnect(); \n resizeObserver = null; \n } \n }); \n \n // Si el panel se monta después de open, vincularlo al ResizeObserver. \n watch(panelRef, (el) => { \n if (isOpen.value && el && resizeObserver) resizeObserver.observe(el); \n }); \n \n // Re-measure when reactive placement / matchTriggerWidth options change \n // while the popover is open (allows playgrounds to switch placement live). \n watch( \n () => [toValue(placementOption), toValue(matchTriggerWidthOption)], \n () => { if (isOpen.value) measure(); }, \n ); \n \n onBeforeUnmount(() => { \n document.removeEventListener('pointerdown', onDocumentPointerDown, true); \n document.removeEventListener('keydown', onDocumentKeyDown); \n window.removeEventListener('scroll', onWindowScroll, true); \n window.removeEventListener('resize', onScrollOrResize); \n resizeObserver?.disconnect(); \n }); \n \n return { \n triggerRef: triggerRef as Ref<HTMLElement | null>, \n panelRef: panelRef as Ref<HTMLElement | null>, \n isOpen, \n position, \n panelStyle, \n open, \n close, \n toggle, \n measure, \n }; \n}\n"],"mappings":";;;;;;;;;;;;;;AA6CA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D,gBAAgB,YAAY;GAC5B,iBAAiB;;GAEvB;CAGF,CAAA,GAAA,IAAA,OAAM,WAAW,OAAO;EACpB,IAAI,OAAO,SAAS,MAAM,gBAAgB,eAAe,QAAQ,GAAG;GACtE;CAIF,CAAA,GAAA,IAAA,aACU,EAAA,GAAA,IAAA,SAAS,gBAAgB,GAAA,GAAA,IAAA,SAAU,wBAAwB,CAAC,QAC5D;EAAE,IAAI,OAAO,OAAO,SAAS;GACtC;CAED,CAAA,GAAA,IAAA,uBAAsB;EAClB,SAAS,oBAAoB,eAAe,uBAAuB,KAAK;EACxE,SAAS,oBAAoB,WAAW,kBAAkB;EAC1D,OAAO,oBAAoB,UAAU,gBAAgB,KAAK;EAC1D,OAAO,oBAAoB,UAAU,iBAAiB;EACtD,gBAAgB,YAAY;GAC9B;CAEF,OAAO;EACS;EACF;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACH"}
1
+ {"version":3,"file":"usePopover.cjs","names":[],"sources":["../../src/composables/usePopover.ts"],"sourcesContent":["import { ref, computed, onBeforeUnmount, watch, toValue, type Ref, type MaybeRefOrGetter } from 'vue'; \n \nexport type PopoverPlacement = \n | 'bottom-start' | 'bottom-end' | 'bottom-center' \n | 'top-start' | 'top-end' | 'top-center'; \n \nexport interface UsePopoverOptions { \n /** Placement inicial. @default 'bottom-start' */ \n placement?: MaybeRefOrGetter<PopoverPlacement>; \n /** Offset vertical entre trigger y panel (px). @default 6 */ \n offset?: number; \n /** Auto-flip cuando no cabe en el viewport. @default true */ \n flip?: boolean; \n /** Hacer que el panel tenga el mismo ancho del trigger. @default false */ \n matchTriggerWidth?: MaybeRefOrGetter<boolean>; \n /** Cerrar al hacer click fuera del trigger y del panel. @default true */\n closeOnClickOutside?: boolean;\n /** Cerrar con Escape. @default true */\n closeOnEscape?: boolean;\n /**\n * Cerrar cuando la página hace scroll (fuera del panel). @default true\n * Con `false` el popover se reposiciona en vez de cerrarse — útil para un\n * dropdown de búsqueda que no debe desaparecer si enfocar el input provoca\n * un pequeño auto-scroll.\n */\n closeOnScroll?: boolean;\n /** Callback cuando se abre. */ \n onOpen?: () => void; \n /** Callback cuando se cierra. */ \n onClose?: () => void; \n} \n \nexport interface PopoverPosition {\n top: number;\n left: number;\n width?: number;\n maxHeight?: number;\n /** Placement final (puede diferir del solicitado si hubo flip). */\n placement: PopoverPlacement;\n} \n \n/** \n * Headless composable para lógica de popover/dropdown: \n * - estado abierto/cerrado \n * - click outside + Escape \n * - posición absoluta relativa al viewport (para usar con `position: fixed`) \n * - auto-flip vertical cuando no cabe \n * - reposicionado en scroll + resize + ResizeObserver del trigger \n * \n * El caller se encarga de renderizar el trigger y el panel; este composable \n * sólo devuelve refs y estado. \n */ \nexport function usePopover(options: UsePopoverOptions = {}) { \n const { \n placement: placementOption = 'bottom-start', \n offset = 6, \n flip = true, \n matchTriggerWidth: matchTriggerWidthOption = false, \n closeOnClickOutside = true,\n closeOnEscape = true,\n closeOnScroll = true,\n onOpen,\n onClose,\n } = options;\n \n const triggerRef = ref<HTMLElement | null>(null); \n const panelRef = ref<HTMLElement | null>(null); \n const isOpen = ref(false); \n \n const position = ref<PopoverPosition>({ \n top: 0, \n left: 0, \n placement: toValue(placementOption), \n }); \n \n const panelStyle = computed(() => {\n const style: Record<string, string> = {\n position: 'fixed',\n top: `${position.value.top}px`,\n left: `${position.value.left}px`,\n zIndex: '1300',\n };\n if (position.value.width !== undefined) {\n style.width = `${position.value.width}px`;\n }\n if (position.value.maxHeight !== undefined) {\n style.maxHeight = `${position.value.maxHeight}px`;\n }\n return style;\n }); \n \n function measure(): void { \n const trigger = triggerRef.value; \n const panel = panelRef.value; \n if (!trigger) return; \n \n const initialPlacement = toValue(placementOption); \n const matchTriggerWidth = toValue(matchTriggerWidthOption); \n \n const tRect = trigger.getBoundingClientRect(); \n const pRect = panel?.getBoundingClientRect(); \n const panelW = pRect?.width ?? tRect.width; \n const panelH = pRect?.height ?? 0; \n const vw = window.innerWidth; \n const vh = window.innerHeight; \n const margin = 8; \n \n let resolved: PopoverPlacement = initialPlacement; \n \n // Vertical flip check. \n if (flip) { \n const wantsTop = initialPlacement.startsWith('top'); \n const spaceBelow = vh - tRect.bottom - margin; \n const spaceAbove = tRect.top - margin; \n if (!wantsTop && spaceBelow < panelH && spaceAbove > spaceBelow) { \n resolved = initialPlacement.replace('bottom', 'top') as PopoverPlacement; \n } else if (wantsTop && spaceAbove < panelH && spaceBelow > spaceAbove) { \n resolved = initialPlacement.replace('top', 'bottom') as PopoverPlacement; \n } \n } \n \n const isBottom = resolved.startsWith('bottom'); \n const align = resolved.split('-')[1] as 'start' | 'end' | 'center'; \n \n let top = isBottom ? tRect.bottom + offset : tRect.top - panelH - offset; \n \n let left: number; \n if (align === 'start') left = tRect.left; \n else if (align === 'end') left = tRect.right - panelW; \n else left = tRect.left + tRect.width / 2 - panelW / 2; \n \n // Horizontal clamp (simple, sin variante de flip lateral). \n if (left + panelW > vw - margin) left = vw - panelW - margin; \n if (left < margin) left = margin; \n \n // Vertical clamp: if panel taller than available space, cap it so it stays in viewport.\n const availableH = isBottom\n ? vh - margin - (tRect.bottom + offset)\n : tRect.top - offset - margin;\n const clampedMaxH = panelH > availableH ? Math.max(availableH, 120) : undefined;\n\n if (top + panelH > vh - margin) top = Math.max(margin, vh - panelH - margin);\n if (top < margin) top = margin;\n\n position.value = {\n top,\n left,\n width: matchTriggerWidth ? tRect.width : undefined,\n maxHeight: clampedMaxH,\n placement: resolved,\n }; \n } \n \n /* ---------- API ---------- */ \n \n function open() { \n if (isOpen.value) return; \n isOpen.value = true; \n onOpen?.(); \n // Medir en el próximo frame, cuando el panel ya esté en el DOM. \n requestAnimationFrame(() => { \n measure(); \n // Segunda pasada para corregir si aparecieron scrollbars. \n requestAnimationFrame(measure); \n }); \n } \n \n function close() { \n if (!isOpen.value) return; \n isOpen.value = false; \n onClose?.(); \n } \n \n function toggle() { \n isOpen.value ? close() : open(); \n } \n \n /* ---------- Listeners ---------- */ \n \n function onDocumentPointerDown(e: PointerEvent) { \n if (!isOpen.value || !closeOnClickOutside) return; \n const target = e.target as Element | null; \n if (!target) return; \n if (triggerRef.value?.contains(target)) return; \n if (panelRef.value?.contains(target)) return; \n // Click landed inside a *different* popover (e.g. a Select's \n // dropdown teleported to <body> from a child of our panel). \n // Treat any click on a `.modo-popover` ancestor as \"inside\" so \n // nested popovers don't close their parent. The parent will be \n // closed normally when the user clicks truly outside. \n if (typeof (target as Element).closest === 'function' && (target as Element).closest('.modo-popover')) { \n return; \n } \n close(); \n } \n \n function onDocumentKeyDown(e: KeyboardEvent) { \n if (!isOpen.value) return; \n if (closeOnEscape && e.key === 'Escape') { \n e.preventDefault(); \n close(); \n triggerRef.value?.focus?.(); \n } \n } \n \n function onScrollOrResize() { \n if (isOpen.value) measure(); \n } \n \n /** \n * Scroll outside del panel → cerrar. Scroll dentro del panel (p. ej. lista \n * de opciones) → no hace nada. Scroll en window/body → cerrar. \n * Se usa el evento \"scroll\" con capture para recibir cualquier scroll. \n */ \n function onWindowScroll(e: Event) {\n if (!isOpen.value) return;\n const target = e.target as Node | null;\n if (target && panelRef.value && panelRef.value.contains(target)) {\n // Scroll interno del panel — ignorar.\n return;\n }\n // Scroll inside a nested popover (Select's option list teleported\n // to <body>) should not close us either.\n if (target instanceof Element && target.closest('.modo-popover')) {\n return;\n }\n // Reposition instead of closing when the caller opted out of scroll-close.\n if (!closeOnScroll) { measure(); return; }\n close();\n }\n \n let resizeObserver: ResizeObserver | null = null; \n \n watch(isOpen, (open) => { \n if (open) { \n document.addEventListener('pointerdown', onDocumentPointerDown, true); \n document.addEventListener('keydown', onDocumentKeyDown); \n // Scroll en cualquier contenedor (incluido window) cierra el popover \n // salvo si el scroll viene desde dentro del propio panel. \n window.addEventListener('scroll', onWindowScroll, true); \n window.addEventListener('resize', onScrollOrResize); \n if (triggerRef.value && typeof ResizeObserver !== 'undefined') { \n resizeObserver = new ResizeObserver(onScrollOrResize); \n resizeObserver.observe(triggerRef.value); \n if (panelRef.value) resizeObserver.observe(panelRef.value); \n } \n } else { \n document.removeEventListener('pointerdown', onDocumentPointerDown, true); \n document.removeEventListener('keydown', onDocumentKeyDown); \n window.removeEventListener('scroll', onWindowScroll, true); \n window.removeEventListener('resize', onScrollOrResize); \n resizeObserver?.disconnect(); \n resizeObserver = null; \n } \n }); \n \n // Si el panel se monta después de open, vincularlo al ResizeObserver. \n watch(panelRef, (el) => { \n if (isOpen.value && el && resizeObserver) resizeObserver.observe(el); \n }); \n \n // Re-measure when reactive placement / matchTriggerWidth options change \n // while the popover is open (allows playgrounds to switch placement live). \n watch( \n () => [toValue(placementOption), toValue(matchTriggerWidthOption)], \n () => { if (isOpen.value) measure(); }, \n ); \n \n onBeforeUnmount(() => { \n document.removeEventListener('pointerdown', onDocumentPointerDown, true); \n document.removeEventListener('keydown', onDocumentKeyDown); \n window.removeEventListener('scroll', onWindowScroll, true); \n window.removeEventListener('resize', onScrollOrResize); \n resizeObserver?.disconnect(); \n }); \n \n return { \n triggerRef: triggerRef as Ref<HTMLElement | null>, \n panelRef: panelRef as Ref<HTMLElement | null>, \n isOpen, \n position, \n panelStyle, \n open, \n close, \n toggle, \n measure, \n }; \n}\n"],"mappings":";;;;;;;;;;;;;;AAoDA,SAAgB,WAAW,UAA6B,EAAE,EAAE;CACxD,MAAM,EACF,WAAW,kBAAkB,gBAC7B,SAAS,GACT,OAAO,MACP,mBAAmB,0BAA0B,OAC7C,sBAAsB,MACtB,gBAAgB,MAChB,gBAAgB,MAChB,QACA,YACA;CAEJ,MAAM,cAAA,GAAA,IAAA,KAAqC,KAAK;CAChD,MAAM,YAAA,GAAA,IAAA,KAAmC,KAAK;CAC9C,MAAM,UAAA,GAAA,IAAA,KAAa,MAAM;CAEzB,MAAM,YAAA,GAAA,IAAA,KAAgC;EAClC,KAAK;EACL,MAAM;EACN,YAAA,GAAA,IAAA,SAAmB,gBAAgB;EACtC,CAAC;CAEF,MAAM,cAAA,GAAA,IAAA,gBAA4B;EAC9B,MAAM,QAAgC;GAClC,UAA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BAAgB,KAAK;EAC1D,OAAO,oBAAoB,UAAU,iBAAiB;EACtD,gBAAgB,YAAY;GAC9B;CAEF,OAAO;EACS;EACF;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACH"}
@@ -12,7 +12,7 @@ import { computed, onBeforeUnmount, ref, toValue, watch } from "vue";
12
12
  * sólo devuelve refs y estado.
13
13
  */
14
14
  function usePopover(options = {}) {
15
- const { placement: placementOption = "bottom-start", offset = 6, flip = true, matchTriggerWidth: matchTriggerWidthOption = false, closeOnClickOutside = true, closeOnEscape = true, onOpen, onClose } = options;
15
+ const { placement: placementOption = "bottom-start", offset = 6, flip = true, matchTriggerWidth: matchTriggerWidthOption = false, closeOnClickOutside = true, closeOnEscape = true, closeOnScroll = true, onOpen, onClose } = options;
16
16
  const triggerRef = ref(null);
17
17
  const panelRef = ref(null);
18
18
  const isOpen = ref(false);
@@ -121,6 +121,10 @@ function usePopover(options = {}) {
121
121
  const target = e.target;
122
122
  if (target && panelRef.value && panelRef.value.contains(target)) return;
123
123
  if (target instanceof Element && target.closest(".modo-popover")) return;
124
+ if (!closeOnScroll) {
125
+ measure();
126
+ return;
127
+ }
124
128
  close();
125
129
  }
126
130
  let resizeObserver = null;
@@ -1 +1 @@
1
- {"version":3,"file":"usePopover.mjs","names":[],"sources":["../../src/composables/usePopover.ts"],"sourcesContent":["import { ref, computed, onBeforeUnmount, watch, toValue, type Ref, type MaybeRefOrGetter } from 'vue'; \n \nexport type PopoverPlacement = \n | 'bottom-start' | 'bottom-end' | 'bottom-center' \n | 'top-start' | 'top-end' | 'top-center'; \n \nexport interface UsePopoverOptions { \n /** Placement inicial. @default 'bottom-start' */ \n placement?: MaybeRefOrGetter<PopoverPlacement>; \n /** Offset vertical entre trigger y panel (px). @default 6 */ \n offset?: number; \n /** Auto-flip cuando no cabe en el viewport. @default true */ \n flip?: boolean; \n /** Hacer que el panel tenga el mismo ancho del trigger. @default false */ \n matchTriggerWidth?: MaybeRefOrGetter<boolean>; \n /** Cerrar al hacer click fuera del trigger y del panel. @default true */ \n closeOnClickOutside?: boolean; \n /** Cerrar con Escape. @default true */ \n closeOnEscape?: boolean; \n /** Callback cuando se abre. */ \n onOpen?: () => void; \n /** Callback cuando se cierra. */ \n onClose?: () => void; \n} \n \nexport interface PopoverPosition {\n top: number;\n left: number;\n width?: number;\n maxHeight?: number;\n /** Placement final (puede diferir del solicitado si hubo flip). */\n placement: PopoverPlacement;\n} \n \n/** \n * Headless composable para lógica de popover/dropdown: \n * - estado abierto/cerrado \n * - click outside + Escape \n * - posición absoluta relativa al viewport (para usar con `position: fixed`) \n * - auto-flip vertical cuando no cabe \n * - reposicionado en scroll + resize + ResizeObserver del trigger \n * \n * El caller se encarga de renderizar el trigger y el panel; este composable \n * sólo devuelve refs y estado. \n */ \nexport function usePopover(options: UsePopoverOptions = {}) { \n const { \n placement: placementOption = 'bottom-start', \n offset = 6, \n flip = true, \n matchTriggerWidth: matchTriggerWidthOption = false, \n closeOnClickOutside = true, \n closeOnEscape = true, \n onOpen, \n onClose, \n } = options; \n \n const triggerRef = ref<HTMLElement | null>(null); \n const panelRef = ref<HTMLElement | null>(null); \n const isOpen = ref(false); \n \n const position = ref<PopoverPosition>({ \n top: 0, \n left: 0, \n placement: toValue(placementOption), \n }); \n \n const panelStyle = computed(() => {\n const style: Record<string, string> = {\n position: 'fixed',\n top: `${position.value.top}px`,\n left: `${position.value.left}px`,\n zIndex: '1300',\n };\n if (position.value.width !== undefined) {\n style.width = `${position.value.width}px`;\n }\n if (position.value.maxHeight !== undefined) {\n style.maxHeight = `${position.value.maxHeight}px`;\n }\n return style;\n }); \n \n function measure(): void { \n const trigger = triggerRef.value; \n const panel = panelRef.value; \n if (!trigger) return; \n \n const initialPlacement = toValue(placementOption); \n const matchTriggerWidth = toValue(matchTriggerWidthOption); \n \n const tRect = trigger.getBoundingClientRect(); \n const pRect = panel?.getBoundingClientRect(); \n const panelW = pRect?.width ?? tRect.width; \n const panelH = pRect?.height ?? 0; \n const vw = window.innerWidth; \n const vh = window.innerHeight; \n const margin = 8; \n \n let resolved: PopoverPlacement = initialPlacement; \n \n // Vertical flip check. \n if (flip) { \n const wantsTop = initialPlacement.startsWith('top'); \n const spaceBelow = vh - tRect.bottom - margin; \n const spaceAbove = tRect.top - margin; \n if (!wantsTop && spaceBelow < panelH && spaceAbove > spaceBelow) { \n resolved = initialPlacement.replace('bottom', 'top') as PopoverPlacement; \n } else if (wantsTop && spaceAbove < panelH && spaceBelow > spaceAbove) { \n resolved = initialPlacement.replace('top', 'bottom') as PopoverPlacement; \n } \n } \n \n const isBottom = resolved.startsWith('bottom'); \n const align = resolved.split('-')[1] as 'start' | 'end' | 'center'; \n \n let top = isBottom ? tRect.bottom + offset : tRect.top - panelH - offset; \n \n let left: number; \n if (align === 'start') left = tRect.left; \n else if (align === 'end') left = tRect.right - panelW; \n else left = tRect.left + tRect.width / 2 - panelW / 2; \n \n // Horizontal clamp (simple, sin variante de flip lateral). \n if (left + panelW > vw - margin) left = vw - panelW - margin; \n if (left < margin) left = margin; \n \n // Vertical clamp: if panel taller than available space, cap it so it stays in viewport.\n const availableH = isBottom\n ? vh - margin - (tRect.bottom + offset)\n : tRect.top - offset - margin;\n const clampedMaxH = panelH > availableH ? Math.max(availableH, 120) : undefined;\n\n if (top + panelH > vh - margin) top = Math.max(margin, vh - panelH - margin);\n if (top < margin) top = margin;\n\n position.value = {\n top,\n left,\n width: matchTriggerWidth ? tRect.width : undefined,\n maxHeight: clampedMaxH,\n placement: resolved,\n }; \n } \n \n /* ---------- API ---------- */ \n \n function open() { \n if (isOpen.value) return; \n isOpen.value = true; \n onOpen?.(); \n // Medir en el próximo frame, cuando el panel ya esté en el DOM. \n requestAnimationFrame(() => { \n measure(); \n // Segunda pasada para corregir si aparecieron scrollbars. \n requestAnimationFrame(measure); \n }); \n } \n \n function close() { \n if (!isOpen.value) return; \n isOpen.value = false; \n onClose?.(); \n } \n \n function toggle() { \n isOpen.value ? close() : open(); \n } \n \n /* ---------- Listeners ---------- */ \n \n function onDocumentPointerDown(e: PointerEvent) { \n if (!isOpen.value || !closeOnClickOutside) return; \n const target = e.target as Element | null; \n if (!target) return; \n if (triggerRef.value?.contains(target)) return; \n if (panelRef.value?.contains(target)) return; \n // Click landed inside a *different* popover (e.g. a Select's \n // dropdown teleported to <body> from a child of our panel). \n // Treat any click on a `.modo-popover` ancestor as \"inside\" so \n // nested popovers don't close their parent. The parent will be \n // closed normally when the user clicks truly outside. \n if (typeof (target as Element).closest === 'function' && (target as Element).closest('.modo-popover')) { \n return; \n } \n close(); \n } \n \n function onDocumentKeyDown(e: KeyboardEvent) { \n if (!isOpen.value) return; \n if (closeOnEscape && e.key === 'Escape') { \n e.preventDefault(); \n close(); \n triggerRef.value?.focus?.(); \n } \n } \n \n function onScrollOrResize() { \n if (isOpen.value) measure(); \n } \n \n /** \n * Scroll outside del panel → cerrar. Scroll dentro del panel (p. ej. lista \n * de opciones) → no hace nada. Scroll en window/body → cerrar. \n * Se usa el evento \"scroll\" con capture para recibir cualquier scroll. \n */ \n function onWindowScroll(e: Event) { \n if (!isOpen.value) return; \n const target = e.target as Node | null; \n if (target && panelRef.value && panelRef.value.contains(target)) { \n // Scroll interno del panel — ignorar. \n return; \n } \n // Scroll inside a nested popover (Select's option list teleported \n // to <body>) should not close us either. \n if (target instanceof Element && target.closest('.modo-popover')) { \n return; \n } \n close(); \n } \n \n let resizeObserver: ResizeObserver | null = null; \n \n watch(isOpen, (open) => { \n if (open) { \n document.addEventListener('pointerdown', onDocumentPointerDown, true); \n document.addEventListener('keydown', onDocumentKeyDown); \n // Scroll en cualquier contenedor (incluido window) cierra el popover \n // salvo si el scroll viene desde dentro del propio panel. \n window.addEventListener('scroll', onWindowScroll, true); \n window.addEventListener('resize', onScrollOrResize); \n if (triggerRef.value && typeof ResizeObserver !== 'undefined') { \n resizeObserver = new ResizeObserver(onScrollOrResize); \n resizeObserver.observe(triggerRef.value); \n if (panelRef.value) resizeObserver.observe(panelRef.value); \n } \n } else { \n document.removeEventListener('pointerdown', onDocumentPointerDown, true); \n document.removeEventListener('keydown', onDocumentKeyDown); \n window.removeEventListener('scroll', onWindowScroll, true); \n window.removeEventListener('resize', onScrollOrResize); \n resizeObserver?.disconnect(); \n resizeObserver = null; \n } \n }); \n \n // Si el panel se monta después de open, vincularlo al ResizeObserver. \n watch(panelRef, (el) => { \n if (isOpen.value && el && resizeObserver) resizeObserver.observe(el); \n }); \n \n // Re-measure when reactive placement / matchTriggerWidth options change \n // while the popover is open (allows playgrounds to switch placement live). \n watch( \n () => [toValue(placementOption), toValue(matchTriggerWidthOption)], \n () => { if (isOpen.value) measure(); }, \n ); \n \n onBeforeUnmount(() => { \n document.removeEventListener('pointerdown', onDocumentPointerDown, true); \n document.removeEventListener('keydown', onDocumentKeyDown); \n window.removeEventListener('scroll', onWindowScroll, true); \n window.removeEventListener('resize', onScrollOrResize); \n resizeObserver?.disconnect(); \n }); \n \n return { \n triggerRef: triggerRef as Ref<HTMLElement | null>, \n panelRef: panelRef as Ref<HTMLElement | null>, \n isOpen, \n position, \n panelStyle, \n open, \n close, \n toggle, \n measure, \n }; \n}\n"],"mappings":";;;;;;;;;;;;;AA6CA,SAAgB,WAAW,UAA6B,EAAE,EAAE;CACxD,MAAM,EACF,WAAW,kBAAkB,gBAC7B,SAAS,GACT,OAAO,MACP,mBAAmB,0BAA0B,OAC7C,sBAAsB,MACtB,gBAAgB,MAChB,QACA,YACA;CAEJ,MAAM,aAAa,IAAwB,KAAK;CAChD,MAAM,WAAW,IAAwB,KAAK;CAC9C,MAAM,SAAS,IAAI,MAAM;CAEzB,MAAM,WAAW,IAAqB;EAClC,KAAK;EACL,MAAM;EACN,WAAW,QAAQ,gBAAgB;EACtC,CAAC;CAEF,MAAM,aAAa,eAAe;EAC9B,MAAM,QAAgC;GAClC,UAAU;GACV,KAAK,GAAG,SAAS,MAAM,IAAI;GAC3B,MAAM,GAAG,SAAS,MAAM,KAAK;GAC7B,QAAQ;GACX;EACD,IAAI,SAAS,MA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IJ,IAAI,kBAAkB,WAAW,OAAO,QAAQ,gBAAgB,EAC5D;EAEJ,OAAO;;CAGX,IAAI,iBAAwC;CAE5C,MAAM,SAAS,SAAS;EACpB,IAAI,MAAM;GACN,SAAS,iBAAiB,eAAe,uBAAuB,KAAK;GACrE,SAAS,iBAAiB,WAAW,kBAAkB;GAGvD,OAAO,iBAAiB,UAAU,gBAAgB,KAAK;GACvD,OAAO,iBAAiB,UAAU,iBAAiB;GACnD,IAAI,WAAW,SAAS,OAAO,mBAAmB,aAAa;IAC3D,iBAAiB,IAAI,eAAe,iBAAiB;IACrD,eAAe,QAAQ,WAAW,MAAM;IACxC,IAAI,SAAS,OAAO,eAAe,QAAQ,SAAS,MAAM;;SAE3D;GACH,SAAS,oBAAoB,eAAe,uBAAuB,KAAK;GACxE,SAAS,oBAAoB,WAAW,kBAAkB;GAC1D,OAAO,oBAAoB,UAAU,gBAAgB,KAAK;GAC1D,OAAO,oBAAoB,UAAU,iBAAiB;GACtD,gBAAgB,YAAY;GAC5B,iBAAiB;;GAEvB;CAGF,MAAM,WAAW,OAAO;EACpB,IAAI,OAAO,SAAS,MAAM,gBAAgB,eAAe,QAAQ,GAAG;GACtE;CAIF,YACU,CAAC,QAAQ,gBAAgB,EAAE,QAAQ,wBAAwB,CAAC,QAC5D;EAAE,IAAI,OAAO,OAAO,SAAS;GACtC;CAED,sBAAsB;EAClB,SAAS,oBAAoB,eAAe,uBAAuB,KAAK;EACxE,SAAS,oBAAoB,WAAW,kBAAkB;EAC1D,OAAO,oBAAoB,UAAU,gBAAgB,KAAK;EAC1D,OAAO,oBAAoB,UAAU,iBAAiB;EACtD,gBAAgB,YAAY;GAC9B;CAEF,OAAO;EACS;EACF;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACH"}
1
+ {"version":3,"file":"usePopover.mjs","names":[],"sources":["../../src/composables/usePopover.ts"],"sourcesContent":["import { ref, computed, onBeforeUnmount, watch, toValue, type Ref, type MaybeRefOrGetter } from 'vue'; \n \nexport type PopoverPlacement = \n | 'bottom-start' | 'bottom-end' | 'bottom-center' \n | 'top-start' | 'top-end' | 'top-center'; \n \nexport interface UsePopoverOptions { \n /** Placement inicial. @default 'bottom-start' */ \n placement?: MaybeRefOrGetter<PopoverPlacement>; \n /** Offset vertical entre trigger y panel (px). @default 6 */ \n offset?: number; \n /** Auto-flip cuando no cabe en el viewport. @default true */ \n flip?: boolean; \n /** Hacer que el panel tenga el mismo ancho del trigger. @default false */ \n matchTriggerWidth?: MaybeRefOrGetter<boolean>; \n /** Cerrar al hacer click fuera del trigger y del panel. @default true */\n closeOnClickOutside?: boolean;\n /** Cerrar con Escape. @default true */\n closeOnEscape?: boolean;\n /**\n * Cerrar cuando la página hace scroll (fuera del panel). @default true\n * Con `false` el popover se reposiciona en vez de cerrarse — útil para un\n * dropdown de búsqueda que no debe desaparecer si enfocar el input provoca\n * un pequeño auto-scroll.\n */\n closeOnScroll?: boolean;\n /** Callback cuando se abre. */ \n onOpen?: () => void; \n /** Callback cuando se cierra. */ \n onClose?: () => void; \n} \n \nexport interface PopoverPosition {\n top: number;\n left: number;\n width?: number;\n maxHeight?: number;\n /** Placement final (puede diferir del solicitado si hubo flip). */\n placement: PopoverPlacement;\n} \n \n/** \n * Headless composable para lógica de popover/dropdown: \n * - estado abierto/cerrado \n * - click outside + Escape \n * - posición absoluta relativa al viewport (para usar con `position: fixed`) \n * - auto-flip vertical cuando no cabe \n * - reposicionado en scroll + resize + ResizeObserver del trigger \n * \n * El caller se encarga de renderizar el trigger y el panel; este composable \n * sólo devuelve refs y estado. \n */ \nexport function usePopover(options: UsePopoverOptions = {}) { \n const { \n placement: placementOption = 'bottom-start', \n offset = 6, \n flip = true, \n matchTriggerWidth: matchTriggerWidthOption = false, \n closeOnClickOutside = true,\n closeOnEscape = true,\n closeOnScroll = true,\n onOpen,\n onClose,\n } = options;\n \n const triggerRef = ref<HTMLElement | null>(null); \n const panelRef = ref<HTMLElement | null>(null); \n const isOpen = ref(false); \n \n const position = ref<PopoverPosition>({ \n top: 0, \n left: 0, \n placement: toValue(placementOption), \n }); \n \n const panelStyle = computed(() => {\n const style: Record<string, string> = {\n position: 'fixed',\n top: `${position.value.top}px`,\n left: `${position.value.left}px`,\n zIndex: '1300',\n };\n if (position.value.width !== undefined) {\n style.width = `${position.value.width}px`;\n }\n if (position.value.maxHeight !== undefined) {\n style.maxHeight = `${position.value.maxHeight}px`;\n }\n return style;\n }); \n \n function measure(): void { \n const trigger = triggerRef.value; \n const panel = panelRef.value; \n if (!trigger) return; \n \n const initialPlacement = toValue(placementOption); \n const matchTriggerWidth = toValue(matchTriggerWidthOption); \n \n const tRect = trigger.getBoundingClientRect(); \n const pRect = panel?.getBoundingClientRect(); \n const panelW = pRect?.width ?? tRect.width; \n const panelH = pRect?.height ?? 0; \n const vw = window.innerWidth; \n const vh = window.innerHeight; \n const margin = 8; \n \n let resolved: PopoverPlacement = initialPlacement; \n \n // Vertical flip check. \n if (flip) { \n const wantsTop = initialPlacement.startsWith('top'); \n const spaceBelow = vh - tRect.bottom - margin; \n const spaceAbove = tRect.top - margin; \n if (!wantsTop && spaceBelow < panelH && spaceAbove > spaceBelow) { \n resolved = initialPlacement.replace('bottom', 'top') as PopoverPlacement; \n } else if (wantsTop && spaceAbove < panelH && spaceBelow > spaceAbove) { \n resolved = initialPlacement.replace('top', 'bottom') as PopoverPlacement; \n } \n } \n \n const isBottom = resolved.startsWith('bottom'); \n const align = resolved.split('-')[1] as 'start' | 'end' | 'center'; \n \n let top = isBottom ? tRect.bottom + offset : tRect.top - panelH - offset; \n \n let left: number; \n if (align === 'start') left = tRect.left; \n else if (align === 'end') left = tRect.right - panelW; \n else left = tRect.left + tRect.width / 2 - panelW / 2; \n \n // Horizontal clamp (simple, sin variante de flip lateral). \n if (left + panelW > vw - margin) left = vw - panelW - margin; \n if (left < margin) left = margin; \n \n // Vertical clamp: if panel taller than available space, cap it so it stays in viewport.\n const availableH = isBottom\n ? vh - margin - (tRect.bottom + offset)\n : tRect.top - offset - margin;\n const clampedMaxH = panelH > availableH ? Math.max(availableH, 120) : undefined;\n\n if (top + panelH > vh - margin) top = Math.max(margin, vh - panelH - margin);\n if (top < margin) top = margin;\n\n position.value = {\n top,\n left,\n width: matchTriggerWidth ? tRect.width : undefined,\n maxHeight: clampedMaxH,\n placement: resolved,\n }; \n } \n \n /* ---------- API ---------- */ \n \n function open() { \n if (isOpen.value) return; \n isOpen.value = true; \n onOpen?.(); \n // Medir en el próximo frame, cuando el panel ya esté en el DOM. \n requestAnimationFrame(() => { \n measure(); \n // Segunda pasada para corregir si aparecieron scrollbars. \n requestAnimationFrame(measure); \n }); \n } \n \n function close() { \n if (!isOpen.value) return; \n isOpen.value = false; \n onClose?.(); \n } \n \n function toggle() { \n isOpen.value ? close() : open(); \n } \n \n /* ---------- Listeners ---------- */ \n \n function onDocumentPointerDown(e: PointerEvent) { \n if (!isOpen.value || !closeOnClickOutside) return; \n const target = e.target as Element | null; \n if (!target) return; \n if (triggerRef.value?.contains(target)) return; \n if (panelRef.value?.contains(target)) return; \n // Click landed inside a *different* popover (e.g. a Select's \n // dropdown teleported to <body> from a child of our panel). \n // Treat any click on a `.modo-popover` ancestor as \"inside\" so \n // nested popovers don't close their parent. The parent will be \n // closed normally when the user clicks truly outside. \n if (typeof (target as Element).closest === 'function' && (target as Element).closest('.modo-popover')) { \n return; \n } \n close(); \n } \n \n function onDocumentKeyDown(e: KeyboardEvent) { \n if (!isOpen.value) return; \n if (closeOnEscape && e.key === 'Escape') { \n e.preventDefault(); \n close(); \n triggerRef.value?.focus?.(); \n } \n } \n \n function onScrollOrResize() { \n if (isOpen.value) measure(); \n } \n \n /** \n * Scroll outside del panel → cerrar. Scroll dentro del panel (p. ej. lista \n * de opciones) → no hace nada. Scroll en window/body → cerrar. \n * Se usa el evento \"scroll\" con capture para recibir cualquier scroll. \n */ \n function onWindowScroll(e: Event) {\n if (!isOpen.value) return;\n const target = e.target as Node | null;\n if (target && panelRef.value && panelRef.value.contains(target)) {\n // Scroll interno del panel — ignorar.\n return;\n }\n // Scroll inside a nested popover (Select's option list teleported\n // to <body>) should not close us either.\n if (target instanceof Element && target.closest('.modo-popover')) {\n return;\n }\n // Reposition instead of closing when the caller opted out of scroll-close.\n if (!closeOnScroll) { measure(); return; }\n close();\n }\n \n let resizeObserver: ResizeObserver | null = null; \n \n watch(isOpen, (open) => { \n if (open) { \n document.addEventListener('pointerdown', onDocumentPointerDown, true); \n document.addEventListener('keydown', onDocumentKeyDown); \n // Scroll en cualquier contenedor (incluido window) cierra el popover \n // salvo si el scroll viene desde dentro del propio panel. \n window.addEventListener('scroll', onWindowScroll, true); \n window.addEventListener('resize', onScrollOrResize); \n if (triggerRef.value && typeof ResizeObserver !== 'undefined') { \n resizeObserver = new ResizeObserver(onScrollOrResize); \n resizeObserver.observe(triggerRef.value); \n if (panelRef.value) resizeObserver.observe(panelRef.value); \n } \n } else { \n document.removeEventListener('pointerdown', onDocumentPointerDown, true); \n document.removeEventListener('keydown', onDocumentKeyDown); \n window.removeEventListener('scroll', onWindowScroll, true); \n window.removeEventListener('resize', onScrollOrResize); \n resizeObserver?.disconnect(); \n resizeObserver = null; \n } \n }); \n \n // Si el panel se monta después de open, vincularlo al ResizeObserver. \n watch(panelRef, (el) => { \n if (isOpen.value && el && resizeObserver) resizeObserver.observe(el); \n }); \n \n // Re-measure when reactive placement / matchTriggerWidth options change \n // while the popover is open (allows playgrounds to switch placement live). \n watch( \n () => [toValue(placementOption), toValue(matchTriggerWidthOption)], \n () => { if (isOpen.value) measure(); }, \n ); \n \n onBeforeUnmount(() => { \n document.removeEventListener('pointerdown', onDocumentPointerDown, true); \n document.removeEventListener('keydown', onDocumentKeyDown); \n window.removeEventListener('scroll', onWindowScroll, true); \n window.removeEventListener('resize', onScrollOrResize); \n resizeObserver?.disconnect(); \n }); \n \n return { \n triggerRef: triggerRef as Ref<HTMLElement | null>, \n panelRef: panelRef as Ref<HTMLElement | null>, \n isOpen, \n position, \n panelStyle, \n open, \n close, \n togg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gB,YAAY;GAC5B,iBAAiB;;GAEvB;CAGF,MAAM,WAAW,OAAO;EACpB,IAAI,OAAO,SAAS,MAAM,gBAAgB,eAAe,QAAQ,GAAG;GACtE;CAIF,YACU,CAAC,QAAQ,gBAAgB,EAAE,QAAQ,wBAAwB,CAAC,QAC5D;EAAE,IAAI,OAAO,OAAO,SAAS;GACtC;CAED,sBAAsB;EAClB,SAAS,oBAAoB,eAAe,uBAAuB,KAAK;EACxE,SAAS,oBAAoB,WAAW,kBAAkB;EAC1D,OAAO,oBAAoB,UAAU,gBAAgB,KAAK;EAC1D,OAAO,oBAAoB,UAAU,iBAAiB;EACtD,gBAAgB,YAAY;GAC9B;CAEF,OAAO;EACS;EACF;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACH"}
package/dist/index.cjs CHANGED
@@ -21,6 +21,8 @@ const require_Loader = require("./components/feedback/Loader.cjs");
21
21
  const require_Skeleton = require("./components/feedback/Skeleton.cjs");
22
22
  const require_Button = require("./components/forms/Button.cjs");
23
23
  const require_ButtonGroup = require("./components/forms/ButtonGroup.cjs");
24
+ const require_PopoverPanel = require("./components/layout/PopoverPanel.cjs");
25
+ const require_MenuButton = require("./components/forms/MenuButton.cjs");
24
26
  const require_Typography = require("./components/data-display/Typography.cjs");
25
27
  const require_FormField = require("./components/forms/FormField.cjs");
26
28
  const require_Input = require("./components/forms/Input.cjs");
@@ -28,7 +30,6 @@ const require_Textarea = require("./components/forms/Textarea.cjs");
28
30
  const require_PasswordInput = require("./components/forms/PasswordInput.cjs");
29
31
  const require_NumberInput = require("./components/forms/NumberInput.cjs");
30
32
  const require_SearchInput = require("./components/forms/SearchInput.cjs");
31
- const require_PopoverPanel = require("./components/layout/PopoverPanel.cjs");
32
33
  const require_Select = require("./components/forms/Select.cjs");
33
34
  const require_Badge = require("./components/feedback/Badge.cjs");
34
35
  const require_MultiSelect = require("./components/forms/MultiSelect.cjs");
@@ -91,6 +92,7 @@ const require_Kbd = require("./components/data-display/Kbd.cjs");
91
92
  const require_Code = require("./components/data-display/Code.cjs");
92
93
  const require_Accordion = require("./components/data-display/Accordion.cjs");
93
94
  const require_Stat = require("./components/data-display/Stat.cjs");
95
+ const require_Chart = require("./components/data-display/Chart.cjs");
94
96
  const require_Timeline = require("./components/data-display/Timeline.cjs");
95
97
  const require_CalendarEventTooltip = require("./components/data-display/calendar/CalendarEventTooltip.cjs");
96
98
  const require_CalendarHeader = require("./components/data-display/calendar/CalendarHeader.cjs");
@@ -119,6 +121,7 @@ exports.CalendarEventTooltip = require_CalendarEventTooltip.default;
119
121
  exports.CalendarHeader = require_CalendarHeader.default;
120
122
  exports.Canvas = require_Canvas.default;
121
123
  exports.Card = require_Card.default;
124
+ exports.Chart = require_Chart.default;
122
125
  exports.Checkbox = require_Checkbox.default;
123
126
  exports.Chip = require_Chip.default;
124
127
  exports.Code = require_Code.default;
@@ -145,6 +148,7 @@ exports.Kbd = require_Kbd.default;
145
148
  exports.Loader = require_Loader.default;
146
149
  exports.MODO_CONFIG = require_ModoConfig.MODO_CONFIG;
147
150
  exports.MODO_LOCALE = require_ModoLocale.MODO_LOCALE;
151
+ exports.MenuButton = require_MenuButton.default;
148
152
  exports.Modal = require_Modal.default;
149
153
  exports.ModoProvider = require_ModoProvider.default;
150
154
  exports.MonthView = require_MonthView.default;
package/dist/index.mjs CHANGED
@@ -20,6 +20,8 @@ import Loader_default from "./components/feedback/Loader.mjs";
20
20
  import Skeleton_default from "./components/feedback/Skeleton.mjs";
21
21
  import Button_default from "./components/forms/Button.mjs";
22
22
  import ButtonGroup_default from "./components/forms/ButtonGroup.mjs";
23
+ import PopoverPanel_default from "./components/layout/PopoverPanel.mjs";
24
+ import MenuButton_default from "./components/forms/MenuButton.mjs";
23
25
  import Typography_default from "./components/data-display/Typography.mjs";
24
26
  import FormField_default from "./components/forms/FormField.mjs";
25
27
  import Input_default from "./components/forms/Input.mjs";
@@ -27,7 +29,6 @@ import Textarea_default from "./components/forms/Textarea.mjs";
27
29
  import PasswordInput_default from "./components/forms/PasswordInput.mjs";
28
30
  import NumberInput_default from "./components/forms/NumberInput.mjs";
29
31
  import SearchInput_default from "./components/forms/SearchInput.mjs";
30
- import PopoverPanel_default from "./components/layout/PopoverPanel.mjs";
31
32
  import Select_default from "./components/forms/Select.mjs";
32
33
  import Badge_default from "./components/feedback/Badge.mjs";
33
34
  import MultiSelect_default from "./components/forms/MultiSelect.mjs";
@@ -90,6 +91,7 @@ import Kbd_default from "./components/data-display/Kbd.mjs";
90
91
  import Code_default from "./components/data-display/Code.mjs";
91
92
  import Accordion_default from "./components/data-display/Accordion.mjs";
92
93
  import Stat_default from "./components/data-display/Stat.mjs";
94
+ import Chart_default from "./components/data-display/Chart.mjs";
93
95
  import Timeline_default from "./components/data-display/Timeline.mjs";
94
96
  import CalendarEventTooltip_default from "./components/data-display/calendar/CalendarEventTooltip.mjs";
95
97
  import CalendarHeader_default from "./components/data-display/calendar/CalendarHeader.mjs";
@@ -101,4 +103,4 @@ import Scheduler_default from "./components/data-display/calendar/Scheduler.mjs"
101
103
  import TablePagination_default from "./components/data-display/table/TablePagination.mjs";
102
104
  import Table_default from "./components/data-display/table/Table.mjs";
103
105
  import TableColumn_default from "./components/data-display/table/TableColumn.mjs";
104
- export { Accordion_default as Accordion, AgendaView_default as AgendaView, AppShell_default as AppShell, Avatar_default as Avatar, AvatarCropper_default as AvatarCropper, AvatarGroup_default as AvatarGroup, AvatarUpload_default as AvatarUpload, Badge_default as Badge, Banner_default as Banner, Breadcrumbs_default as Breadcrumbs, Button_default as Button, ButtonGroup_default as ButtonGroup, Calendar_default as Calendar, CalendarEventTooltip_default as CalendarEventTooltip, CalendarHeader_default as CalendarHeader, Canvas_default as Canvas, Card_default as Card, Checkbox_default as Checkbox, Chip_default as Chip, Code_default as Code, ColorModeSwitch_default as ColorModeSwitch, ColorPicker_default as ColorPicker, Combobox_default as Combobox, ConfirmDialog_default as ConfirmDialog, Container_default as Container, DateField_default as DateField, DateRangeField_default as DateRangeField, DateRangePicker_default as DateRangePicker, DateTimeField_default as DateTimeField, DateTimePicker_default as DateTimePicker, DayView_default as DayView, Divider_default as Divider, Drawer_default as Drawer, DropdownMenu_default as DropdownMenu, EmptyState_default as EmptyState, FileInput_default as FileInput, FormField_default as FormField, HStack_default as HStack, Input_default as Input, Kbd_default as Kbd, Loader_default as Loader, MODO_CONFIG, MODO_LOCALE, Modal_default as Modal, ModoProvider_default as ModoProvider, MonthView_default as MonthView, MultiSelect_default as MultiSelect, NumberInput_default as NumberInput, OTPInput_default as OTPInput, PageHeader_default as PageHeader, Pagination_default as Pagination, PasswordInput_default as PasswordInput, PhoneInput_default as PhoneInput, PopoverPanel_default as PopoverPanel, ProgressBar_default as ProgressBar, Radio_default as Radio, RadioGroup_default as RadioGroup, RangeSlider_default as RangeSlider, Rating_default as Rating, SIZE_TOKENS, Scheduler_default as Scheduler, SearchInput_default as SearchInput, Segmented_default as Segmented, Select_default as Select, Sidebar_default as Sidebar, SidebarRow_default as SidebarRow, SidebarRowContent_default as SidebarRowContent, Skeleton_default as Skeleton, Slider_default as Slider, Stack_default as Stack, Stat_default as Stat, Stepper_default as Stepper, Switch_default as Switch, Switcher_default as Switcher, Table_default as Table, TableColumn_default as TableColumn, TablePagination_default as TablePagination, Tabs_default as Tabs, TagInput_default as TagInput, Textarea_default as Textarea, Timeline_default as Timeline, Toast_default as Toast, ToastContainer_default as ToastContainer, Tooltip_default as Tooltip, Topbar_default as Topbar, Typography_default as Typography, VStack_default as VStack, WeekView_default as WeekView, configureColorMode, createAvatarProvider, darkSurfaces, defaultLocale, defaultModoConfig, defaultPalettes, eventColorClass, eventColorClassStrong, hexToRgba, isSameDay, locales, mergeLocale, mergePalettes, normalizeSize, paletteFromHex, palettesToCssVars, resolveColorMode, semanticTokensFromPalettes, startOfDay, surfacesToCssVars, useAutoScroll, useCalendar, useColorMode, useConfirm, useConfirmQueue, useLocalStorage, useLocale, useLocaleString, useModoConfig, useModoLocale, usePopover, useResolvedColor, useResolvedHalo, useResolvedRadius, useResolvedSize, useResolvedTheme, useSizeTokens, useToast, useToastQueue };
106
+ export { Accordion_default as Accordion, AgendaView_default as AgendaView, AppShell_default as AppShell, Avatar_default as Avatar, AvatarCropper_default as AvatarCropper, AvatarGroup_default as AvatarGroup, AvatarUpload_default as AvatarUpload, Badge_default as Badge, Banner_default as Banner, Breadcrumbs_default as Breadcrumbs, Button_default as Button, ButtonGroup_default as ButtonGroup, Calendar_default as Calendar, CalendarEventTooltip_default as CalendarEventTooltip, CalendarHeader_default as CalendarHeader, Canvas_default as Canvas, Card_default as Card, Chart_default as Chart, Checkbox_default as Checkbox, Chip_default as Chip, Code_default as Code, ColorModeSwitch_default as ColorModeSwitch, ColorPicker_default as ColorPicker, Combobox_default as Combobox, ConfirmDialog_default as ConfirmDialog, Container_default as Container, DateField_default as DateField, DateRangeField_default as DateRangeField, DateRangePicker_default as DateRangePicker, DateTimeField_default as DateTimeField, DateTimePicker_default as DateTimePicker, DayView_default as DayView, Divider_default as Divider, Drawer_default as Drawer, DropdownMenu_default as DropdownMenu, EmptyState_default as EmptyState, FileInput_default as FileInput, FormField_default as FormField, HStack_default as HStack, Input_default as Input, Kbd_default as Kbd, Loader_default as Loader, MODO_CONFIG, MODO_LOCALE, MenuButton_default as MenuButton, Modal_default as Modal, ModoProvider_default as ModoProvider, MonthView_default as MonthView, MultiSelect_default as MultiSelect, NumberInput_default as NumberInput, OTPInput_default as OTPInput, PageHeader_default as PageHeader, Pagination_default as Pagination, PasswordInput_default as PasswordInput, PhoneInput_default as PhoneInput, PopoverPanel_default as PopoverPanel, ProgressBar_default as ProgressBar, Radio_default as Radio, RadioGroup_default as RadioGroup, RangeSlider_default as RangeSlider, Rating_default as Rating, SIZE_TOKENS, Scheduler_default as Scheduler, SearchInput_default as SearchInput, Segmented_default as Segmented, Select_default as Select, Sidebar_default as Sidebar, SidebarRow_default as SidebarRow, SidebarRowContent_default as SidebarRowContent, Skeleton_default as Skeleton, Slider_default as Slider, Stack_default as Stack, Stat_default as Stat, Stepper_default as Stepper, Switch_default as Switch, Switcher_default as Switcher, Table_default as Table, TableColumn_default as TableColumn, TablePagination_default as TablePagination, Tabs_default as Tabs, TagInput_default as TagInput, Textarea_default as Textarea, Timeline_default as Timeline, Toast_default as Toast, ToastContainer_default as ToastContainer, Tooltip_default as Tooltip, Topbar_default as Topbar, Typography_default as Typography, VStack_default as VStack, WeekView_default as WeekView, configureColorMode, createAvatarProvider, darkSurfaces, defaultLocale, defaultModoConfig, defaultPalettes, eventColorClass, eventColorClassStrong, hexToRgba, isSameDay, locales, mergeLocale, mergePalettes, normalizeSize, paletteFromHex, palettesToCssVars, resolveColorMode, semanticTokensFromPalettes, startOfDay, surfacesToCssVars, useAutoScroll, useCalendar, useColorMode, useConfirm, useConfirmQueue, useLocalStorage, useLocale, useLocaleString, useModoConfig, useModoLocale, usePopover, useResolvedColor, useResolvedHalo, useResolvedRadius, useResolvedSize, useResolvedTheme, useSizeTokens, useToast, useToastQueue };