@yamada-ui/react 2.2.5-dev-20260727050304 → 2.2.5-dev-20260727071034

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 (302) hide show
  1. package/dist/cjs/components/accordion/accordion.cjs.map +1 -1
  2. package/dist/cjs/components/action-bar/action-bar.cjs.map +1 -1
  3. package/dist/cjs/components/airy/airy.cjs.map +1 -1
  4. package/dist/cjs/components/alert/alert.cjs.map +1 -1
  5. package/dist/cjs/components/alpha-slider/alpha-slider.cjs.map +1 -1
  6. package/dist/cjs/components/autocomplete/autocomplete.cjs.map +1 -1
  7. package/dist/cjs/components/autocomplete/use-autocomplete.cjs.map +1 -1
  8. package/dist/cjs/components/avatar/avatar-group.cjs.map +1 -1
  9. package/dist/cjs/components/avatar/avatar.cjs.map +1 -1
  10. package/dist/cjs/components/blockquote/blockquote.cjs.map +1 -1
  11. package/dist/cjs/components/breadcrumb/breadcrumb.cjs.map +1 -1
  12. package/dist/cjs/components/button/button-group.cjs.map +1 -1
  13. package/dist/cjs/components/button/button.cjs.map +1 -1
  14. package/dist/cjs/components/calendar/calendar.cjs.map +1 -1
  15. package/dist/cjs/components/calendar/use-calendar.cjs.map +1 -1
  16. package/dist/cjs/components/carousel/carousel.cjs.map +1 -1
  17. package/dist/cjs/components/chart/cartesian-chart.cjs.map +1 -1
  18. package/dist/cjs/components/chart/chart.cjs.map +1 -1
  19. package/dist/cjs/components/chart/polar-chart.cjs.map +1 -1
  20. package/dist/cjs/components/checkbox/checkbox-group.cjs.map +1 -1
  21. package/dist/cjs/components/checkbox/checkbox.cjs.map +1 -1
  22. package/dist/cjs/components/checkbox-card/checkbox-card-group.cjs.map +1 -1
  23. package/dist/cjs/components/checkbox-card/checkbox-card.cjs.map +1 -1
  24. package/dist/cjs/components/circle-progress/circle-progress.cjs.map +1 -1
  25. package/dist/cjs/components/collapse/collapse.cjs.map +1 -1
  26. package/dist/cjs/components/color-picker/color-picker.cjs.map +1 -1
  27. package/dist/cjs/components/color-selector/color-selector.cjs.map +1 -1
  28. package/dist/cjs/components/color-swatch/color-swatch-group.cjs.map +1 -1
  29. package/dist/cjs/components/color-swatch/color-swatch.cjs.map +1 -1
  30. package/dist/cjs/components/data-list/data-list.cjs.map +1 -1
  31. package/dist/cjs/components/date-picker/date-picker.cjs.map +1 -1
  32. package/dist/cjs/components/date-picker/use-date-picker.cjs.map +1 -1
  33. package/dist/cjs/components/drawer/drawer.cjs.map +1 -1
  34. package/dist/cjs/components/dropzone/dropzone.cjs.map +1 -1
  35. package/dist/cjs/components/editable/editable.cjs.map +1 -1
  36. package/dist/cjs/components/empty-state/empty-state.cjs.map +1 -1
  37. package/dist/cjs/components/fade/fade.cjs.map +1 -1
  38. package/dist/cjs/components/fade-scale/fade-scale.cjs.map +1 -1
  39. package/dist/cjs/components/field/field.cjs.map +1 -1
  40. package/dist/cjs/components/fieldset/fieldset.cjs.map +1 -1
  41. package/dist/cjs/components/file-input/file-input.cjs.map +1 -1
  42. package/dist/cjs/components/flip/flip.cjs.map +1 -1
  43. package/dist/cjs/components/focus-lock/focus-lock.cjs.map +1 -1
  44. package/dist/cjs/components/form/form.cjs.map +1 -1
  45. package/dist/cjs/components/format/format-byte.cjs.map +1 -1
  46. package/dist/cjs/components/format/format-date-time.cjs.map +1 -1
  47. package/dist/cjs/components/format/format-number.cjs.map +1 -1
  48. package/dist/cjs/components/highlight/highlight.cjs.map +1 -1
  49. package/dist/cjs/components/hue-slider/hue-slider.cjs.map +1 -1
  50. package/dist/cjs/components/icon/icons/circle-euro-icon.cjs +14 -0
  51. package/dist/cjs/components/icon/icons/circle-euro-icon.cjs.map +1 -0
  52. package/dist/cjs/components/icon/icons/index.cjs +9 -3
  53. package/dist/cjs/components/icon/icons/index.cjs.map +1 -1
  54. package/dist/cjs/components/icon/icons/scan-box-icon.cjs +14 -0
  55. package/dist/cjs/components/icon/icons/scan-box-icon.cjs.map +1 -0
  56. package/dist/cjs/components/icon/icons/server-plus-icon.cjs +14 -0
  57. package/dist/cjs/components/icon/icons/server-plus-icon.cjs.map +1 -0
  58. package/dist/cjs/components/icon/index.cjs +6 -2
  59. package/dist/cjs/components/indicator/indicator.cjs.map +1 -1
  60. package/dist/cjs/components/infinite-scroll-area/infinite-scroll-area.cjs.map +1 -1
  61. package/dist/cjs/components/input/input-group.cjs.map +1 -1
  62. package/dist/cjs/components/link-box/link-box.cjs.map +1 -1
  63. package/dist/cjs/components/list/list.cjs.map +1 -1
  64. package/dist/cjs/components/loading/audio.cjs.map +1 -1
  65. package/dist/cjs/components/loading/background.cjs.map +1 -1
  66. package/dist/cjs/components/loading/circles.cjs.map +1 -1
  67. package/dist/cjs/components/loading/dots.cjs.map +1 -1
  68. package/dist/cjs/components/loading/grid.cjs.map +1 -1
  69. package/dist/cjs/components/loading/loading-provider.cjs.map +1 -1
  70. package/dist/cjs/components/loading/oval.cjs.map +1 -1
  71. package/dist/cjs/components/loading/page.cjs.map +1 -1
  72. package/dist/cjs/components/loading/puff.cjs.map +1 -1
  73. package/dist/cjs/components/loading/rings.cjs.map +1 -1
  74. package/dist/cjs/components/loading/screen.cjs.map +1 -1
  75. package/dist/cjs/components/loading/suspense.cjs.map +1 -1
  76. package/dist/cjs/components/menu/menu.cjs.map +1 -1
  77. package/dist/cjs/components/menu/use-menu.cjs.map +1 -1
  78. package/dist/cjs/components/modal/modal.cjs.map +1 -1
  79. package/dist/cjs/components/native-accordion/native-accordion.cjs.map +1 -1
  80. package/dist/cjs/components/native-popover/native-popover.cjs.map +1 -1
  81. package/dist/cjs/components/native-select/native-select.cjs.map +1 -1
  82. package/dist/cjs/components/native-select/use-native-select.cjs.map +1 -1
  83. package/dist/cjs/components/native-table/native-table.cjs.map +1 -1
  84. package/dist/cjs/components/notice/notice-provider.cjs.map +1 -1
  85. package/dist/cjs/components/notice/notice.cjs.map +1 -1
  86. package/dist/cjs/components/notice/use-notice.cjs.map +1 -1
  87. package/dist/cjs/components/number-input/number-input.cjs.map +1 -1
  88. package/dist/cjs/components/pagination/pagination.cjs.map +1 -1
  89. package/dist/cjs/components/password-input/password-input.cjs.map +1 -1
  90. package/dist/cjs/components/password-input/strength-meter.cjs.map +1 -1
  91. package/dist/cjs/components/picture/picture.cjs.map +1 -1
  92. package/dist/cjs/components/pin-input/pin-input.cjs.map +1 -1
  93. package/dist/cjs/components/popover/popover.cjs.map +1 -1
  94. package/dist/cjs/components/progress/progress.cjs.map +1 -1
  95. package/dist/cjs/components/qr-code/qr-code.cjs.map +1 -1
  96. package/dist/cjs/components/radio/radio-group.cjs.map +1 -1
  97. package/dist/cjs/components/radio/radio.cjs.map +1 -1
  98. package/dist/cjs/components/radio-card/radio-card-group.cjs.map +1 -1
  99. package/dist/cjs/components/radio-card/radio-card.cjs.map +1 -1
  100. package/dist/cjs/components/rating/rating.cjs.map +1 -1
  101. package/dist/cjs/components/reorder/reorder.cjs.map +1 -1
  102. package/dist/cjs/components/resizable/resizable.cjs.map +1 -1
  103. package/dist/cjs/components/ripple/ripple.cjs.map +1 -1
  104. package/dist/cjs/components/rotate/rotate.cjs.map +1 -1
  105. package/dist/cjs/components/saturation-slider/saturation-slider.cjs.map +1 -1
  106. package/dist/cjs/components/saturation-slider/use-saturation-slider.cjs.map +1 -1
  107. package/dist/cjs/components/segmented-control/segmented-control.cjs.map +1 -1
  108. package/dist/cjs/components/select/select.cjs.map +1 -1
  109. package/dist/cjs/components/select/use-select.cjs.map +1 -1
  110. package/dist/cjs/components/sidebar/sidebar.cjs.map +1 -1
  111. package/dist/cjs/components/skeleton/skeleton-text.cjs.map +1 -1
  112. package/dist/cjs/components/slide/slide.cjs.map +1 -1
  113. package/dist/cjs/components/slide-fade/slide-fade.cjs.map +1 -1
  114. package/dist/cjs/components/slider/slider.cjs.map +1 -1
  115. package/dist/cjs/components/slot/slot.cjs.map +1 -1
  116. package/dist/cjs/components/snacks/snacks.cjs.map +1 -1
  117. package/dist/cjs/components/stack/stack.cjs.map +1 -1
  118. package/dist/cjs/components/stack/z-stack.cjs.map +1 -1
  119. package/dist/cjs/components/stat/stat.cjs.map +1 -1
  120. package/dist/cjs/components/status/status.cjs.map +1 -1
  121. package/dist/cjs/components/steps/steps.cjs.map +1 -1
  122. package/dist/cjs/components/switch/switch.cjs.map +1 -1
  123. package/dist/cjs/components/table/table.cjs.map +1 -1
  124. package/dist/cjs/components/tabs/tabs.cjs.map +1 -1
  125. package/dist/cjs/components/tag/tag.cjs.map +1 -1
  126. package/dist/cjs/components/timeline/timeline.cjs.map +1 -1
  127. package/dist/cjs/components/tip/tip.cjs.map +1 -1
  128. package/dist/cjs/components/toggle/toggle-group.cjs.map +1 -1
  129. package/dist/cjs/components/tooltip/tooltip.cjs.map +1 -1
  130. package/dist/cjs/components/tree/tree.cjs.map +1 -1
  131. package/dist/cjs/components/tree/use-tree.cjs.map +1 -1
  132. package/dist/cjs/core/components/create-component.cjs.map +1 -1
  133. package/dist/cjs/core/system/breakpoint.cjs.map +1 -1
  134. package/dist/cjs/core/system/environment-provider.cjs.map +1 -1
  135. package/dist/cjs/core/system/styled.cjs.map +1 -1
  136. package/dist/cjs/core/system/theme-provider.cjs.map +1 -1
  137. package/dist/cjs/hooks/use-async-callback/index.cjs.map +1 -1
  138. package/dist/cjs/hooks/use-breakpoint/use-breakpoint.cjs.map +1 -1
  139. package/dist/cjs/hooks/use-combobox/index.cjs.map +1 -1
  140. package/dist/cjs/hooks/use-field-sizing/index.cjs.map +1 -1
  141. package/dist/cjs/hooks/use-outside-click/index.cjs.map +1 -1
  142. package/dist/cjs/index.cjs +9 -3
  143. package/dist/cjs/providers/ui-provider/ui-provider.cjs.map +1 -1
  144. package/dist/cjs/utils/store.cjs.map +1 -1
  145. package/dist/esm/components/accordion/accordion.js.map +1 -1
  146. package/dist/esm/components/action-bar/action-bar.js.map +1 -1
  147. package/dist/esm/components/airy/airy.js.map +1 -1
  148. package/dist/esm/components/alert/alert.js.map +1 -1
  149. package/dist/esm/components/alpha-slider/alpha-slider.js.map +1 -1
  150. package/dist/esm/components/autocomplete/autocomplete.js.map +1 -1
  151. package/dist/esm/components/autocomplete/use-autocomplete.js.map +1 -1
  152. package/dist/esm/components/avatar/avatar-group.js.map +1 -1
  153. package/dist/esm/components/avatar/avatar.js.map +1 -1
  154. package/dist/esm/components/blockquote/blockquote.js.map +1 -1
  155. package/dist/esm/components/breadcrumb/breadcrumb.js.map +1 -1
  156. package/dist/esm/components/button/button-group.js.map +1 -1
  157. package/dist/esm/components/button/button.js.map +1 -1
  158. package/dist/esm/components/calendar/calendar.js.map +1 -1
  159. package/dist/esm/components/calendar/use-calendar.js.map +1 -1
  160. package/dist/esm/components/carousel/carousel.js.map +1 -1
  161. package/dist/esm/components/chart/cartesian-chart.js.map +1 -1
  162. package/dist/esm/components/chart/chart.js.map +1 -1
  163. package/dist/esm/components/chart/polar-chart.js.map +1 -1
  164. package/dist/esm/components/checkbox/checkbox-group.js.map +1 -1
  165. package/dist/esm/components/checkbox/checkbox.js.map +1 -1
  166. package/dist/esm/components/checkbox-card/checkbox-card-group.js.map +1 -1
  167. package/dist/esm/components/checkbox-card/checkbox-card.js.map +1 -1
  168. package/dist/esm/components/circle-progress/circle-progress.js.map +1 -1
  169. package/dist/esm/components/collapse/collapse.js.map +1 -1
  170. package/dist/esm/components/color-picker/color-picker.js.map +1 -1
  171. package/dist/esm/components/color-selector/color-selector.js.map +1 -1
  172. package/dist/esm/components/color-swatch/color-swatch-group.js.map +1 -1
  173. package/dist/esm/components/color-swatch/color-swatch.js.map +1 -1
  174. package/dist/esm/components/data-list/data-list.js.map +1 -1
  175. package/dist/esm/components/date-picker/date-picker.js.map +1 -1
  176. package/dist/esm/components/date-picker/use-date-picker.js.map +1 -1
  177. package/dist/esm/components/drawer/drawer.js.map +1 -1
  178. package/dist/esm/components/dropzone/dropzone.js.map +1 -1
  179. package/dist/esm/components/editable/editable.js.map +1 -1
  180. package/dist/esm/components/empty-state/empty-state.js.map +1 -1
  181. package/dist/esm/components/fade/fade.js.map +1 -1
  182. package/dist/esm/components/fade-scale/fade-scale.js.map +1 -1
  183. package/dist/esm/components/field/field.js.map +1 -1
  184. package/dist/esm/components/fieldset/fieldset.js.map +1 -1
  185. package/dist/esm/components/file-input/file-input.js.map +1 -1
  186. package/dist/esm/components/flip/flip.js.map +1 -1
  187. package/dist/esm/components/focus-lock/focus-lock.js.map +1 -1
  188. package/dist/esm/components/form/form.js.map +1 -1
  189. package/dist/esm/components/format/format-byte.js.map +1 -1
  190. package/dist/esm/components/format/format-date-time.js.map +1 -1
  191. package/dist/esm/components/format/format-number.js.map +1 -1
  192. package/dist/esm/components/highlight/highlight.js.map +1 -1
  193. package/dist/esm/components/hue-slider/hue-slider.js.map +1 -1
  194. package/dist/esm/components/icon/icons/circle-euro-icon.js +14 -0
  195. package/dist/esm/components/icon/icons/circle-euro-icon.js.map +1 -0
  196. package/dist/esm/components/icon/icons/index.js +7 -3
  197. package/dist/esm/components/icon/icons/index.js.map +1 -1
  198. package/dist/esm/components/icon/icons/scan-box-icon.js +14 -0
  199. package/dist/esm/components/icon/icons/scan-box-icon.js.map +1 -0
  200. package/dist/esm/components/icon/icons/server-plus-icon.js +14 -0
  201. package/dist/esm/components/icon/icons/server-plus-icon.js.map +1 -0
  202. package/dist/esm/components/icon/index.js +4 -2
  203. package/dist/esm/components/indicator/indicator.js.map +1 -1
  204. package/dist/esm/components/infinite-scroll-area/infinite-scroll-area.js.map +1 -1
  205. package/dist/esm/components/input/input-group.js.map +1 -1
  206. package/dist/esm/components/link-box/link-box.js.map +1 -1
  207. package/dist/esm/components/list/list.js.map +1 -1
  208. package/dist/esm/components/loading/audio.js.map +1 -1
  209. package/dist/esm/components/loading/background.js.map +1 -1
  210. package/dist/esm/components/loading/circles.js.map +1 -1
  211. package/dist/esm/components/loading/dots.js.map +1 -1
  212. package/dist/esm/components/loading/grid.js.map +1 -1
  213. package/dist/esm/components/loading/loading-provider.js.map +1 -1
  214. package/dist/esm/components/loading/oval.js.map +1 -1
  215. package/dist/esm/components/loading/page.js.map +1 -1
  216. package/dist/esm/components/loading/puff.js.map +1 -1
  217. package/dist/esm/components/loading/rings.js.map +1 -1
  218. package/dist/esm/components/loading/screen.js.map +1 -1
  219. package/dist/esm/components/loading/suspense.js.map +1 -1
  220. package/dist/esm/components/menu/menu.js.map +1 -1
  221. package/dist/esm/components/menu/use-menu.js.map +1 -1
  222. package/dist/esm/components/modal/modal.js.map +1 -1
  223. package/dist/esm/components/native-accordion/native-accordion.js.map +1 -1
  224. package/dist/esm/components/native-popover/native-popover.js.map +1 -1
  225. package/dist/esm/components/native-select/native-select.js.map +1 -1
  226. package/dist/esm/components/native-select/use-native-select.js.map +1 -1
  227. package/dist/esm/components/native-table/native-table.js.map +1 -1
  228. package/dist/esm/components/notice/notice-provider.js.map +1 -1
  229. package/dist/esm/components/notice/notice.js.map +1 -1
  230. package/dist/esm/components/notice/use-notice.js.map +1 -1
  231. package/dist/esm/components/number-input/number-input.js.map +1 -1
  232. package/dist/esm/components/pagination/pagination.js.map +1 -1
  233. package/dist/esm/components/password-input/password-input.js.map +1 -1
  234. package/dist/esm/components/password-input/strength-meter.js.map +1 -1
  235. package/dist/esm/components/picture/picture.js.map +1 -1
  236. package/dist/esm/components/pin-input/pin-input.js.map +1 -1
  237. package/dist/esm/components/popover/popover.js.map +1 -1
  238. package/dist/esm/components/progress/progress.js.map +1 -1
  239. package/dist/esm/components/qr-code/qr-code.js.map +1 -1
  240. package/dist/esm/components/radio/radio-group.js.map +1 -1
  241. package/dist/esm/components/radio/radio.js.map +1 -1
  242. package/dist/esm/components/radio-card/radio-card-group.js.map +1 -1
  243. package/dist/esm/components/radio-card/radio-card.js.map +1 -1
  244. package/dist/esm/components/rating/rating.js.map +1 -1
  245. package/dist/esm/components/reorder/reorder.js.map +1 -1
  246. package/dist/esm/components/resizable/resizable.js.map +1 -1
  247. package/dist/esm/components/ripple/ripple.js.map +1 -1
  248. package/dist/esm/components/rotate/rotate.js.map +1 -1
  249. package/dist/esm/components/saturation-slider/saturation-slider.js.map +1 -1
  250. package/dist/esm/components/saturation-slider/use-saturation-slider.js.map +1 -1
  251. package/dist/esm/components/segmented-control/segmented-control.js.map +1 -1
  252. package/dist/esm/components/select/select.js.map +1 -1
  253. package/dist/esm/components/select/use-select.js.map +1 -1
  254. package/dist/esm/components/sidebar/sidebar.js.map +1 -1
  255. package/dist/esm/components/skeleton/skeleton-text.js.map +1 -1
  256. package/dist/esm/components/slide/slide.js.map +1 -1
  257. package/dist/esm/components/slide-fade/slide-fade.js.map +1 -1
  258. package/dist/esm/components/slider/slider.js.map +1 -1
  259. package/dist/esm/components/slot/slot.js.map +1 -1
  260. package/dist/esm/components/snacks/snacks.js.map +1 -1
  261. package/dist/esm/components/stack/stack.js.map +1 -1
  262. package/dist/esm/components/stack/z-stack.js.map +1 -1
  263. package/dist/esm/components/stat/stat.js.map +1 -1
  264. package/dist/esm/components/status/status.js.map +1 -1
  265. package/dist/esm/components/steps/steps.js.map +1 -1
  266. package/dist/esm/components/switch/switch.js.map +1 -1
  267. package/dist/esm/components/table/table.js.map +1 -1
  268. package/dist/esm/components/tabs/tabs.js.map +1 -1
  269. package/dist/esm/components/tag/tag.js.map +1 -1
  270. package/dist/esm/components/timeline/timeline.js.map +1 -1
  271. package/dist/esm/components/tip/tip.js.map +1 -1
  272. package/dist/esm/components/toggle/toggle-group.js.map +1 -1
  273. package/dist/esm/components/tooltip/tooltip.js.map +1 -1
  274. package/dist/esm/components/tree/tree.js.map +1 -1
  275. package/dist/esm/components/tree/use-tree.js.map +1 -1
  276. package/dist/esm/core/components/create-component.js.map +1 -1
  277. package/dist/esm/core/system/breakpoint.js.map +1 -1
  278. package/dist/esm/core/system/environment-provider.js.map +1 -1
  279. package/dist/esm/core/system/styled.js.map +1 -1
  280. package/dist/esm/core/system/theme-provider.js.map +1 -1
  281. package/dist/esm/hooks/use-breakpoint/use-breakpoint.js.map +1 -1
  282. package/dist/esm/hooks/use-combobox/index.js.map +1 -1
  283. package/dist/esm/hooks/use-field-sizing/index.js.map +1 -1
  284. package/dist/esm/hooks/use-outside-click/index.js.map +1 -1
  285. package/dist/esm/index.js +7 -3
  286. package/dist/esm/providers/ui-provider/ui-provider.js.map +1 -1
  287. package/dist/esm/utils/store.js.map +1 -1
  288. package/dist/types/components/icon/icons/circle-euro-icon.d.ts +13 -0
  289. package/dist/types/components/icon/icons/index.d.ts +5 -3
  290. package/dist/types/components/icon/icons/index.types.d.ts +1 -1
  291. package/dist/types/components/icon/icons/scan-box-icon.d.ts +13 -0
  292. package/dist/types/components/icon/icons/server-plus-icon.d.ts +13 -0
  293. package/dist/types/components/icon/index.d.ts +4 -2
  294. package/dist/types/components/menu/use-menu.d.ts +1 -1
  295. package/dist/types/components/number-input/number-input.style.d.ts +1 -1
  296. package/dist/types/index.d.ts +5 -3
  297. package/package.json +5 -5
  298. package/dist/cjs/components/icon/icons/circle-euro-sign-icon.cjs +0 -14
  299. package/dist/cjs/components/icon/icons/circle-euro-sign-icon.cjs.map +0 -1
  300. package/dist/esm/components/icon/icons/circle-euro-sign-icon.js +0 -14
  301. package/dist/esm/components/icon/icons/circle-euro-sign-icon.js.map +0 -1
  302. package/dist/types/components/icon/icons/circle-euro-sign-icon.d.ts +0 -13
@@ -1 +1 @@
1
- {"version":3,"file":"menu.js","names":["Popover.Root","Popover.Trigger","Popover.Anchor","Popover.Content"],"sources":["../../../../src/components/menu/menu.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, ReactElement, ReactNode } from \"react\"\nimport type {\n GenericsComponent,\n HTMLProps,\n HTMLStyledProps,\n ThemeProps,\n WithoutThemeProps,\n} from \"../../core\"\nimport type { MenuStyle } from \"./menu.style\"\nimport type {\n MenuOptionGroupType,\n MenuOptionGroupValue,\n UseMenuGroupProps,\n UseMenuItemProps,\n UseMenuOptionGroupProps,\n UseMenuOptionItemProps,\n UseMenuProps,\n UseMenuReturn,\n} from \"./use-menu\"\nimport { Fragment, useMemo, useState } from \"react\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { cast, handlerAll } from \"../../utils\"\nimport { CheckIcon, ChevronRightIcon, CircleSmallIcon } from \"../icon\"\nimport { Popover, usePopoverProps } from \"../popover\"\nimport { menuStyle } from \"./menu.style\"\nimport {\n MainMenuContext,\n MenuContext,\n MenuDescendantsContext,\n MenuGroupContext,\n MenuOptionGroupContext,\n useMenu,\n useMenuContext,\n useMenuGroup,\n useMenuGroupContext,\n useMenuItem,\n useMenuOptionGroup,\n useMenuOptionItem,\n} from \"./use-menu\"\n\ninterface MenuSharedItem {\n label?: ReactNode\n}\n\ninterface MenuItemWithValue extends MenuSharedItem, MenuItemProps {}\n\ninterface MenuOptionItem extends MenuSharedItem, MenuOptionItemProps {}\n\ninterface MenuItemWithSeparator extends MenuSeparatorProps {\n type: \"separator\"\n}\n\ninterface MenuItemWithRadioGroup<Y extends string = string>\n extends\n Omit<MenuItemWithItems, \"defaultValue\" | \"items\" | \"onChange\">,\n MenuOptionGroupProps<\"radio\", Y> {\n type: \"radio\"\n items?: MenuOptionItem[]\n}\n\ninterface MenuItemWithCheckboxGroup<Y extends string[] = string[]>\n extends\n Omit<MenuItemWithItems, \"defaultValue\" | \"items\" | \"onChange\">,\n MenuOptionGroupProps<\"checkbox\", Y> {\n type: \"checkbox\"\n items?: MenuOptionItem[]\n}\n\ninterface MenuItemWithItems extends MenuSharedItem, MenuGroupProps {\n hasEndSeparator?: boolean\n hasSeparator?: boolean\n hasStartSeparator?: boolean\n items?: MenuItemWithValue[]\n labelProps?: MenuLabelProps\n}\n\nexport type MenuItem =\n | MenuItemWithCheckboxGroup\n | MenuItemWithItems\n | MenuItemWithRadioGroup\n | MenuItemWithSeparator\n | MenuItemWithValue\n\ninterface ComponentContext extends Pick<\n UseMenuReturn,\n | \"getContentProps\"\n | \"getContextTriggerProps\"\n | \"getSeparatorProps\"\n | \"getTriggerProps\"\n> {}\n\nexport interface MenuRootProps\n extends\n UseMenuProps,\n Omit<\n WithoutThemeProps<Popover.RootProps, MenuStyle>,\n \"autoFocus\" | \"modal\" | \"updateRef\" | \"withCloseButton\"\n >,\n ThemeProps<MenuStyle> {\n /**\n * The placement of the popper relative to its reference.\n *\n * @default 'end-start'\n */\n placement?: Popover.RootProps[\"placement\"]\n}\n\nconst {\n ComponentContext,\n PropsContext: MenuPropsContext,\n StyleContext,\n useComponentContext,\n usePropsContext: useMenuPropsContext,\n withContext,\n useRootComponentProps,\n} = createSlotComponent<MenuRootProps, MenuStyle, ComponentContext>(\n \"menu\",\n menuStyle,\n)\n\nexport { MenuPropsContext, useMenuPropsContext }\n\n/**\n * `Menu` is a component that displays a common dropdown menu.\n *\n * @see https://yamada-ui.com/docs/components/menu\n */\nexport const MenuRoot: FC<MenuRootProps> = (props) => {\n const [styleContext, mergedProps] = useRootComponentProps(props)\n const [\n { animationScheme, initialFocusRef, offset, placement, ...popoverProps },\n { children, disabled, ...rest },\n ] = usePopoverProps(mergedProps, [\n \"disabled\",\n \"open\",\n \"defaultOpen\",\n \"onOpen\",\n \"onClose\",\n ])\n const {\n closeOnSelect,\n descendants,\n open,\n subMenu,\n subMenuDirection,\n updateRef,\n getContentProps,\n getContextTriggerProps,\n getSeparatorProps,\n getTriggerProps,\n onActiveDescendant,\n onClose,\n onCloseRef,\n onCloseSubMenu,\n onOpen,\n onSelect,\n } = useMenu({ disabled, ...rest })\n const mergedPopoverProps = useMemo<Popover.RootProps>(\n () => ({\n ...popoverProps,\n animationScheme:\n animationScheme ?? (subMenu ? \"inline-start\" : \"block-start\"),\n autoFocus: !!initialFocusRef,\n disabled,\n initialFocusRef,\n offset: offset ?? (subMenu ? [0, 0] : undefined),\n open,\n placement:\n placement ?? (subMenu ? `center-${subMenuDirection}` : \"end-start\"),\n updateRef,\n onClose,\n onOpen,\n }),\n [\n animationScheme,\n disabled,\n initialFocusRef,\n offset,\n onClose,\n onOpen,\n open,\n placement,\n popoverProps,\n subMenu,\n subMenuDirection,\n updateRef,\n ],\n )\n const menuContext = useMemo(\n () => ({\n subMenu,\n subMenuDirection,\n onActiveDescendant,\n onClose,\n onCloseSubMenu,\n onOpen,\n onSelect,\n }),\n [\n onClose,\n onOpen,\n onSelect,\n onActiveDescendant,\n subMenu,\n subMenuDirection,\n onCloseSubMenu,\n ],\n )\n const mainMenuContext = useMemo(\n () => ({\n closeOnSelect,\n descendants,\n onActiveDescendant,\n onCloseRef,\n onSelect,\n }),\n [closeOnSelect, descendants, onActiveDescendant, onCloseRef, onSelect],\n )\n const componentContext = useMemo(\n () => ({\n getContentProps,\n getContextTriggerProps,\n getSeparatorProps,\n getTriggerProps,\n }),\n [\n getContentProps,\n getContextTriggerProps,\n getSeparatorProps,\n getTriggerProps,\n ],\n )\n\n return (\n <StyleContext value={styleContext}>\n <MenuDescendantsContext value={descendants}>\n <MenuContext value={menuContext}>\n <MainMenuContext value={mainMenuContext}>\n <ComponentContext value={componentContext}>\n <Popover.Root {...mergedPopoverProps}>{children}</Popover.Root>\n </ComponentContext>\n </MainMenuContext>\n </MenuContext>\n </MenuDescendantsContext>\n </StyleContext>\n )\n}\n\nexport interface MenuTriggerProps extends Popover.TriggerProps {}\n\nexport const MenuTrigger = withContext<\"button\", MenuTriggerProps>(\n Popover.Trigger,\n \"trigger\",\n)(undefined, (props) => {\n const { getTriggerProps } = useComponentContext()\n\n return cast<HTMLProps<\"button\">>(getTriggerProps(cast<HTMLProps>(props)))\n})\n\ninterface Rect {\n left: number\n top: number\n}\n\nexport interface MenuContextTriggerProps extends HTMLProps {}\n\nexport const MenuContextTrigger = withContext<\"div\", MenuContextTriggerProps>(\n ({ children, onContextMenu, ...rest }) => {\n const [rect, setRect] = useState<Rect>({\n left: 0,\n top: 0,\n })\n const { getContextTriggerProps } = useComponentContext()\n\n return (\n <>\n <MenuAnchor>\n <styled.div style={{ position: \"fixed\", ...rect }} />\n </MenuAnchor>\n\n <styled.div\n asChild\n {...getContextTriggerProps({\n onContextMenu: handlerAll(onContextMenu, (ev) => {\n setRect({ left: ev.clientX, top: ev.clientY })\n }),\n ...rest,\n })}\n >\n {children}\n </styled.div>\n </>\n )\n },\n \"contextTrigger\",\n)()\n\nexport interface MenuAnchorProps extends Popover.AnchorProps {}\n\nexport const MenuAnchor = withContext<\"div\", MenuAnchorProps>(\n Popover.Anchor,\n \"anchor\",\n)()\n\nexport interface MenuContentProps extends Popover.ContentProps {\n /**\n * The footer of the menu.\n */\n footer?: ReactNode\n /**\n * The header of the menu.\n */\n header?: ReactNode\n /**\n * If provided, generate elements based on items.\n */\n items?: MenuItem[]\n /**\n * Props for the footer component.\n */\n footerProps?: MenuFooterProps\n /**\n * Props for the header component.\n */\n headerProps?: MenuHeaderProps\n}\n\nexport const MenuContent = withContext<\"div\", MenuContentProps>(\n Popover.Content,\n \"content\",\n)(\n undefined,\n ({\n children,\n footer,\n header,\n items = [],\n footerProps,\n headerProps,\n portalProps,\n ...rest\n }) => {\n const { subMenu } = useMenuContext()\n const { getContentProps } = useComponentContext()\n const computedChildren = useMemo(() => {\n if (children) return children\n\n return (\n <>\n {header ? <MenuHeader {...headerProps}>{header}</MenuHeader> : null}\n\n {items.map((props, index) => {\n if (\"type\" in props) {\n if (props.type === \"radio\") {\n const {\n type,\n hasSeparator = true,\n hasEndSeparator = hasSeparator,\n hasStartSeparator = hasSeparator,\n items = [],\n ...rest\n } = props\n\n return (\n <Fragment key={index}>\n {hasStartSeparator ? <MenuSeparator /> : null}\n\n <MenuOptionGroup type={type} {...rest}>\n {items.map(({ label, ...rest }, index) => (\n <MenuOptionItem key={index} {...rest}>\n {label}\n </MenuOptionItem>\n ))}\n </MenuOptionGroup>\n\n {hasEndSeparator ? <MenuSeparator /> : null}\n </Fragment>\n )\n } else if (props.type === \"checkbox\") {\n const {\n type,\n hasSeparator = true,\n hasEndSeparator = hasSeparator,\n hasStartSeparator = hasSeparator,\n items = [],\n ...rest\n } = props\n\n return (\n <Fragment key={index}>\n {hasStartSeparator ? <MenuSeparator /> : null}\n\n <MenuOptionGroup type={type} {...rest}>\n {items.map(({ label, ...rest }, index) => (\n <MenuOptionItem key={index} {...rest}>\n {label}\n </MenuOptionItem>\n ))}\n </MenuOptionGroup>\n\n {hasEndSeparator ? <MenuSeparator /> : null}\n </Fragment>\n )\n } else {\n return <MenuSeparator key={index} />\n }\n } else if (\"items\" in props) {\n const {\n hasSeparator = true,\n hasEndSeparator = hasSeparator,\n hasStartSeparator = hasSeparator,\n items = [],\n ...rest\n } = props\n\n return (\n <Fragment key={index}>\n {hasStartSeparator ? <MenuSeparator /> : null}\n\n <MenuGroup {...rest}>\n {items.map(({ label, ...rest }, index) => (\n <MenuItem key={index} {...rest}>\n {label}\n </MenuItem>\n ))}\n </MenuGroup>\n\n {hasEndSeparator ? <MenuSeparator /> : null}\n </Fragment>\n )\n } else if (\"value\" in props) {\n const { label, ...rest } = props\n\n return (\n <MenuItem key={index} {...rest}>\n {label}\n </MenuItem>\n )\n }\n })}\n\n {footer ? <MenuFooter {...footerProps}>{footer}</MenuFooter> : null}\n </>\n )\n }, [children, footer, footerProps, header, headerProps, items])\n\n return {\n ...getContentProps(\n cast<HTMLProps>({ ...rest, children: computedChildren }),\n ),\n portalProps: subMenu ? { ...portalProps, disabled: true } : portalProps,\n }\n },\n)\n\nexport interface MenuHeaderProps extends HTMLStyledProps {}\n\nexport const MenuHeader = withContext<\"div\", MenuHeaderProps>(\n \"div\",\n \"header\",\n)({ \"data-header\": \"\" })\n\nexport interface MenuFooterProps extends HTMLStyledProps {}\n\nexport const MenuFooter = withContext<\"div\", MenuFooterProps>(\n \"div\",\n \"footer\",\n)({ \"data-footer\": \"\" })\n\nexport interface MenuLabelProps extends HTMLStyledProps<\"span\"> {}\n\nexport const MenuLabel = withContext<\"span\", MenuLabelProps>(\"span\", \"label\")(\n undefined,\n (props) => {\n const { getLabelProps } = useMenuGroupContext()\n\n return getLabelProps(props)\n },\n)\n\nexport interface MenuGroupProps extends UseMenuGroupProps, HTMLStyledProps {\n /**\n * The label of the group.\n */\n label?: ReactNode\n /**\n * Props for the label component.\n */\n labelProps?: MenuLabelProps\n}\n\nexport const MenuGroup = withContext<\"div\", MenuGroupProps>(\n ({ children, label, labelProps, ...rest }) => {\n const { getGroupProps, getLabelProps } = useMenuGroup(rest)\n const context = useMemo(() => ({ getLabelProps }), [getLabelProps])\n\n return (\n <MenuGroupContext value={context}>\n <styled.div {...getGroupProps()}>\n {label ? <MenuLabel {...labelProps}>{label}</MenuLabel> : null}\n {children}\n </styled.div>\n </MenuGroupContext>\n )\n },\n \"group\",\n)()\n\nexport interface MenuOptionGroupProps<\n Y extends MenuOptionGroupType = \"checkbox\",\n M extends MenuOptionGroupValue<Y> = MenuOptionGroupValue<Y>,\n>\n extends\n UseMenuOptionGroupProps<Y, M>,\n Omit<MenuGroupProps, \"defaultValue\" | \"onChange\"> {}\n\nexport const MenuOptionGroup = withContext<\"div\", MenuOptionGroupProps>(\n ({\n type: typeProp,\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n ...rest\n }) => {\n const { type, value, onChange } = useMenuOptionGroup({\n type: typeProp,\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const context = useMemo(\n () => ({ type, value, onChange }),\n [type, value, onChange],\n )\n\n return (\n <MenuOptionGroupContext value={context}>\n <MenuGroup {...rest} />\n </MenuOptionGroupContext>\n )\n },\n { name: \"OptionGroup\", slot: [\"group\", \"option\"] },\n)() as GenericsComponent<{\n <\n Y extends MenuOptionGroupType = \"checkbox\",\n M extends MenuOptionGroupValue<Y> = MenuOptionGroupValue<Y>,\n >(\n props: MenuOptionGroupProps<Y, M>,\n ): ReactElement\n}>\n\nexport interface MenuItemProps extends HTMLStyledProps, UseMenuItemProps {}\n\nexport const MenuItem = withContext<\"div\", MenuItemProps>(\n ({ children, ...rest }) => {\n const { subMenuTrigger, getItemProps } = useMenuItem(rest)\n\n return (\n <styled.div {...getItemProps()}>\n {children}\n\n {subMenuTrigger ? (\n <MenuIndicator as={ChevronRightIcon} ms=\"auto\" />\n ) : null}\n </styled.div>\n )\n },\n \"item\",\n)()\n\nexport interface MenuOptionItemProps\n extends HTMLStyledProps, UseMenuOptionItemProps {\n /**\n * The icon to be used in the menu option item.\n */\n icon?: ReactNode\n}\n\nexport const MenuOptionItem = withContext<\"div\", MenuOptionItemProps>(\n ({ children, icon, ...rest }) => {\n const { type, getIndicatorProps, getOptionItemProps } =\n useMenuOptionItem(rest)\n\n return (\n <styled.div {...getOptionItemProps()}>\n <MenuIndicator {...getIndicatorProps()}>\n {icon ||\n (type === \"radio\" ? (\n <CircleSmallIcon fill=\"currentColor\" />\n ) : (\n <CheckIcon />\n ))}\n </MenuIndicator>\n {children}\n </styled.div>\n )\n },\n { name: \"OptionItem\", slot: [\"item\", \"option\"] },\n)()\n\nexport interface MenuIndicatorProps extends HTMLStyledProps {}\n\nexport const MenuIndicator = withContext<\"div\", MenuIndicatorProps>(\n \"div\",\n \"indicator\",\n)()\n\nexport interface MenuCommandProps extends HTMLStyledProps<\"kbd\"> {}\n\nexport const MenuCommand = withContext<\"kbd\", MenuCommandProps>(\n \"kbd\",\n \"command\",\n)()\n\nexport interface MenuSeparatorProps extends HTMLStyledProps<\"hr\"> {}\n\nexport const MenuSeparator = withContext<\"hr\", MenuSeparatorProps>(\n \"hr\",\n \"separator\",\n)(undefined, (props) => {\n const { getSeparatorProps } = useComponentContext()\n\n return getSeparatorProps(props)\n})\n"],"mappings":";;;;;;;;;;;;;;AA6GA,MAAM,EACJ,kBACA,cAAc,kBACd,cACA,qBACA,iBAAiB,qBACjB,aACA,0BACE,oBACF,QACA,SACF;;;;;;AASA,MAAa,YAA+B,UAAU;CACpD,MAAM,CAAC,cAAc,eAAe,sBAAsB,KAAK;CAC/D,MAAM,CACJ,EAAE,iBAAiB,iBAAiB,QAAQ,WAAW,GAAG,gBAC1D,EAAE,UAAU,UAAU,GAAG,UACvB,gBAAgB,aAAa;EAC/B;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,MAAM,EACJ,eACA,aACA,MACA,SACA,kBACA,WACA,iBACA,wBACA,mBACA,iBACA,oBACA,SACA,YACA,gBACA,QACA,aACE,Q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GACA;CAAE,MAAM;CAAe,MAAM,CAAC,SAAS,QAAQ;AAAE,CACnD,CAAC,CAAC;AAWF,MAAa,WAAW,aACrB,EAAE,UAAU,GAAG,WAAW;CACzB,MAAM,EAAE,gBAAgB,iBAAiB,YAAY,IAAI;CAEzD,OACE,qBAAC,OAAO,KAAR;EAAY,GAAI,aAAa;YAA7B,CACG,UAEA,iBACC,oBAAC,eAAD;GAAe,IAAI;GAAkB,IAAG;EAAQ,CAAA,IAC9C,IACM;;AAEhB,GACA,MACF,CAAC,CAAC;AAUF,MAAa,iBAAiB,aAC3B,EAAE,UAAU,MAAM,GAAG,WAAW;CAC/B,MAAM,EAAE,MAAM,mBAAmB,uBAC/B,kBAAkB,IAAI;CAExB,OACE,qBAAC,OAAO,KAAR;EAAY,GAAI,mBAAmB;YAAnC,CACE,oBAAC,eAAD;GAAe,GAAI,kBAAkB;aAClC,SACE,SAAS,UACR,oBAAC,iBAAD,EAAiB,MAAK,eAAgB,CAAA,IAEtC,oBAAC,WAAD,CAAY,CAAA;EAEH,CAAA,GACd,QACS;;AAEhB,GACA;CAAE,MAAM;CAAc,MAAM,CAAC,QAAQ,QAAQ;AAAE,CACjD,CAAC,CAAC;AAIF,MAAa,gBAAgB,YAC3B,OACA,WACF,CAAC,CAAC;AAIF,MAAa,cAAc,YACzB,OACA,SACF,CAAC,CAAC;AAIF,MAAa,gBAAgB,YAC3B,MACA,WACF,CAAC,CAAC,KAAA,IAAY,UAAU;CACtB,MAAM,EAAE,sBAAsB,oBAAoB;CAElD,OAAO,kBAAkB,KAAK;AAChC,CAAC"}
1
+ {"version":3,"file":"menu.js","names":["Popover.Root","Popover.Trigger","Popover.Anchor","Popover.Content"],"sources":["../../../../src/components/menu/menu.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, ReactElement, ReactNode } from \"react\"\nimport type {\n GenericsComponent,\n HTMLProps,\n HTMLStyledProps,\n ThemeProps,\n WithoutThemeProps,\n} from \"../../core\"\nimport type { MenuStyle } from \"./menu.style\"\nimport type {\n MenuOptionGroupType,\n MenuOptionGroupValue,\n UseMenuGroupProps,\n UseMenuItemProps,\n UseMenuOptionGroupProps,\n UseMenuOptionItemProps,\n UseMenuProps,\n UseMenuReturn,\n} from \"./use-menu\"\nimport { Fragment, useMemo, useState } from \"react\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { cast, handlerAll } from \"../../utils\"\nimport { CheckIcon, ChevronRightIcon, CircleSmallIcon } from \"../icon\"\nimport { Popover, usePopoverProps } from \"../popover\"\nimport { menuStyle } from \"./menu.style\"\nimport {\n MainMenuContext,\n MenuContext,\n MenuDescendantsContext,\n MenuGroupContext,\n MenuOptionGroupContext,\n useMenu,\n useMenuContext,\n useMenuGroup,\n useMenuGroupContext,\n useMenuItem,\n useMenuOptionGroup,\n useMenuOptionItem,\n} from \"./use-menu\"\n\ninterface MenuSharedItem {\n label?: ReactNode\n}\n\ninterface MenuItemWithValue extends MenuSharedItem, MenuItemProps {}\n\ninterface MenuOptionItem extends MenuSharedItem, MenuOptionItemProps {}\n\ninterface MenuItemWithSeparator extends MenuSeparatorProps {\n type: \"separator\"\n}\n\ninterface MenuItemWithRadioGroup<Y extends string = string>\n extends\n Omit<MenuItemWithItems, \"defaultValue\" | \"items\" | \"onChange\">,\n MenuOptionGroupProps<\"radio\", Y> {\n type: \"radio\"\n items?: MenuOptionItem[]\n}\n\ninterface MenuItemWithCheckboxGroup<Y extends string[] = string[]>\n extends\n Omit<MenuItemWithItems, \"defaultValue\" | \"items\" | \"onChange\">,\n MenuOptionGroupProps<\"checkbox\", Y> {\n type: \"checkbox\"\n items?: MenuOptionItem[]\n}\n\ninterface MenuItemWithItems extends MenuSharedItem, MenuGroupProps {\n hasEndSeparator?: boolean\n hasSeparator?: boolean\n hasStartSeparator?: boolean\n items?: MenuItemWithValue[]\n labelProps?: MenuLabelProps\n}\n\nexport type MenuItem =\n | MenuItemWithCheckboxGroup\n | MenuItemWithItems\n | MenuItemWithRadioGroup\n | MenuItemWithSeparator\n | MenuItemWithValue\n\ninterface ComponentContext extends Pick<\n UseMenuReturn,\n | \"getContentProps\"\n | \"getContextTriggerProps\"\n | \"getSeparatorProps\"\n | \"getTriggerProps\"\n> {}\n\nexport interface MenuRootProps\n extends\n UseMenuProps,\n Omit<\n WithoutThemeProps<Popover.RootProps, MenuStyle>,\n \"autoFocus\" | \"modal\" | \"updateRef\" | \"withCloseButton\"\n >,\n ThemeProps<MenuStyle> {\n /**\n * The placement of the popper relative to its reference.\n *\n * @default 'end-start'\n */\n placement?: Popover.RootProps[\"placement\"]\n}\n\nconst {\n ComponentContext,\n PropsContext: MenuPropsContext,\n StyleContext,\n useComponentContext,\n usePropsContext: useMenuPropsContext,\n withContext,\n useRootComponentProps,\n} = createSlotComponent<MenuRootProps, MenuStyle, ComponentContext>(\n \"menu\",\n menuStyle,\n)\n\nexport { MenuPropsContext, useMenuPropsContext }\n\n/**\n * `Menu` is a component that displays a common dropdown menu.\n *\n * @see https://yamada-ui.com/docs/components/menu\n */\nexport const MenuRoot: FC<MenuRootProps> = (props) => {\n const [styleContext, mergedProps] = useRootComponentProps(props)\n const [\n { animationScheme, initialFocusRef, offset, placement, ...popoverProps },\n { children, disabled, ...rest },\n ] = usePopoverProps(mergedProps, [\n \"disabled\",\n \"open\",\n \"defaultOpen\",\n \"onOpen\",\n \"onClose\",\n ])\n const {\n closeOnSelect,\n descendants,\n open,\n subMenu,\n subMenuDirection,\n updateRef,\n getContentProps,\n getContextTriggerProps,\n getSeparatorProps,\n getTriggerProps,\n onActiveDescendant,\n onClose,\n onCloseRef,\n onCloseSubMenu,\n onOpen,\n onSelect,\n } = useMenu({ disabled, ...rest })\n const mergedPopoverProps = useMemo<Popover.RootProps>(\n () => ({\n ...popoverProps,\n animationScheme:\n animationScheme ?? (subMenu ? \"inline-start\" : \"block-start\"),\n autoFocus: !!initialFocusRef,\n disabled,\n initialFocusRef,\n offset: offset ?? (subMenu ? [0, 0] : undefined),\n open,\n placement:\n placement ?? (subMenu ? `center-${subMenuDirection}` : \"end-start\"),\n updateRef,\n onClose,\n onOpen,\n }),\n [\n animationScheme,\n disabled,\n initialFocusRef,\n offset,\n onClose,\n onOpen,\n open,\n placement,\n popoverProps,\n subMenu,\n subMenuDirection,\n updateRef,\n ],\n )\n const menuContext = useMemo(\n () => ({\n subMenu,\n subMenuDirection,\n onActiveDescendant,\n onClose,\n onCloseSubMenu,\n onOpen,\n onSelect,\n }),\n [\n onClose,\n onOpen,\n onSelect,\n onActiveDescendant,\n subMenu,\n subMenuDirection,\n onCloseSubMenu,\n ],\n )\n const mainMenuContext = useMemo(\n () => ({\n closeOnSelect,\n descendants,\n onActiveDescendant,\n onCloseRef,\n onSelect,\n }),\n [closeOnSelect, descendants, onActiveDescendant, onCloseRef, onSelect],\n )\n const componentContext = useMemo(\n () => ({\n getContentProps,\n getContextTriggerProps,\n getSeparatorProps,\n getTriggerProps,\n }),\n [\n getContentProps,\n getContextTriggerProps,\n getSeparatorProps,\n getTriggerProps,\n ],\n )\n\n return (\n <StyleContext value={styleContext}>\n <MenuDescendantsContext value={descendants}>\n <MenuContext value={menuContext}>\n <MainMenuContext value={mainMenuContext}>\n <ComponentContext value={componentContext}>\n <Popover.Root {...mergedPopoverProps}>{children}</Popover.Root>\n </ComponentContext>\n </MainMenuContext>\n </MenuContext>\n </MenuDescendantsContext>\n </StyleContext>\n )\n}\n\nexport interface MenuTriggerProps extends Popover.TriggerProps {}\n\nexport const MenuTrigger = withContext<\"button\", MenuTriggerProps>(\n Popover.Trigger,\n \"trigger\",\n)(undefined, (props) => {\n const { getTriggerProps } = useComponentContext()\n\n return cast<HTMLProps<\"button\">>(getTriggerProps(cast<HTMLProps>(props)))\n})\n\ninterface Rect {\n left: number\n top: number\n}\n\nexport interface MenuContextTriggerProps extends HTMLProps {}\n\nexport const MenuContextTrigger = withContext<\"div\", MenuContextTriggerProps>(\n ({ children, onContextMenu, ...rest }) => {\n const [rect, setRect] = useState<Rect>({\n left: 0,\n top: 0,\n })\n const { getContextTriggerProps } = useComponentContext()\n\n return (\n <>\n <MenuAnchor>\n <styled.div style={{ position: \"fixed\", ...rect }} />\n </MenuAnchor>\n\n <styled.div\n asChild\n {...getContextTriggerProps({\n onContextMenu: handlerAll(onContextMenu, (ev) => {\n setRect({ left: ev.clientX, top: ev.clientY })\n }),\n ...rest,\n })}\n >\n {children}\n </styled.div>\n </>\n )\n },\n \"contextTrigger\",\n)()\n\nexport interface MenuAnchorProps extends Popover.AnchorProps {}\n\nexport const MenuAnchor = withContext<\"div\", MenuAnchorProps>(\n Popover.Anchor,\n \"anchor\",\n)()\n\nexport interface MenuContentProps extends Popover.ContentProps {\n /**\n * The footer of the menu.\n */\n footer?: ReactNode\n /**\n * The header of the menu.\n */\n header?: ReactNode\n /**\n * If provided, generate elements based on items.\n */\n items?: MenuItem[]\n /**\n * Props for the footer component.\n */\n footerProps?: MenuFooterProps\n /**\n * Props for the header component.\n */\n headerProps?: MenuHeaderProps\n}\n\nexport const MenuContent = withContext<\"div\", MenuContentProps>(\n Popover.Content,\n \"content\",\n)(\n undefined,\n ({\n children,\n footer,\n header,\n items = [],\n footerProps,\n headerProps,\n portalProps,\n ...rest\n }) => {\n const { subMenu } = useMenuContext()\n const { getContentProps } = useComponentContext()\n const computedChildren = useMemo(() => {\n if (children) return children\n\n return (\n <>\n {header ? <MenuHeader {...headerProps}>{header}</MenuHeader> : null}\n\n {items.map((props, index) => {\n if (\"type\" in props) {\n if (props.type === \"radio\") {\n const {\n type,\n hasSeparator = true,\n hasEndSeparator = hasSeparator,\n hasStartSeparator = hasSeparator,\n items = [],\n ...rest\n } = props\n\n return (\n <Fragment key={index}>\n {hasStartSeparator ? <MenuSeparator /> : null}\n\n <MenuOptionGroup type={type} {...rest}>\n {items.map(({ label, ...rest }, index) => (\n <MenuOptionItem key={index} {...rest}>\n {label}\n </MenuOptionItem>\n ))}\n </MenuOptionGroup>\n\n {hasEndSeparator ? <MenuSeparator /> : null}\n </Fragment>\n )\n } else if (props.type === \"checkbox\") {\n const {\n type,\n hasSeparator = true,\n hasEndSeparator = hasSeparator,\n hasStartSeparator = hasSeparator,\n items = [],\n ...rest\n } = props\n\n return (\n <Fragment key={index}>\n {hasStartSeparator ? <MenuSeparator /> : null}\n\n <MenuOptionGroup type={type} {...rest}>\n {items.map(({ label, ...rest }, index) => (\n <MenuOptionItem key={index} {...rest}>\n {label}\n </MenuOptionItem>\n ))}\n </MenuOptionGroup>\n\n {hasEndSeparator ? <MenuSeparator /> : null}\n </Fragment>\n )\n } else {\n return <MenuSeparator key={index} />\n }\n } else if (\"items\" in props) {\n const {\n hasSeparator = true,\n hasEndSeparator = hasSeparator,\n hasStartSeparator = hasSeparator,\n items = [],\n ...rest\n } = props\n\n return (\n <Fragment key={index}>\n {hasStartSeparator ? <MenuSeparator /> : null}\n\n <MenuGroup {...rest}>\n {items.map(({ label, ...rest }, index) => (\n <MenuItem key={index} {...rest}>\n {label}\n </MenuItem>\n ))}\n </MenuGroup>\n\n {hasEndSeparator ? <MenuSeparator /> : null}\n </Fragment>\n )\n } else if (\"value\" in props) {\n const { label, ...rest } = props\n\n return (\n <MenuItem key={index} {...rest}>\n {label}\n </MenuItem>\n )\n }\n })}\n\n {footer ? <MenuFooter {...footerProps}>{footer}</MenuFooter> : null}\n </>\n )\n }, [children, footer, footerProps, header, headerProps, items])\n\n return {\n ...getContentProps(\n cast<HTMLProps>({ ...rest, children: computedChildren }),\n ),\n portalProps: subMenu ? { ...portalProps, disabled: true } : portalProps,\n }\n },\n)\n\nexport interface MenuHeaderProps extends HTMLStyledProps {}\n\nexport const MenuHeader = withContext<\"div\", MenuHeaderProps>(\n \"div\",\n \"header\",\n)({ \"data-header\": \"\" })\n\nexport interface MenuFooterProps extends HTMLStyledProps {}\n\nexport const MenuFooter = withContext<\"div\", MenuFooterProps>(\n \"div\",\n \"footer\",\n)({ \"data-footer\": \"\" })\n\nexport interface MenuLabelProps extends HTMLStyledProps<\"span\"> {}\n\nexport const MenuLabel = withContext<\"span\", MenuLabelProps>(\"span\", \"label\")(\n undefined,\n (props) => {\n const { getLabelProps } = useMenuGroupContext()\n\n return getLabelProps(props)\n },\n)\n\nexport interface MenuGroupProps extends UseMenuGroupProps, HTMLStyledProps {\n /**\n * The label of the group.\n */\n label?: ReactNode\n /**\n * Props for the label component.\n */\n labelProps?: MenuLabelProps\n}\n\nexport const MenuGroup = withContext<\"div\", MenuGroupProps>(\n ({ children, label, labelProps, ...rest }) => {\n const { getGroupProps, getLabelProps } = useMenuGroup(rest)\n const context = useMemo(() => ({ getLabelProps }), [getLabelProps])\n\n return (\n <MenuGroupContext value={context}>\n <styled.div {...getGroupProps()}>\n {label ? <MenuLabel {...labelProps}>{label}</MenuLabel> : null}\n {children}\n </styled.div>\n </MenuGroupContext>\n )\n },\n \"group\",\n)()\n\nexport interface MenuOptionGroupProps<\n Y extends MenuOptionGroupType = \"checkbox\",\n M extends MenuOptionGroupValue<Y> = MenuOptionGroupValue<Y>,\n>\n extends\n UseMenuOptionGroupProps<Y, M>,\n Omit<MenuGroupProps, \"defaultValue\" | \"onChange\"> {}\n\nexport const MenuOptionGroup = withContext<\"div\", MenuOptionGroupProps>(\n ({\n type: typeProp,\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n ...rest\n }) => {\n const { type, value, onChange } = useMenuOptionGroup({\n type: typeProp,\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const context = useMemo(\n () => ({ type, value, onChange }),\n [type, value, onChange],\n )\n\n return (\n <MenuOptionGroupContext value={context}>\n <MenuGroup {...rest} />\n </MenuOptionGroupContext>\n )\n },\n { name: \"OptionGroup\", slot: [\"group\", \"option\"] },\n)() as GenericsComponent<{\n <\n Y extends MenuOptionGroupType = \"checkbox\",\n M extends MenuOptionGroupValue<Y> = MenuOptionGroupValue<Y>,\n >(\n props: MenuOptionGroupProps<Y, M>,\n ): ReactElement\n}>\n\nexport interface MenuItemProps extends HTMLStyledProps, UseMenuItemProps {}\n\nexport const MenuItem = withContext<\"div\", MenuItemProps>(\n ({ children, ...rest }) => {\n const { subMenuTrigger, getItemProps } = useMenuItem(rest)\n\n return (\n <styled.div {...getItemProps()}>\n {children}\n\n {subMenuTrigger ? (\n <MenuIndicator as={ChevronRightIcon} ms=\"auto\" />\n ) : null}\n </styled.div>\n )\n },\n \"item\",\n)()\n\nexport interface MenuOptionItemProps\n extends HTMLStyledProps, UseMenuOptionItemProps {\n /**\n * The icon to be used in the menu option item.\n */\n icon?: ReactNode\n}\n\nexport const MenuOptionItem = withContext<\"div\", MenuOptionItemProps>(\n ({ children, icon, ...rest }) => {\n const { type, getIndicatorProps, getOptionItemProps } =\n useMenuOptionItem(rest)\n\n return (\n <styled.div {...getOptionItemProps()}>\n <MenuIndicator {...getIndicatorProps()}>\n {icon ||\n (type === \"radio\" ? (\n <CircleSmallIcon fill=\"currentColor\" />\n ) : (\n <CheckIcon />\n ))}\n </MenuIndicator>\n {children}\n </styled.div>\n )\n },\n { name: \"OptionItem\", slot: [\"item\", \"option\"] },\n)()\n\nexport interface MenuIndicatorProps extends HTMLStyledProps {}\n\nexport const MenuIndicator = withContext<\"div\", MenuIndicatorProps>(\n \"div\",\n \"indicator\",\n)()\n\nexport interface MenuCommandProps extends HTMLStyledProps<\"kbd\"> {}\n\nexport const MenuCommand = withContext<\"kbd\", MenuCommandProps>(\n \"kbd\",\n \"command\",\n)()\n\nexport interface MenuSeparatorProps extends HTMLStyledProps<\"hr\"> {}\n\nexport const MenuSeparator = withContext<\"hr\", MenuSeparatorProps>(\n \"hr\",\n \"separator\",\n)(undefined, (props) => {\n const { getSeparatorProps } = useComponentContext()\n\n return getSeparatorProps(props)\n})\n"],"mappings":";;;;;;;;;;;;;;AA6GA,MAAM,EACJ,kBACA,cAAc,kBACd,cACA,qBACA,iBAAiB,qBACjB,aACA,0BACE,oBACF,QACA,SACF;;;;;;AASA,MAAa,YAA+B,UAAU;CACpD,MAAM,CAAC,cAAc,eAAe,sBAAsB,KAAK;CAC/D,MAAM,CACJ,EAAE,iBAAiB,iBAAiB,QAAQ,WAAW,GAAG,gBAC1D,EAAE,UAAU,UAAU,GAAG,UACvB,gBAAgB,aAAa;EAC/B;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,MAAM,EACJ,eACA,aACA,MACA,SACA,kBACA,WACA,iBACA,wBACA,mBACA,iBACA,oBACA,SACA,YACA,gBACA,QACA,aACE,QAAQ;EAAE;EAAU,GAAG;CAAK,CAAC;CACjC,MAAM,qBAAqB,eAClB;EACL,GAAG;EACH,iBACE,oBAAoB,UAAU,iBAAiB;EACjD,WAAW,CAAC,CAAC;EACb;EACA;EACA,QAAQ,WAAW,UAAU,CAAC,GAAG,CAAC,IAAI,KAAA;EACtC;EACA,WACE,cAAc,UAAU,UAAU,qBAAqB;EACzD;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CACA,MAAM,cAAc,eACX;EACL;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CACA,MAAM,kBAAkB,eACf;EACL;EACA;EACA;EACA;EACA;CACF,IACA;EAAC;EAAe;EAAa;EAAoB;EAAY;CAAQ,CACvE;CACA,MAAM,mBAAmB,eAChB;EACL;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;CACF,CACF;CAEA,OACE,oBAAC,cAAD;EAAc,OAAO;EACnB,UAAA,oBAAC,wBAAD;GAAwB,OAAO;GAC7B,UAAA,oBAAC,aAAD;IAAa,OAAO;IAClB,UAAA,oBAAC,iBAAD;KAAiB,OAAO;KACtB,UAAA,oBAAC,kBAAD;MAAkB,OAAO;MACvB,UAAA,oBAACA,aAAD;OAAc,GAAI;OAAqB;MAAuB,CAAA;KAC9C,CAAA;IACH,CAAA;GACN,CAAA;EACS,CAAA;CACZ,CAAA;AAElB;AAIA,MAAa,cAAc,YACzBC,gBACA,SACF,CAAC,CAAC,KAAA,IAAY,UAAU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,KAAA,IAAY,UAAU;CACtB,MAAM,EAAE,sBAAsB,oBAAoB;CAElD,OAAO,kBAAkB,KAAK;AAChC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-menu.js","names":["createContext","noop"],"sources":["../../../../src/components/menu/use-menu.ts"],"sourcesContent":["\"use client\"\n\nimport type { KeyboardEvent, MouseEvent, RefObject } from \"react\"\nimport type { HTMLProps, PropGetter } from \"../../core\"\nimport type { Descendant, Descendants } from \"../../hooks/use-descendants\"\nimport type { UseDisclosureProps } from \"../../hooks/use-disclosure\"\nimport { useCallback, useId, useRef } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { createDescendants } from \"../../hooks/use-descendants\"\nimport { useDisclosure } from \"../../hooks/use-disclosure\"\nimport {\n ariaAttr,\n assignRef,\n createContext,\n cx,\n dataAttr,\n handlerAll,\n isArray,\n isString,\n isTruthyDataAttr,\n mergeRefs,\n noop,\n runKeyAction,\n useUpdateEffect,\n} from \"../../utils\"\n\ntype SubMenuDirection = \"end\" | \"start\"\n\ninterface MenuDescendantProps {\n id: string\n}\ntype MenuDescendant = Descendant<HTMLDivElement, MenuDescendantProps>\n\nconst {\n DescendantsContext: MenuDescendantsContext,\n useDescendant: useMenuDescendant,\n useDescendantRegister: useMenuDescendantRegister,\n useDescendants: useMenuDescendants,\n} = createDescendants<HTMLDivElement, MenuDescendantProps>()\n\nexport { MenuDescendantsContext, useMenuDescendant, useMenuDescendants }\n\ninterface MenuContext extends Pick<\n UseMenuReturn,\n | \"onActiveDescendant\"\n | \"onClose\"\n | \"onCloseSubMenu\"\n | \"onOpen\"\n | \"onSelect\"\n | \"subMenu\"\n | \"subMenuDirection\"\n> {}\n\nconst [MenuContext, useMenuContext] = createContext<MenuContext>({\n name: \"MenuContext\",\n})\n\ninterface MenuGroupContext extends Pick<UseMenuGroupReturn, \"getLabelProps\"> {}\n\nconst [MenuGroupContext, useMenuGroupContext] = createContext<MenuGroupContext>(\n {\n name: \"MenuGroupContext\",\n },\n)\n\ninterface MainMenuContext {\n descendants: Descendants<HTMLDivElement, MenuDescendantProps>\n onActiveDescendant: (descendant?: MenuDescendant) => void\n onCloseRef: RefObject<() => void>\n onSelect: (value?: string, closeOnSelect?: boolean) => void\n closeOnSelect?: boolean\n}\n\nconst [MainMenuContext, useMainMenuContext] = createContext<MainMenuContext>({\n name: \"MainMenuContext\",\n strict: false,\n})\n\ninterface MenuOptionGroupContext {\n type: \"checkbox\" | \"radio\"\n value: string | string[]\n onChange?: (value: string) => void\n}\n\nconst [MenuOptionGroupContext, useMenuOptionGroupContext] =\n createContext<MenuOptionGroupContext>({\n name: \"MenuOptionGroupContext\",\n })\n\nexport {\n MainMenuContext,\n MenuContext,\n MenuGroupContext,\n MenuOptionGroupContext,\n useMainMenuContext,\n useMenuContext,\n useMenuGroupContext,\n useMenuOptionGroupContext,\n}\n\nexport interface UseMenuProps extends Omit<UseDisclosureProps, \"timing\"> {\n /**\n * If `true`, the menu item will be closed when selected.\n *\n * @default true\n */\n closeOnSelect?: boolean\n /**\n * If `true`, the menu will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * The direction of the sub menu.\n *\n * @default 'end'\n */\n subMenuDirection?: SubMenuDirection\n /**\n * Callback invoked when a menu item is selected.\n */\n onSelect?: (value?: string) => void\n}\n\nexport const useMenu = ({\n closeOnSelect,\n defaultOpen,\n disabled = false,\n open: openProp,\n subMenuDirection = \"end\",\n onClose: onCloseProp,\n onOpen: onOpenProp,\n onSelect: onSelectProp,\n}: UseMenuProps = {}) => {\n const triggerId = useId()\n const contentId = useId()\n const descendants = useMenuDescendants()\n const updateRef = useRef<() => void>(noop)\n const onCloseRef = useRef<() => void>(noop)\n const contentRef = useRef<HTMLDivElement>(null)\n const { open, onClose, onOpen } = useDisclosure({\n defaultOpen,\n open: openProp,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n })\n const onCloseSubMenu = useCallback(() => onCloseRef.current(), [])\n const onActiveDescendant = useCallback(\n (\n descendant?: MenuDescendant,\n options: FocusOptions = { preventScroll: true },\n ) => {\n if (!contentRef.current || !descendant || disabled) return\n\n contentRef.current.setAttribute(\"aria-activedescendant\", descendant.id)\n\n descendants.active(descendant, options)\n },\n [descendants, disabled],\n )\n const { mainCloseOnSelect, subMenu, getSubMenuProps, onMainSelect } =\n useSubMenu({\n descendants,\n disabled,\n open,\n subMenuDirection,\n onActiveDescendant,\n onClose,\n onOpen,\n })\n\n closeOnSelect ??= mainCloseOnSelect ?? true\n\n const onSelect = useCallback(\n (value?: string, closeOnSelectProp = closeOnSelect) => {\n if (disabled) return\n\n onSelectProp?.(value)\n onMainSelect?.(value, closeOnSelectProp)\n\n if (!closeOnSelectProp) return\n\n onClose()\n },\n [closeOnSelect, disabled, onClose, onMainSelect, onSelectProp],\n )\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n if (disabled) return\n\n ev.preventDefault()\n\n if (!open) onOpen()\n else onClose()\n },\n [disabled, onClose, onOpen, open],\n )\n\n const onContextMenu = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n if (disabled) return\n\n ev.preventDefault()\n onOpen()\n updateRef.current()\n },\n [disabled, onOpen],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLDivElement>) => {\n if (disabled) return\n\n runKeyAction(ev, {\n ArrowDown: () => {\n onOpen()\n\n setTimeout(() => {\n const descendant = descendants.enabledFirstValue()\n\n onActiveDescendant(descendant)\n })\n },\n ArrowUp: () => {\n onOpen()\n\n setTimeout(() => {\n const descendant = descendants.enabledLastValue()\n\n onActiveDescendant(descendant)\n })\n },\n Enter: () => {\n onOpen()\n\n setTimeout(() => {\n const descendant = descendants.enabledFirstValue()\n\n onActiveDescendant(descendant)\n })\n },\n Space: () => {\n onOpen()\n\n setTimeout(() => {\n const descendant = descendants.enabledFirstValue()\n\n onActiveDescendant(descendant)\n })\n },\n })\n },\n [descendants, disabled, onActiveDescendant, onOpen],\n )\n\n const getTriggerProps: PropGetter = useCallback(\n (props = {}) => ({\n ...getSubMenuProps({\n id: triggerId,\n \"aria-controls\": open ? contentId : undefined,\n \"aria-disabled\": ariaAttr(disabled),\n \"aria-expanded\": open,\n \"aria-haspopup\": \"menu\",\n \"data-trigger\": dataAttr(true),\n role: \"button\",\n tabIndex: disabled ? -1 : 0,\n ...props,\n onClick: handlerAll(props.onClick, onClick),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }),\n }),\n [contentId, disabled, getSubMenuProps, onClick, onKeyDown, open, triggerId],\n )\n\n const getContextTriggerProps: PropGetter = useCallback(\n (props = {}) => ({\n id: triggerId,\n \"aria-controls\": open ? contentId : undefined,\n \"aria-disabled\": ariaAttr(disabled),\n \"aria-expanded\": open,\n \"aria-haspopup\": \"menu\",\n \"data-trigger\": dataAttr(true),\n role: \"application\",\n ...props,\n onContextMenu: handlerAll(props.onContextMenu, onContextMenu),\n }),\n [contentId, disabled, onContextMenu, open, triggerId],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, \"aria-labelledby\": ariaLabelledby, ...props } = {}) => ({\n id: contentId,\n \"aria-labelledby\": cx(ariaLabelledby, triggerId),\n role: \"menu\",\n ...props,\n ref: mergeRefs(ref, contentRef),\n }),\n [contentId, triggerId],\n )\n\n const getSeparatorProps: PropGetter = useCallback(\n (props) => ({ role: \"separator\", ...props }),\n [],\n )\n\n return {\n closeOnSelect,\n descendants,\n open,\n subMenu,\n subMenuDirection,\n updateRef,\n getContentProps,\n getContextTriggerProps,\n getSeparatorProps,\n getTriggerProps,\n onActiveDescendant,\n onClose,\n onCloseRef,\n onCloseSubMenu,\n onOpen,\n onSelect,\n }\n}\n\nexport type UseMenuReturn = ReturnType<typeof useMenu>\n\nexport interface UseSubMenuProps extends Omit<\n Required<UseDisclosureProps>,\n \"defaultOpen\" | \"timing\"\n> {\n descendants: Descendants<HTMLDivElement, MenuDescendantProps>\n onActiveDescendant: (descendant?: MenuDescendant) => void\n disabled?: boolean\n subMenuDirection?: SubMenuDirection\n}\n\nexport const useSubMenu = ({\n descendants,\n disabled = false,\n open,\n subMenuDirection = \"end\",\n onActiveDescendant,\n onClose,\n onOpen,\n}: UseSubMenuProps) => {\n const uuid = useId()\n const {\n closeOnSelect: mainCloseOnSelect,\n descendants: mainDescendants,\n onActiveDescendant: onActiveMainDescendant,\n onCloseRef,\n onSelect: onMainSelect,\n } = useMainMenuContext() ?? {}\n const subMenu = !!mainDescendants && !!onActiveMainDescendant\n const createRegister = useMenuDescendantRegister(mainDescendants)\n const triggerRef = useRef<HTMLDivElement>(null)\n\n const dataDisabled = useCallback((node?: HTMLDivElement | null) => {\n node ??= triggerRef.current\n\n if (!node) return false\n\n const dataDisabled = isTruthyDataAttr(node.getAttribute(\"data-disabled\"))\n\n return dataDisabled\n }, [])\n\n const ariaDisabled = useCallback((node?: HTMLDivElement | null) => {\n node ??= triggerRef.current\n\n if (!node) return false\n\n const ariaDisabled = isTruthyDataAttr(node.getAttribute(\"aria-disabled\"))\n\n return ariaDisabled\n }, [])\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n if (!subMenu) return\n\n ev.defaultPrevented = disabled || dataDisabled() || ariaDisabled()\n },\n [ariaDisabled, dataDisabled, disabled, subMenu],\n )\n\n const onMouseEnter = useCallback(() => {\n if (!subMenu || disabled || dataDisabled() || ariaDisabled()) return\n\n onOpen()\n }, [ariaDisabled, dataDisabled, disabled, onOpen, subMenu])\n\n const onMouseMove = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n if (!subMenu || disabled || dataDisabled() || ariaDisabled()) return\n\n const descendant = descendants.value(triggerRef.current)\n\n onActiveMainDescendant(descendant)\n\n ev.defaultPrevented = true\n },\n [\n ariaDisabled,\n dataDisabled,\n descendants,\n disabled,\n onActiveMainDescendant,\n subMenu,\n ],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLDivElement>) => {\n if (!subMenu || disabled) return\n\n const currentDescendant = open ? descendants : mainDescendants\n const onActiveCurrentDescendant = open\n ? onActiveDescendant\n : onActiveMainDescendant\n\n runKeyAction(ev, {\n ArrowDown: () => {\n const descendant = currentDescendant.enabledNextValue(\n triggerRef.current,\n )\n\n onActiveCurrentDescendant(descendant)\n\n ev.defaultPrevented = true\n },\n ArrowUp: () => {\n const descendant = currentDescendant.enabledPrevValue(\n triggerRef.current,\n )\n\n onActiveCurrentDescendant(descendant)\n\n ev.defaultPrevented = true\n },\n End: () => {\n const descendant = currentDescendant.enabledLastValue()\n\n onActiveCurrentDescendant(descendant)\n\n ev.defaultPrevented = true\n },\n Home: () => {\n const descendant = currentDescendant.enabledFirstValue()\n\n onActiveCurrentDescendant(descendant)\n\n ev.defaultPrevented = true\n },\n [subMenuDirection === \"end\" ? \"ArrowRight\" : \"ArrowLeft\"]: () => {\n onOpen()\n\n setTimeout(() => {\n const descendant = descendants.enabledFirstValue()\n\n onActiveDescendant(descendant)\n })\n\n ev.defaultPrevented = true\n },\n })\n },\n [\n subMenu,\n disabled,\n open,\n descendants,\n mainDescendants,\n onActiveDescendant,\n onActiveMainDescendant,\n subMenuDirection,\n onOpen,\n ],\n )\n\n assignRef(onCloseRef, onClose)\n\n const getSubMenuProps: PropGetter = useCallback(\n ({ id = uuid, ref, ...props } = {}) => {\n const getDisabled = (node: HTMLDivElement) =>\n disabled || dataDisabled(node) || ariaDisabled(node)\n const register = createRegister({ id, disabled: getDisabled })\n\n return {\n role: subMenu ? \"menuitem\" : \"button\",\n ...props,\n ref: mergeRefs(ref, triggerRef, register),\n onClick: handlerAll(onClick, props.onClick),\n onKeyDown: handlerAll(onKeyDown, props.onKeyDown),\n onMouseEnter: handlerAll(onMouseEnter, props.onMouseEnter),\n onMouseMove: handlerAll(onMouseMove, props.onMouseMove),\n }\n },\n [\n uuid,\n subMenu,\n createRegister,\n onClick,\n onKeyDown,\n onMouseEnter,\n onMouseMove,\n disabled,\n dataDisabled,\n ariaDisabled,\n ],\n )\n\n return { mainCloseOnSelect, subMenu, getSubMenuProps, onMainSelect }\n}\n\nexport type UseSubMenuReturn = ReturnType<typeof useSubMenu>\n\nexport interface UseMenuGroupProps extends HTMLProps {}\n\nexport const useMenuGroup = ({\n \"aria-labelledby\": ariaLabelledbyProp,\n ...rest\n}: UseMenuGroupProps) => {\n const labelId = useId()\n\n const getGroupProps: PropGetter = useCallback(\n ({ \"aria-labelledby\": ariaLabelledby, ...props } = {}) =>\n mergeProps(\n {\n \"aria-labelledby\": cx(ariaLabelledbyProp, ariaLabelledby, labelId),\n role: \"group\",\n },\n rest,\n props,\n )(),\n [ariaLabelledbyProp, labelId, rest],\n )\n\n const getLabelProps: PropGetter<\"span\"> = useCallback(\n (props) => ({ id: labelId, role: \"presentation\", ...props }),\n [labelId],\n )\n\n return { getGroupProps, getLabelProps }\n}\n\nexport type UseMenuGroupReturn = ReturnType<typeof useMenuGroup>\n\nexport interface UseMenuItemProps extends HTMLProps {\n /**\n * If `true`, the menu item will be closed when selected.\n */\n closeOnSelect?: boolean\n /**\n * If `true`, the menu item will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * The value of the menu item.\n */\n value?: string\n}\n\nexport const useMenuItem = ({\n id,\n \"aria-disabled\": ariaDisabled,\n \"data-disabled\": dataDisabled,\n \"data-trigger\": dataTrigger,\n closeOnSelect,\n disabled = false,\n value,\n ...rest\n}: UseMenuItemProps) => {\n const trigger = isTruthyDataAttr(dataTrigger)\n const {\n subMenu,\n subMenuDirection,\n onActiveDescendant,\n onClose,\n onCloseSubMenu,\n onSelect,\n } = useMenuContext()\n const uuid = useId()\n const itemRef = useRef<HTMLDivElement>(null)\n const subMenuTrigger = subMenu && trigger\n\n id ??= uuid\n\n const { descendants, register } = useMenuDescendant({\n id,\n disabled: disabled || subMenuTrigger,\n })\n\n const onActive = useCallback(() => {\n if (disabled) return\n\n const descendant = descendants.value(itemRef.current)\n\n onActiveDescendant(descendant)\n }, [descendants, disabled, onActiveDescendant])\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLDivElement>) => {\n runKeyAction(ev, {\n ArrowDown: () => {\n const descendant = descendants.enabledNextValue(itemRef.current)\n\n onActiveDescendant(descendant)\n },\n ArrowUp: () => {\n const descendant = descendants.enabledPrevValue(itemRef.current)\n\n onActiveDescendant(descendant)\n },\n End: () => {\n const descendant = descendants.enabledLastValue()\n\n onActiveDescendant(descendant)\n },\n Enter: () => onSelect(value, closeOnSelect),\n Home: () => {\n const descendant = descendants.enabledFirstValue()\n\n onActiveDescendant(descendant)\n },\n Space: () => onSelect(value, closeOnSelect),\n [subMenuDirection === \"end\" ? \"ArrowLeft\" : \"ArrowRight\"]: () => {\n if (!subMenu) return\n\n onClose()\n\n const descendant = descendants.firstValue()\n\n descendant?.node.focus()\n },\n })\n },\n [\n closeOnSelect,\n descendants,\n onActiveDescendant,\n onClose,\n onSelect,\n subMenu,\n subMenuDirection,\n value,\n ],\n )\n\n const getItemProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => {\n const {\n onClick: restOnClick,\n onFocus: restOnFocus,\n onKeyDown: restOnKeyDown,\n onMouseMove: restOnMouseMove,\n ...restProps\n } = rest\n const {\n onClick: propsOnClick,\n onFocus: propsOnFocus,\n onKeyDown: propsOnKeyDown,\n onMouseMove: propsOnMouseMove,\n ...itemProps\n } = props\n\n return mergeProps(\n {\n id,\n \"aria-disabled\": ariaDisabled ?? ariaAttr(disabled),\n \"data-disabled\": dataDisabled ?? dataAttr(disabled),\n role: \"menuitem\",\n tabIndex: -1,\n },\n restProps,\n itemProps,\n {\n ref: mergeRefs(ref, itemRef, register),\n onClick: handlerAll(propsOnClick, restOnClick, () =>\n onSelect(value, closeOnSelect),\n ),\n onFocus: handlerAll(propsOnFocus, restOnFocus, onActive),\n onKeyDown: handlerAll(propsOnKeyDown, restOnKeyDown, onKeyDown),\n onMouseMove: handlerAll(propsOnMouseMove, restOnMouseMove, () => {\n onCloseSubMenu()\n onActive()\n }),\n },\n )()\n },\n [\n id,\n ariaDisabled,\n disabled,\n dataDisabled,\n rest,\n register,\n onActive,\n onKeyDown,\n onSelect,\n value,\n closeOnSelect,\n onCloseSubMenu,\n ],\n )\n\n return {\n subMenuTrigger,\n getItemProps,\n }\n}\n\nexport type UseMenuItemReturn = ReturnType<typeof useMenuItem>\n\nexport type MenuOptionGroupType = \"checkbox\" | \"radio\"\nexport type MenuOptionGroupValue<Y extends MenuOptionGroupType> =\n Y extends \"checkbox\" ? string[] : string\n\nexport interface UseMenuOptionGroupProps<\n Y extends MenuOptionGroupType = \"checkbox\",\n M extends MenuOptionGroupValue<Y> = MenuOptionGroupValue<Y>,\n> {\n /**\n * The initial value of the menu item group.\n */\n defaultValue?: M\n /**\n * The type of the menu option group.\n */\n type?: Y\n /**\n * The value of the menu item group.\n */\n value?: M\n /**\n * The callback fired when any children checkbox is checked or unchecked.\n */\n onChange?: (value: M) => void\n}\n\nexport const useMenuOptionGroup = <\n Y extends \"checkbox\" | \"radio\" = \"checkbox\",\n M extends Y extends \"checkbox\" ? string[] : string = Y extends \"checkbox\"\n ? string[]\n : string,\n>({\n type = \"checkbox\" as Y,\n defaultValue = (type === \"checkbox\" ? [] : \"\") as M,\n value: valueProp,\n onChange: onChangeProp,\n}: UseMenuOptionGroupProps<Y, M>) => {\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const radio = type === \"radio\"\n\n const onChange = useCallback(\n (selectedValue: string) => {\n setValue((prev) => {\n if (radio && isString(prev)) return selectedValue as M\n else if (!radio && isArray(prev))\n return (\n prev.includes(selectedValue)\n ? prev.filter((value) => value !== selectedValue)\n : prev.concat(selectedValue)\n ) as M\n else return prev\n })\n },\n [radio, setValue],\n )\n\n useUpdateEffect(() => {\n setValue(valueProp!)\n }, [valueProp])\n\n return {\n type,\n value,\n onChange,\n }\n}\n\nexport type UseMenuOptionGroupReturn = ReturnType<typeof useMenuOptionGroup>\n\nexport interface UseMenuOptionItemProps extends UseMenuItemProps {\n /**\n * The value of the menu option item.\n */\n value: string\n}\n\nexport const useMenuOptionItem = ({\n disabled,\n value,\n ...rest\n}: UseMenuOptionItemProps) => {\n const { type, value: selectedValue, onChange } = useMenuOptionGroupContext()\n const { getItemProps } = useMenuItem({ disabled, value, ...rest })\n const radio = type === \"radio\" && isString(selectedValue)\n const checkbox = type === \"checkbox\" && isArray(selectedValue)\n const selected = radio\n ? value === selectedValue\n : checkbox\n ? selectedValue.includes(value)\n : false\n\n const getIndicatorProps: PropGetter = useCallback(\n ({ style, ...props } = {}) => ({\n style: { opacity: selected ? 1 : 0, ...style },\n ...props,\n }),\n [selected],\n )\n\n const getOptionItemProps: PropGetter = useCallback(\n (props = {}) =>\n getItemProps({\n role: radio ? \"menuitemradio\" : \"menuitemcheckbox\",\n ...props,\n onClick: handlerAll(props.onClick, () =>\n !disabled ? onChange?.(value) : noop,\n ),\n }),\n [disabled, getItemProps, onChange, radio, value],\n )\n\n return {\n type,\n selected,\n getIndicatorProps,\n getOptionItemProps,\n }\n}\n\nexport type UseMenuOptionItemReturn = ReturnType<typeof useMenuOptionItem>\n"],"mappings":";;;;;;;;;;;;AAkCA,MAAM,EACJ,oBAAoB,wBACpB,eAAe,mBACf,uBAAuB,2BACvB,gBAAgB,uBACd,kBAAuD;AAe3D,MAAM,CAAC,aAAa,kBAAkBA,gBAA2B,EAC/D,MAAM,cACR,CAAC;AAID,MAAM,CAAC,kBAAkB,uBAAuBA,gBAC9C,EACE,MAAM,mBACR,CACF;AAUA,MAAM,CAAC,iBAAiB,sBAAsBA,gBAA+B;CAC3E,MAAM;CACN,QAAQ;AACV,CAAC;AAQD,MAAM,CAAC,wBAAwB,6BAC7BA,gBAAsC,EACpC,MAAM,yBACR,CAAC;AAsCH,MAAa,WAAW,EACtB,eACA,aACA,WAAW,OACX,MAAM,UACN,mBAAmB,OACnB,SAAS,aACT,QAAQ,YACR,UAAU,iBACM,CAAC,MAAM;CACvB,MAAM,YAAY,MAAM;CACxB,MAAM,YAAY,MAAM;CACxB,MA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AK,CAAC;CACjE,MAAM,QAAQ,SAAS,YAAA,GAAA,cAAA,SAAA,CAAoB,aAAa;CACxD,MAAM,WAAW,SAAS,eAAA,GAAA,cAAA,QAAA,CAAsB,aAAa;CAC7D,MAAM,WAAW,QACb,UAAU,gBACV,WACE,cAAc,SAAS,KAAK,IAC5B;CAsBN,OAAO;EACL;EACA;EACA,mBAvBoC,aACnC,EAAE,OAAO,GAAG,UAAU,CAAC,OAAO;GAC7B,OAAO;IAAE,SAAS,WAAW,IAAI;IAAG,GAAG;GAAM;GAC7C,GAAG;EACL,IACA,CAAC,QAAQ,CAkBO;EAChB,oBAhBqC,aACpC,QAAQ,CAAC,MACR,aAAa;GACX,MAAM,QAAQ,kBAAkB;GAChC,GAAG;GACH,UAAA,GAAA,cAAA,WAAA,CAAoB,MAAM,eACxB,CAAC,WAAW,WAAW,KAAK,IAAIA,cAAAA,IAClC;EACF,CAAC,GACH;GAAC;GAAU;GAAc;GAAU;GAAO;EAAK,CAO9B;CACnB;AACF"}
1
+ {"version":3,"file":"use-menu.js","names":["createContext","noop"],"sources":["../../../../src/components/menu/use-menu.ts"],"sourcesContent":["\"use client\"\n\nimport type { KeyboardEvent, MouseEvent, RefObject } from \"react\"\nimport type { HTMLProps, PropGetter } from \"../../core\"\nimport type { Descendant, Descendants } from \"../../hooks/use-descendants\"\nimport type { UseDisclosureProps } from \"../../hooks/use-disclosure\"\nimport { useCallback, useId, useRef } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { createDescendants } from \"../../hooks/use-descendants\"\nimport { useDisclosure } from \"../../hooks/use-disclosure\"\nimport {\n ariaAttr,\n assignRef,\n createContext,\n cx,\n dataAttr,\n handlerAll,\n isArray,\n isString,\n isTruthyDataAttr,\n mergeRefs,\n noop,\n runKeyAction,\n useUpdateEffect,\n} from \"../../utils\"\n\ntype SubMenuDirection = \"end\" | \"start\"\n\ninterface MenuDescendantProps {\n id: string\n}\ntype MenuDescendant = Descendant<HTMLDivElement, MenuDescendantProps>\n\nconst {\n DescendantsContext: MenuDescendantsContext,\n useDescendant: useMenuDescendant,\n useDescendantRegister: useMenuDescendantRegister,\n useDescendants: useMenuDescendants,\n} = createDescendants<HTMLDivElement, MenuDescendantProps>()\n\nexport { MenuDescendantsContext, useMenuDescendant, useMenuDescendants }\n\ninterface MenuContext extends Pick<\n UseMenuReturn,\n | \"onActiveDescendant\"\n | \"onClose\"\n | \"onCloseSubMenu\"\n | \"onOpen\"\n | \"onSelect\"\n | \"subMenu\"\n | \"subMenuDirection\"\n> {}\n\nconst [MenuContext, useMenuContext] = createContext<MenuContext>({\n name: \"MenuContext\",\n})\n\ninterface MenuGroupContext extends Pick<UseMenuGroupReturn, \"getLabelProps\"> {}\n\nconst [MenuGroupContext, useMenuGroupContext] = createContext<MenuGroupContext>(\n {\n name: \"MenuGroupContext\",\n },\n)\n\ninterface MainMenuContext {\n descendants: Descendants<HTMLDivElement, MenuDescendantProps>\n onActiveDescendant: (descendant?: MenuDescendant) => void\n onCloseRef: RefObject<() => void>\n onSelect: (value?: string, closeOnSelect?: boolean) => void\n closeOnSelect?: boolean\n}\n\nconst [MainMenuContext, useMainMenuContext] = createContext<MainMenuContext>({\n name: \"MainMenuContext\",\n strict: false,\n})\n\ninterface MenuOptionGroupContext {\n type: \"checkbox\" | \"radio\"\n value: string | string[]\n onChange?: (value: string) => void\n}\n\nconst [MenuOptionGroupContext, useMenuOptionGroupContext] =\n createContext<MenuOptionGroupContext>({\n name: \"MenuOptionGroupContext\",\n })\n\nexport {\n MainMenuContext,\n MenuContext,\n MenuGroupContext,\n MenuOptionGroupContext,\n useMainMenuContext,\n useMenuContext,\n useMenuGroupContext,\n useMenuOptionGroupContext,\n}\n\nexport interface UseMenuProps extends Omit<UseDisclosureProps, \"timing\"> {\n /**\n * If `true`, the menu item will be closed when selected.\n *\n * @default true\n */\n closeOnSelect?: boolean\n /**\n * If `true`, the menu will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * The direction of the sub menu.\n *\n * @default 'end'\n */\n subMenuDirection?: SubMenuDirection\n /**\n * Callback invoked when a menu item is selected.\n */\n onSelect?: (value?: string) => void\n}\n\nexport const useMenu = ({\n closeOnSelect,\n defaultOpen,\n disabled = false,\n open: openProp,\n subMenuDirection = \"end\",\n onClose: onCloseProp,\n onOpen: onOpenProp,\n onSelect: onSelectProp,\n}: UseMenuProps = {}) => {\n const triggerId = useId()\n const contentId = useId()\n const descendants = useMenuDescendants()\n const updateRef = useRef<() => void>(noop)\n const onCloseRef = useRef<() => void>(noop)\n const contentRef = useRef<HTMLDivElement>(null)\n const { open, onClose, onOpen } = useDisclosure({\n defaultOpen,\n open: openProp,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n })\n const onCloseSubMenu = useCallback(() => onCloseRef.current(), [])\n const onActiveDescendant = useCallback(\n (\n descendant?: MenuDescendant,\n options: FocusOptions = { preventScroll: true },\n ) => {\n if (!contentRef.current || !descendant || disabled) return\n\n contentRef.current.setAttribute(\"aria-activedescendant\", descendant.id)\n\n descendants.active(descendant, options)\n },\n [descendants, disabled],\n )\n const { mainCloseOnSelect, subMenu, getSubMenuProps, onMainSelect } =\n useSubMenu({\n descendants,\n disabled,\n open,\n subMenuDirection,\n onActiveDescendant,\n onClose,\n onOpen,\n })\n\n closeOnSelect ??= mainCloseOnSelect ?? true\n\n const onSelect = useCallback(\n (value?: string, closeOnSelectProp = closeOnSelect) => {\n if (disabled) return\n\n onSelectProp?.(value)\n onMainSelect?.(value, closeOnSelectProp)\n\n if (!closeOnSelectProp) return\n\n onClose()\n },\n [closeOnSelect, disabled, onClose, onMainSelect, onSelectProp],\n )\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n if (disabled) return\n\n ev.preventDefault()\n\n if (!open) onOpen()\n else onClose()\n },\n [disabled, onClose, onOpen, open],\n )\n\n const onContextMenu = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n if (disabled) return\n\n ev.preventDefault()\n onOpen()\n updateRef.current()\n },\n [disabled, onOpen],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLDivElement>) => {\n if (disabled) return\n\n runKeyAction(ev, {\n ArrowDown: () => {\n onOpen()\n\n setTimeout(() => {\n const descendant = descendants.enabledFirstValue()\n\n onActiveDescendant(descendant)\n })\n },\n ArrowUp: () => {\n onOpen()\n\n setTimeout(() => {\n const descendant = descendants.enabledLastValue()\n\n onActiveDescendant(descendant)\n })\n },\n Enter: () => {\n onOpen()\n\n setTimeout(() => {\n const descendant = descendants.enabledFirstValue()\n\n onActiveDescendant(descendant)\n })\n },\n Space: () => {\n onOpen()\n\n setTimeout(() => {\n const descendant = descendants.enabledFirstValue()\n\n onActiveDescendant(descendant)\n })\n },\n })\n },\n [descendants, disabled, onActiveDescendant, onOpen],\n )\n\n const getTriggerProps: PropGetter = useCallback(\n (props = {}) => ({\n ...getSubMenuProps({\n id: triggerId,\n \"aria-controls\": open ? contentId : undefined,\n \"aria-disabled\": ariaAttr(disabled),\n \"aria-expanded\": open,\n \"aria-haspopup\": \"menu\",\n \"data-trigger\": dataAttr(true),\n role: \"button\",\n tabIndex: disabled ? -1 : 0,\n ...props,\n onClick: handlerAll(props.onClick, onClick),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }),\n }),\n [contentId, disabled, getSubMenuProps, onClick, onKeyDown, open, triggerId],\n )\n\n const getContextTriggerProps: PropGetter = useCallback(\n (props = {}) => ({\n id: triggerId,\n \"aria-controls\": open ? contentId : undefined,\n \"aria-disabled\": ariaAttr(disabled),\n \"aria-expanded\": open,\n \"aria-haspopup\": \"menu\",\n \"data-trigger\": dataAttr(true),\n role: \"application\",\n ...props,\n onContextMenu: handlerAll(props.onContextMenu, onContextMenu),\n }),\n [contentId, disabled, onContextMenu, open, triggerId],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, \"aria-labelledby\": ariaLabelledby, ...props } = {}) => ({\n id: contentId,\n \"aria-labelledby\": cx(ariaLabelledby, triggerId),\n role: \"menu\",\n ...props,\n ref: mergeRefs(ref, contentRef),\n }),\n [contentId, triggerId],\n )\n\n const getSeparatorProps: PropGetter = useCallback(\n (props) => ({ role: \"separator\", ...props }),\n [],\n )\n\n return {\n closeOnSelect,\n descendants,\n open,\n subMenu,\n subMenuDirection,\n updateRef,\n getContentProps,\n getContextTriggerProps,\n getSeparatorProps,\n getTriggerProps,\n onActiveDescendant,\n onClose,\n onCloseRef,\n onCloseSubMenu,\n onOpen,\n onSelect,\n }\n}\n\nexport type UseMenuReturn = ReturnType<typeof useMenu>\n\nexport interface UseSubMenuProps extends Omit<\n Required<UseDisclosureProps>,\n \"defaultOpen\" | \"timing\"\n> {\n descendants: Descendants<HTMLDivElement, MenuDescendantProps>\n onActiveDescendant: (descendant?: MenuDescendant) => void\n disabled?: boolean\n subMenuDirection?: SubMenuDirection\n}\n\nexport const useSubMenu = ({\n descendants,\n disabled = false,\n open,\n subMenuDirection = \"end\",\n onActiveDescendant,\n onClose,\n onOpen,\n}: UseSubMenuProps) => {\n const uuid = useId()\n const {\n closeOnSelect: mainCloseOnSelect,\n descendants: mainDescendants,\n onActiveDescendant: onActiveMainDescendant,\n onCloseRef,\n onSelect: onMainSelect,\n } = useMainMenuContext() ?? {}\n const subMenu = !!mainDescendants && !!onActiveMainDescendant\n const createRegister = useMenuDescendantRegister(mainDescendants)\n const triggerRef = useRef<HTMLDivElement>(null)\n\n const dataDisabled = useCallback((node?: HTMLDivElement | null) => {\n node ??= triggerRef.current\n\n if (!node) return false\n\n const dataDisabled = isTruthyDataAttr(node.getAttribute(\"data-disabled\"))\n\n return dataDisabled\n }, [])\n\n const ariaDisabled = useCallback((node?: HTMLDivElement | null) => {\n node ??= triggerRef.current\n\n if (!node) return false\n\n const ariaDisabled = isTruthyDataAttr(node.getAttribute(\"aria-disabled\"))\n\n return ariaDisabled\n }, [])\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n if (!subMenu) return\n\n ev.defaultPrevented = disabled || dataDisabled() || ariaDisabled()\n },\n [ariaDisabled, dataDisabled, disabled, subMenu],\n )\n\n const onMouseEnter = useCallback(() => {\n if (!subMenu || disabled || dataDisabled() || ariaDisabled()) return\n\n onOpen()\n }, [ariaDisabled, dataDisabled, disabled, onOpen, subMenu])\n\n const onMouseMove = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n if (!subMenu || disabled || dataDisabled() || ariaDisabled()) return\n\n const descendant = descendants.value(triggerRef.current)\n\n onActiveMainDescendant(descendant)\n\n ev.defaultPrevented = true\n },\n [\n ariaDisabled,\n dataDisabled,\n descendants,\n disabled,\n onActiveMainDescendant,\n subMenu,\n ],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLDivElement>) => {\n if (!subMenu || disabled) return\n\n const currentDescendant = open ? descendants : mainDescendants\n const onActiveCurrentDescendant = open\n ? onActiveDescendant\n : onActiveMainDescendant\n\n runKeyAction(ev, {\n ArrowDown: () => {\n const descendant = currentDescendant.enabledNextValue(\n triggerRef.current,\n )\n\n onActiveCurrentDescendant(descendant)\n\n ev.defaultPrevented = true\n },\n ArrowUp: () => {\n const descendant = currentDescendant.enabledPrevValue(\n triggerRef.current,\n )\n\n onActiveCurrentDescendant(descendant)\n\n ev.defaultPrevented = true\n },\n End: () => {\n const descendant = currentDescendant.enabledLastValue()\n\n onActiveCurrentDescendant(descendant)\n\n ev.defaultPrevented = true\n },\n Home: () => {\n const descendant = currentDescendant.enabledFirstValue()\n\n onActiveCurrentDescendant(descendant)\n\n ev.defaultPrevented = true\n },\n [subMenuDirection === \"end\" ? \"ArrowRight\" : \"ArrowLeft\"]: () => {\n onOpen()\n\n setTimeout(() => {\n const descendant = descendants.enabledFirstValue()\n\n onActiveDescendant(descendant)\n })\n\n ev.defaultPrevented = true\n },\n })\n },\n [\n subMenu,\n disabled,\n open,\n descendants,\n mainDescendants,\n onActiveDescendant,\n onActiveMainDescendant,\n subMenuDirection,\n onOpen,\n ],\n )\n\n assignRef(onCloseRef, onClose)\n\n const getSubMenuProps: PropGetter = useCallback(\n ({ id = uuid, ref, ...props } = {}) => {\n const getDisabled = (node: HTMLDivElement) =>\n disabled || dataDisabled(node) || ariaDisabled(node)\n const register = createRegister({ id, disabled: getDisabled })\n\n return {\n role: subMenu ? \"menuitem\" : \"button\",\n ...props,\n ref: mergeRefs(ref, triggerRef, register),\n onClick: handlerAll(onClick, props.onClick),\n onKeyDown: handlerAll(onKeyDown, props.onKeyDown),\n onMouseEnter: handlerAll(onMouseEnter, props.onMouseEnter),\n onMouseMove: handlerAll(onMouseMove, props.onMouseMove),\n }\n },\n [\n uuid,\n subMenu,\n createRegister,\n onClick,\n onKeyDown,\n onMouseEnter,\n onMouseMove,\n disabled,\n dataDisabled,\n ariaDisabled,\n ],\n )\n\n return { mainCloseOnSelect, subMenu, getSubMenuProps, onMainSelect }\n}\n\nexport type UseSubMenuReturn = ReturnType<typeof useSubMenu>\n\nexport interface UseMenuGroupProps extends HTMLProps {}\n\nexport const useMenuGroup = ({\n \"aria-labelledby\": ariaLabelledbyProp,\n ...rest\n}: UseMenuGroupProps) => {\n const labelId = useId()\n\n const getGroupProps: PropGetter = useCallback(\n ({ \"aria-labelledby\": ariaLabelledby, ...props } = {}) =>\n mergeProps(\n {\n \"aria-labelledby\": cx(ariaLabelledbyProp, ariaLabelledby, labelId),\n role: \"group\",\n },\n rest,\n props,\n )(),\n [ariaLabelledbyProp, labelId, rest],\n )\n\n const getLabelProps: PropGetter<\"span\"> = useCallback(\n (props) => ({ id: labelId, role: \"presentation\", ...props }),\n [labelId],\n )\n\n return { getGroupProps, getLabelProps }\n}\n\nexport type UseMenuGroupReturn = ReturnType<typeof useMenuGroup>\n\nexport interface UseMenuItemProps extends HTMLProps {\n /**\n * If `true`, the menu item will be closed when selected.\n */\n closeOnSelect?: boolean\n /**\n * If `true`, the menu item will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * The value of the menu item.\n */\n value?: string\n}\n\nexport const useMenuItem = ({\n id,\n \"aria-disabled\": ariaDisabled,\n \"data-disabled\": dataDisabled,\n \"data-trigger\": dataTrigger,\n closeOnSelect,\n disabled = false,\n value,\n ...rest\n}: UseMenuItemProps) => {\n const trigger = isTruthyDataAttr(dataTrigger)\n const {\n subMenu,\n subMenuDirection,\n onActiveDescendant,\n onClose,\n onCloseSubMenu,\n onSelect,\n } = useMenuContext()\n const uuid = useId()\n const itemRef = useRef<HTMLDivElement>(null)\n const subMenuTrigger = subMenu && trigger\n\n id ??= uuid\n\n const { descendants, register } = useMenuDescendant({\n id,\n disabled: disabled || subMenuTrigger,\n })\n\n const onActive = useCallback(() => {\n if (disabled) return\n\n const descendant = descendants.value(itemRef.current)\n\n onActiveDescendant(descendant)\n }, [descendants, disabled, onActiveDescendant])\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLDivElement>) => {\n runKeyAction(ev, {\n ArrowDown: () => {\n const descendant = descendants.enabledNextValue(itemRef.current)\n\n onActiveDescendant(descendant)\n },\n ArrowUp: () => {\n const descendant = descendants.enabledPrevValue(itemRef.current)\n\n onActiveDescendant(descendant)\n },\n End: () => {\n const descendant = descendants.enabledLastValue()\n\n onActiveDescendant(descendant)\n },\n Enter: () => onSelect(value, closeOnSelect),\n Home: () => {\n const descendant = descendants.enabledFirstValue()\n\n onActiveDescendant(descendant)\n },\n Space: () => onSelect(value, closeOnSelect),\n [subMenuDirection === \"end\" ? \"ArrowLeft\" : \"ArrowRight\"]: () => {\n if (!subMenu) return\n\n onClose()\n\n const descendant = descendants.firstValue()\n\n descendant?.node.focus()\n },\n })\n },\n [\n closeOnSelect,\n descendants,\n onActiveDescendant,\n onClose,\n onSelect,\n subMenu,\n subMenuDirection,\n value,\n ],\n )\n\n const getItemProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => {\n const {\n onClick: restOnClick,\n onFocus: restOnFocus,\n onKeyDown: restOnKeyDown,\n onMouseMove: restOnMouseMove,\n ...restProps\n } = rest\n const {\n onClick: propsOnClick,\n onFocus: propsOnFocus,\n onKeyDown: propsOnKeyDown,\n onMouseMove: propsOnMouseMove,\n ...itemProps\n } = props\n\n return mergeProps(\n {\n id,\n \"aria-disabled\": ariaDisabled ?? ariaAttr(disabled),\n \"data-disabled\": dataDisabled ?? dataAttr(disabled),\n role: \"menuitem\",\n tabIndex: -1,\n },\n restProps,\n itemProps,\n {\n ref: mergeRefs(ref, itemRef, register),\n onClick: handlerAll(propsOnClick, restOnClick, () =>\n onSelect(value, closeOnSelect),\n ),\n onFocus: handlerAll(propsOnFocus, restOnFocus, onActive),\n onKeyDown: handlerAll(propsOnKeyDown, restOnKeyDown, onKeyDown),\n onMouseMove: handlerAll(propsOnMouseMove, restOnMouseMove, () => {\n onCloseSubMenu()\n onActive()\n }),\n },\n )()\n },\n [\n id,\n ariaDisabled,\n disabled,\n dataDisabled,\n rest,\n register,\n onActive,\n onKeyDown,\n onSelect,\n value,\n closeOnSelect,\n onCloseSubMenu,\n ],\n )\n\n return {\n subMenuTrigger,\n getItemProps,\n }\n}\n\nexport type UseMenuItemReturn = ReturnType<typeof useMenuItem>\n\nexport type MenuOptionGroupType = \"checkbox\" | \"radio\"\nexport type MenuOptionGroupValue<Y extends MenuOptionGroupType> =\n Y extends \"checkbox\" ? string[] : string\n\nexport interface UseMenuOptionGroupProps<\n Y extends MenuOptionGroupType = \"checkbox\",\n M extends MenuOptionGroupValue<Y> = MenuOptionGroupValue<Y>,\n> {\n /**\n * The initial value of the menu item group.\n */\n defaultValue?: M\n /**\n * The type of the menu option group.\n */\n type?: Y\n /**\n * The value of the menu item group.\n */\n value?: M\n /**\n * The callback fired when any children checkbox is checked or unchecked.\n */\n onChange?: (value: M) => void\n}\n\nexport const useMenuOptionGroup = <\n Y extends \"checkbox\" | \"radio\" = \"checkbox\",\n M extends (Y extends \"checkbox\" ? string[] : string) = Y extends \"checkbox\"\n ? string[]\n : string,\n>({\n type = \"checkbox\" as Y,\n defaultValue = (type === \"checkbox\" ? [] : \"\") as M,\n value: valueProp,\n onChange: onChangeProp,\n}: UseMenuOptionGroupProps<Y, M>) => {\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const radio = type === \"radio\"\n\n const onChange = useCallback(\n (selectedValue: string) => {\n setValue((prev) => {\n if (radio && isString(prev)) return selectedValue as M\n else if (!radio && isArray(prev))\n return (\n prev.includes(selectedValue)\n ? prev.filter((value) => value !== selectedValue)\n : prev.concat(selectedValue)\n ) as M\n else return prev\n })\n },\n [radio, setValue],\n )\n\n useUpdateEffect(() => {\n setValue(valueProp!)\n }, [valueProp])\n\n return {\n type,\n value,\n onChange,\n }\n}\n\nexport type UseMenuOptionGroupReturn = ReturnType<typeof useMenuOptionGroup>\n\nexport interface UseMenuOptionItemProps extends UseMenuItemProps {\n /**\n * The value of the menu option item.\n */\n value: string\n}\n\nexport const useMenuOptionItem = ({\n disabled,\n value,\n ...rest\n}: UseMenuOptionItemProps) => {\n const { type, value: selectedValue, onChange } = useMenuOptionGroupContext()\n const { getItemProps } = useMenuItem({ disabled, value, ...rest })\n const radio = type === \"radio\" && isString(selectedValue)\n const checkbox = type === \"checkbox\" && isArray(selectedValue)\n const selected = radio\n ? value === selectedValue\n : checkbox\n ? selectedValue.includes(value)\n : false\n\n const getIndicatorProps: PropGetter = useCallback(\n ({ style, ...props } = {}) => ({\n style: { opacity: selected ? 1 : 0, ...style },\n ...props,\n }),\n [selected],\n )\n\n const getOptionItemProps: PropGetter = useCallback(\n (props = {}) =>\n getItemProps({\n role: radio ? \"menuitemradio\" : \"menuitemcheckbox\",\n ...props,\n onClick: handlerAll(props.onClick, () =>\n !disabled ? onChange?.(value) : noop,\n ),\n }),\n [disabled, getItemProps, onChange, radio, value],\n )\n\n return {\n type,\n selected,\n getIndicatorProps,\n getOptionItemProps,\n }\n}\n\nexport type UseMenuOptionItemReturn = ReturnType<typeof useMenuOptionItem>\n"],"mappings":";;;;;;;;;;;;AAkCA,MAAM,EACJ,o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AAI,UAAA,GAAA,cAAA,SAAA,CAAkB,IAAI,GAAG,OAAO;QAC/B,IAAI,CAAC,UAAA,GAAA,cAAA,QAAA,CAAiB,IAAI,GAC7B,OACE,KAAK,SAAS,aAAa,IACvB,KAAK,QAAQ,UAAU,UAAU,aAAa,IAC9C,KAAK,OAAO,aAAa;QAE5B,OAAO;EACd,CAAC;CACH,GACA,CAAC,OAAO,QAAQ,CAClB;CAEA,sBAAsB;EACpB,SAAS,SAAU;CACrB,GAAG,CAAC,SAAS,CAAC;CAEd,OAAO;EACL;EACA;EACA;CACF;AACF;AAWA,MAAa,qBAAqB,EAChC,UACA,OACA,GAAG,WACyB;CAC5B,MAAM,EAAE,MAAM,OAAO,eAAe,aAAa,0BAA0B;CAC3E,MAAM,EAAE,iBAAiB,YAAY;EAAE;EAAU;EAAO,GAAG;CAAK,CAAC;CACjE,MAAM,QAAQ,SAAS,YAAA,GAAA,cAAA,SAAA,CAAoB,aAAa;CACxD,MAAM,WAAW,SAAS,eAAA,GAAA,cAAA,QAAA,CAAsB,aAAa;CAC7D,MAAM,WAAW,QACb,UAAU,gBACV,WACE,cAAc,SAAS,KAAK,IAC5B;CAsBN,OAAO;EACL;EACA;EACA,mBAvBoC,aACnC,EAAE,OAAO,GAAG,UAAU,CAAC,OAAO;GAC7B,OAAO;IAAE,SAAS,WAAW,IAAI;IAAG,GAAG;GAAM;GAC7C,GAAG;EACL,IACA,CAAC,QAAQ,CAkBO;EAChB,oBAhBqC,aACpC,QAAQ,CAAC,MACR,aAAa;GACX,MAAM,QAAQ,kBAAkB;GAChC,GAAG;GACH,UAAA,GAAA,cAAA,WAAA,CAAoB,MAAM,eACxB,CAAC,WAAW,WAAW,KAAK,IAAIA,cAAAA,IAClC;EACF,CAAC,GACH;GAAC;GAAU;GAAc;GAAU;GAAO;EAAK,CAO9B;CACnB;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"modal.js","names":["motion"],"sources":["../../../../src/components/modal/modal.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, PropsWithChildren, ReactNode } from \"react\"\nimport type { HTMLProps, HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { ButtonProps } from \"../button\"\nimport type { CloseButtonProps } from \"../close-button\"\nimport type { FocusLockProps } from \"../focus-lock\"\nimport type { HTMLMotionProps, HTMLMotionPropsWithoutAs } from \"../motion\"\nimport type { UsePopupAnimationProps } from \"../popover\"\nimport type { PortalProps } from \"../portal\"\nimport type { ModalStyle } from \"./modal.style\"\nimport type { UseModalProps, UseModalReturn } from \"./use-modal\"\nimport { AnimatePresence } from \"motion/react\"\nimport { useMemo } from \"react\"\nimport { RemoveScroll } from \"react-remove-scroll\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { useValue } from \"../../hooks/use-value\"\nimport { cast, isArray, useSplitChildren, wrapOrPassProps } from \"../../utils\"\nimport { Button } from \"../button\"\nimport { CloseButton } from \"../close-button\"\nimport { fadeVariants } from \"../fade\"\nimport { FocusLock } from \"../focus-lock\"\nimport { motion } from \"../motion\"\nimport { usePopupAnimationProps } from \"../popover\"\nimport { Portal } from \"../portal\"\nimport { modalStyle } from \"./modal.style\"\nimport { useModal } from \"./use-modal\"\n\ninterface ComponentContext\n extends\n Omit<UseModalReturn, \"getRootProps\">,\n UsePopupAnimationProps,\n Pick<ModalRootProps, \"withCloseButton\"> {}\n\nexport interface ModalRootProps\n extends\n Omit<HTMLStyledProps<\"div\">, \"scrollBehavior\" | \"title\">,\n ThemeProps<ModalStyle>,\n Omit<UseModalProps, \"title\">,\n Pick<\n FocusLockProps,\n | \"autoFocus\"\n | \"finalFocusRef\"\n | \"initialFocusRef\"\n | \"lockFocusAcrossFrames\"\n | \"restoreFocus\"\n >,\n UsePopupAnimationProps,\n ShorthandModalContentProps {\n /**\n * Handle zoom or pinch gestures on iOS devices when scroll locking is enabled.\n *\n * @default false.\n */\n allowPinchZoom?: boolean\n /**\n * If `true`, scrolling will be disabled on the `body` when the modal opens.\n *\n * @default true\n */\n blockScrollOnMount?: boolean\n /**\n * The modal trigger to use.\n */\n trigger?: ReactNode\n /**\n * If `true`, display the modal close button.\n *\n * @default true\n */\n withCloseButton?: boolean\n /**\n * If `true`, display the modal overlay.\n *\n * @default true\n */\n withOverlay?: boolean\n /**\n * Props to be forwarded to the portal component.\n */\n portalProps?: Omit<PortalProps, \"children\">\n /**\n * Callback function to run side effects after the modal has closed.\n */\n onCloseComplete?: () => void\n}\n\nconst {\n ComponentContext,\n PropsContext: ModalPropsContext,\n useComponentContext,\n usePropsContext: useModalPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<ModalRootProps, ModalStyle, ComponentContext>(\n \"modal\",\n modalStyle,\n)\n\nexport { ModalPropsContext, useModalPropsContext }\n\n/**\n * `Modal` is a component that is displayed over the main content to focus the user's attention solely on the information.\n *\n * @see https://yamada-ui.com/docs/components/modal\n */\nexport const ModalRoot = withProvider<\"div\", ModalRootProps>(\n ({\n allowPinchZoom = false,\n animationScheme = \"scale\",\n autoFocus,\n blockScrollOnMount = true,\n body,\n cancel,\n children,\n duration,\n finalFocusRef,\n footer,\n header,\n initialFocusRef,\n lockFocusAcrossFrames = true,\n middle,\n restoreFocus,\n success,\n title,\n trigger,\n withCloseButton = true,\n withOverlay = true,\n portalProps,\n onCancel,\n onCloseComplete,\n onMiddle,\n onSuccess,\n ...props\n }) => {\n const [omittedChildren, openTrigger, customOverlay] = useSplitChildren(\n children,\n ModalOpenTrigger,\n ModalOverlay,\n )\n const hasChildren = isArray(omittedChildren) && !!omittedChildren.length\n const { open, getRootProps, ...rest } = useModal(props)\n const customOpenTrigger = trigger ? (\n <ModalOpenTrigger>{trigger}</ModalOpenTrigger>\n ) : null\n const context = useMemo(\n () => ({\n animationScheme,\n duration,\n open,\n withCloseButton,\n ...rest,\n }),\n [animationScheme, duration, open, withCloseButton, rest],\n )\n\n return (\n <ComponentContext value={context}>\n {openTrigger ?? customOpenTrigger}\n\n <AnimatePresence onExitComplete={onCloseComplete}>\n {open ? (\n <Portal {...portalProps}>\n <FocusLock\n autoFocus={autoFocus}\n finalFocusRef={finalFocusRef}\n initialFocusRef={initialFocusRef}\n lockFocusAcrossFrames={lockFocusAcrossFrames}\n restoreFocus={restoreFocus}\n >\n <RemoveScroll\n allowPinchZoom={allowPinchZoom}\n enabled={blockScrollOnMount}\n forwardProps\n >\n <styled.div {...getRootProps()}>\n {customOverlay ?? (withOverlay ? <ModalOverlay /> : null)}\n\n {hasChildren ? (\n omittedChildren\n ) : (\n <ShorthandModalContent\n body={body}\n cancel={cancel}\n footer={footer}\n header={header}\n middle={middle}\n success={success}\n title={title}\n onCancel={onCancel}\n onMiddle={onMiddle}\n onSuccess={onSuccess}\n />\n )}\n </styled.div>\n </RemoveScroll>\n </FocusLock>\n </Portal>\n ) : null}\n </AnimatePresence>\n </ComponentContext>\n )\n },\n \"root\",\n)()\n\nexport interface ModalOpenTriggerProps extends HTMLStyledProps<\"button\"> {}\n\nexport const ModalOpenTrigger = withContext<\"button\", ModalOpenTriggerProps>(\n \"button\",\n { name: \"OpenTrigger\", slot: [\"trigger\", \"open\"] },\n)(undefined, (props) => {\n const { getOpenTriggerProps } = useComponentContext()\n\n return { asChild: true, ...getOpenTriggerProps(props) }\n})\n\nexport interface ModalCloseTriggerProps extends HTMLStyledProps<\"button\"> {}\n\nexport const ModalCloseTrigger = withContext<\"button\", ModalCloseTriggerProps>(\n \"button\",\n { name: \"CloseTrigger\", slot: [\"trigger\", \"close\"] },\n)(undefined, (props) => {\n const { getCloseTriggerProps } = useComponentContext()\n\n return { asChild: true, ...getCloseTriggerProps(props) }\n})\n\nexport interface ModalCloseButtonProps extends CloseButtonProps {}\n\nexport const ModalCloseButton = withContext<\"button\", ModalCloseButtonProps>(\n CloseButton,\n \"closeButton\",\n)(undefined, (props) => {\n const { getCloseButtonProps } = useComponentContext()\n\n return { ...getCloseButtonProps(props) }\n})\n\nexport interface ModalOverlayProps extends HTMLMotionProps {}\n\nexport const ModalOverlay = withContext<\"div\", ModalOverlayProps>((props) => {\n const {\n animationScheme,\n duration: durationProp,\n getOverlayProps,\n } = useComponentContext()\n const duration = useValue(durationProp)\n\n return (\n <motion.div\n custom={{ duration }}\n {...(animationScheme !== \"none\"\n ? {\n animate: \"enter\",\n exit: \"exit\",\n initial: \"exit\",\n variants: fadeVariants,\n }\n : {})}\n {...cast<HTMLMotionProps>(getOverlayProps(cast<HTMLProps>(props)))}\n />\n )\n}, \"overlay\")()\n\nexport interface ModalContentProps\n extends Omit<HTMLMotionProps<\"section\">, \"children\">, PropsWithChildren {}\n\nexport const ModalContent = withContext<\"section\", ModalContentProps>(\n ({ children, ...rest }) => {\n const { animationScheme, duration, withCloseButton, getContentProps } =\n useComponentContext()\n const [omittedChildren, customCloseButton] = useSplitChildren(\n children,\n ModalCloseButton,\n )\n const popupAnimationProps = usePopupAnimationProps({\n animationScheme,\n duration,\n })\n\n return (\n <motion.section\n {...popupAnimationProps}\n {...cast<HTMLMotionPropsWithoutAs<\"section\">>(\n getContentProps(cast<HTMLProps<\"section\">>(rest)),\n )}\n >\n {customCloseButton ?? (withCloseButton ? <ModalCloseButton /> : null)}\n\n {omittedChildren}\n </motion.section>\n )\n },\n \"content\",\n)()\n\ninterface ShorthandModalContentProps {\n /**\n * The modal body to use.\n */\n body?: ModalBodyProps | ReactNode\n /**\n * The modal cancel button to use.\n */\n cancel?: ButtonProps | ReactNode\n /**\n * The modal footer to use.\n */\n footer?: ModalFooterProps | ReactNode\n /**\n * The modal header to use.\n */\n header?: ModalHeaderProps | ReactNode\n /**\n * The modal middle button to use.\n */\n middle?: ButtonProps | ReactNode\n /**\n * The modal success button to use.\n */\n success?: ButtonProps | ReactNode\n /**\n * The modal title to use.\n */\n title?: ModalTitleProps | ReactNode\n /**\n * The callback invoked when cancel button clicked.\n */\n onCancel?: (onClose: () => void) => void\n /**\n * The callback invoked when middle button clicked.\n */\n onMiddle?: (onClose: () => void) => void\n /**\n * The callback invoked when success button clicked.\n */\n onSuccess?: (onClose: () => void) => void\n}\n\nexport const ShorthandModalContent: FC<ShorthandModalContentProps> = ({\n body,\n cancel,\n footer,\n header,\n middle,\n success,\n title,\n onCancel,\n onMiddle,\n onSuccess,\n}) => {\n const { onClose } = useComponentContext()\n const customHeader = wrapOrPassProps(ModalHeader, header)\n const customTitle = wrapOrPassProps(ModalTitle, title)\n const customBody = wrapOrPassProps(ModalBody, body)\n const customFooter = wrapOrPassProps(ModalFooter, footer)\n const customCancel = wrapOrPassProps(Button, cancel, {\n colorScheme: \"mono\",\n variant: \"ghost\",\n onClick: () => (onCancel ? onCancel(onClose) : onClose()),\n })\n const customMiddle = wrapOrPassProps(Button, middle, {\n colorScheme: \"secondary\",\n onClick: () => (onMiddle ? onMiddle(onClose) : onClose()),\n })\n const customSuccess = wrapOrPassProps(Button, success, {\n colorScheme: \"primary\",\n onClick: () => (onSuccess ? onSuccess(onClose) : onClose()),\n })\n\n return (\n <ModalContent>\n {customHeader ??\n (customTitle ? <ModalHeader>{customTitle}</ModalHeader> : null)}\n {customBody}\n {customFooter ??\n (customCancel || customMiddle || customSuccess ? (\n <ModalFooter>\n {customCancel}\n {customMiddle}\n {customSuccess}\n </ModalFooter>\n ) : null)}\n </ModalContent>\n )\n}\n\nexport interface ModalHeaderProps extends HTMLStyledProps<\"header\"> {}\n\nexport const ModalHeader = withContext<\"header\", ModalHeaderProps>(\n \"header\",\n \"header\",\n)(undefined, (props) => {\n const { getHeaderProps } = useComponentContext()\n\n return { ...getHeaderProps(props) }\n})\n\nexport interface ModalTitleProps extends HTMLStyledProps<\"h2\"> {}\n\nexport const ModalTitle = withContext<\"h2\", ModalTitleProps>(\"h2\", \"title\")(\n undefined,\n (props) => {\n const { getTitleProps } = useComponentContext()\n\n return { ...getTitleProps(props) }\n },\n)\n\nexport interface ModalBodyProps extends HTMLStyledProps {}\n\nexport const ModalBody = withContext<\"div\", ModalBodyProps>(\"div\", \"body\")(\n undefined,\n (props) => {\n const { getBodyProps } = useComponentContext()\n\n return { ...getBodyProps(props) }\n },\n)\n\nexport interface ModalFooterProps extends HTMLStyledProps<\"footer\"> {}\n\nexport const ModalFooter = withContext<\"footer\", ModalFooterProps>(\n \"footer\",\n \"footer\",\n)(undefined, (props) => {\n const { getFooterProps } = useComponentContext()\n\n return { ...getFooterProps(props) }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuFA,MAAM,EACJ,kBACA,cAAc,mBACd,qBACA,iBAAiB,sBACjB,aACA,iBACE,oBACF,SACA,UACF;;;;;;AASA,MAAa,YAAY,cACtB,EACC,iBAAiB,OACjB,kBAAkB,SAClB,WACA,qBAAqB,MACrB,MACA,QACA,UACA,UACA,eACA,QACA,QACA,iBACA,wBAAwB,MACxB,QACA,cACA,SACA,OACA,SACA,kBAAkB,MAClB,cAAc,MACd,aACA,UACA,iBACA,UACA,WACA,GAAG,YACC;CACJ,MAAM,CAAC,iBAAiB,aAAa,iBAAiB,iBACpD,UACA,kBACA,YACF;CACA,MAAM,eAAA,GAAA,cAAA,QAAA,CAAsB,eAAe,KAAK,CAAC,CAAC,gBAAgB;CAClE,MAAM,EAAE,MAAM,cAAc,GAAG,SAAS,SAAS,KAAK;CACtD,MAAM,oBAAoB,UACxB,oBAAC,kBAAD,EAAA,UAAmB,QAA0B,CAAA,IAC3C;CACJ,MAAM,UAAU,eACP;EACL;EACA;EACA;EACA;EACA,GAAG;CACL,IACA;EAAC;EAAiB;EAAU;EAAM;EAAiB;CAAI,CACzD;CAEA,OACE,qBAAC,kBAAD;EAAkB,OAAO;YAAzB,CACG,eAAe,mBAEhB,oBAAC,iBAAD;GAAiB,gBAAgB;aAC9B,OACC,oBAAC,QAAD;IAAQ,GAAI;cACV,oBAAC,WAAD;KACa;KACI;KACE;KACM;KACT;eAEd,oBAAC,cAAD;MACkB;MAChB,SAAS;MACT,cAAA;gBAEA,qBAAC,OAAO,KAAR;OAAY,GAAI,aAAa;iBAA7B,CACG,kBAAkB,cAAc,oBAAC,cAAD,CAAe,CAAA,IAAI,OAEnD,cACC,kBAEA,oBAAC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U;CACtB,MAAM,EAAE,mBAAmB,oBAAoB;CAE/C,OAAO,EAAE,GAAG,eAAe,KAAK,EAAE;AACpC,CAAC;AAID,MAAa,aAAa,YAAmC,MAAM,OAAO,CAAC,CACzE,KAAA,IACC,UAAU;CACT,MAAM,EAAE,kBAAkB,oBAAoB;CAE9C,OAAO,EAAE,GAAG,cAAc,KAAK,EAAE;AACnC,CACF;AAIA,MAAa,YAAY,YAAmC,OAAO,MAAM,CAAC,CACxE,KAAA,IACC,UAAU;CACT,MAAM,EAAE,iBAAiB,oBAAoB;CAE7C,OAAO,EAAE,GAAG,aAAa,KAAK,EAAE;AAClC,CACF;AAIA,MAAa,cAAc,YACzB,UACA,QACF,CAAC,CAAC,KAAA,IAAY,UAAU;CACtB,MAAM,EAAE,mBAAmB,oBAAoB;CAE/C,OAAO,EAAE,GAAG,eAAe,KAAK,EAAE;AACpC,CAAC"}
1
+ {"version":3,"file":"modal.js","names":["motion"],"sources":["../../../../src/components/modal/modal.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, PropsWithChildren, ReactNode } from \"react\"\nimport type { HTMLProps, HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { ButtonProps } from \"../button\"\nimport type { CloseButtonProps } from \"../close-button\"\nimport type { FocusLockProps } from \"../focus-lock\"\nimport type { HTMLMotionProps, HTMLMotionPropsWithoutAs } from \"../motion\"\nimport type { UsePopupAnimationProps } from \"../popover\"\nimport type { PortalProps } from \"../portal\"\nimport type { ModalStyle } from \"./modal.style\"\nimport type { UseModalProps, UseModalReturn } from \"./use-modal\"\nimport { AnimatePresence } from \"motion/react\"\nimport { useMemo } from \"react\"\nimport { RemoveScroll } from \"react-remove-scroll\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { useValue } from \"../../hooks/use-value\"\nimport { cast, isArray, useSplitChildren, wrapOrPassProps } from \"../../utils\"\nimport { Button } from \"../button\"\nimport { CloseButton } from \"../close-button\"\nimport { fadeVariants } from \"../fade\"\nimport { FocusLock } from \"../focus-lock\"\nimport { motion } from \"../motion\"\nimport { usePopupAnimationProps } from \"../popover\"\nimport { Portal } from \"../portal\"\nimport { modalStyle } from \"./modal.style\"\nimport { useModal } from \"./use-modal\"\n\ninterface ComponentContext\n extends\n Omit<UseModalReturn, \"getRootProps\">,\n UsePopupAnimationProps,\n Pick<ModalRootProps, \"withCloseButton\"> {}\n\nexport interface ModalRootProps\n extends\n Omit<HTMLStyledProps<\"div\">, \"scrollBehavior\" | \"title\">,\n ThemeProps<ModalStyle>,\n Omit<UseModalProps, \"title\">,\n Pick<\n FocusLockProps,\n | \"autoFocus\"\n | \"finalFocusRef\"\n | \"initialFocusRef\"\n | \"lockFocusAcrossFrames\"\n | \"restoreFocus\"\n >,\n UsePopupAnimationProps,\n ShorthandModalContentProps {\n /**\n * Handle zoom or pinch gestures on iOS devices when scroll locking is enabled.\n *\n * @default false.\n */\n allowPinchZoom?: boolean\n /**\n * If `true`, scrolling will be disabled on the `body` when the modal opens.\n *\n * @default true\n */\n blockScrollOnMount?: boolean\n /**\n * The modal trigger to use.\n */\n trigger?: ReactNode\n /**\n * If `true`, display the modal close button.\n *\n * @default true\n */\n withCloseButton?: boolean\n /**\n * If `true`, display the modal overlay.\n *\n * @default true\n */\n withOverlay?: boolean\n /**\n * Props to be forwarded to the portal component.\n */\n portalProps?: Omit<PortalProps, \"children\">\n /**\n * Callback function to run side effects after the modal has closed.\n */\n onCloseComplete?: () => void\n}\n\nconst {\n ComponentContext,\n PropsContext: ModalPropsContext,\n useComponentContext,\n usePropsContext: useModalPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<ModalRootProps, ModalStyle, ComponentContext>(\n \"modal\",\n modalStyle,\n)\n\nexport { ModalPropsContext, useModalPropsContext }\n\n/**\n * `Modal` is a component that is displayed over the main content to focus the user's attention solely on the information.\n *\n * @see https://yamada-ui.com/docs/components/modal\n */\nexport const ModalRoot = withProvider<\"div\", ModalRootProps>(\n ({\n allowPinchZoom = false,\n animationScheme = \"scale\",\n autoFocus,\n blockScrollOnMount = true,\n body,\n cancel,\n children,\n duration,\n finalFocusRef,\n footer,\n header,\n initialFocusRef,\n lockFocusAcrossFrames = true,\n middle,\n restoreFocus,\n success,\n title,\n trigger,\n withCloseButton = true,\n withOverlay = true,\n portalProps,\n onCancel,\n onCloseComplete,\n onMiddle,\n onSuccess,\n ...props\n }) => {\n const [omittedChildren, openTrigger, customOverlay] = useSplitChildren(\n children,\n ModalOpenTrigger,\n ModalOverlay,\n )\n const hasChildren = isArray(omittedChildren) && !!omittedChildren.length\n const { open, getRootProps, ...rest } = useModal(props)\n const customOpenTrigger = trigger ? (\n <ModalOpenTrigger>{trigger}</ModalOpenTrigger>\n ) : null\n const context = useMemo(\n () => ({\n animationScheme,\n duration,\n open,\n withCloseButton,\n ...rest,\n }),\n [animationScheme, duration, open, withCloseButton, rest],\n )\n\n return (\n <ComponentContext value={context}>\n {openTrigger ?? customOpenTrigger}\n\n <AnimatePresence onExitComplete={onCloseComplete}>\n {open ? (\n <Portal {...portalProps}>\n <FocusLock\n autoFocus={autoFocus}\n finalFocusRef={finalFocusRef}\n initialFocusRef={initialFocusRef}\n lockFocusAcrossFrames={lockFocusAcrossFrames}\n restoreFocus={restoreFocus}\n >\n <RemoveScroll\n allowPinchZoom={allowPinchZoom}\n enabled={blockScrollOnMount}\n forwardProps\n >\n <styled.div {...getRootProps()}>\n {customOverlay ?? (withOverlay ? <ModalOverlay /> : null)}\n\n {hasChildren ? (\n omittedChildren\n ) : (\n <ShorthandModalContent\n body={body}\n cancel={cancel}\n footer={footer}\n header={header}\n middle={middle}\n success={success}\n title={title}\n onCancel={onCancel}\n onMiddle={onMiddle}\n onSuccess={onSuccess}\n />\n )}\n </styled.div>\n </RemoveScroll>\n </FocusLock>\n </Portal>\n ) : null}\n </AnimatePresence>\n </ComponentContext>\n )\n },\n \"root\",\n)()\n\nexport interface ModalOpenTriggerProps extends HTMLStyledProps<\"button\"> {}\n\nexport const ModalOpenTrigger = withContext<\"button\", ModalOpenTriggerProps>(\n \"button\",\n { name: \"OpenTrigger\", slot: [\"trigger\", \"open\"] },\n)(undefined, (props) => {\n const { getOpenTriggerProps } = useComponentContext()\n\n return { asChild: true, ...getOpenTriggerProps(props) }\n})\n\nexport interface ModalCloseTriggerProps extends HTMLStyledProps<\"button\"> {}\n\nexport const ModalCloseTrigger = withContext<\"button\", ModalCloseTriggerProps>(\n \"button\",\n { name: \"CloseTrigger\", slot: [\"trigger\", \"close\"] },\n)(undefined, (props) => {\n const { getCloseTriggerProps } = useComponentContext()\n\n return { asChild: true, ...getCloseTriggerProps(props) }\n})\n\nexport interface ModalCloseButtonProps extends CloseButtonProps {}\n\nexport const ModalCloseButton = withContext<\"button\", ModalCloseButtonProps>(\n CloseButton,\n \"closeButton\",\n)(undefined, (props) => {\n const { getCloseButtonProps } = useComponentContext()\n\n return { ...getCloseButtonProps(props) }\n})\n\nexport interface ModalOverlayProps extends HTMLMotionProps {}\n\nexport const ModalOverlay = withContext<\"div\", ModalOverlayProps>((props) => {\n const {\n animationScheme,\n duration: durationProp,\n getOverlayProps,\n } = useComponentContext()\n const duration = useValue(durationProp)\n\n return (\n <motion.div\n custom={{ duration }}\n {...(animationScheme !== \"none\"\n ? {\n animate: \"enter\",\n exit: \"exit\",\n initial: \"exit\",\n variants: fadeVariants,\n }\n : {})}\n {...cast<HTMLMotionProps>(getOverlayProps(cast<HTMLProps>(props)))}\n />\n )\n}, \"overlay\")()\n\nexport interface ModalContentProps\n extends Omit<HTMLMotionProps<\"section\">, \"children\">, PropsWithChildren {}\n\nexport const ModalContent = withContext<\"section\", ModalContentProps>(\n ({ children, ...rest }) => {\n const { animationScheme, duration, withCloseButton, getContentProps } =\n useComponentContext()\n const [omittedChildren, customCloseButton] = useSplitChildren(\n children,\n ModalCloseButton,\n )\n const popupAnimationProps = usePopupAnimationProps({\n animationScheme,\n duration,\n })\n\n return (\n <motion.section\n {...popupAnimationProps}\n {...cast<HTMLMotionPropsWithoutAs<\"section\">>(\n getContentProps(cast<HTMLProps<\"section\">>(rest)),\n )}\n >\n {customCloseButton ?? (withCloseButton ? <ModalCloseButton /> : null)}\n\n {omittedChildren}\n </motion.section>\n )\n },\n \"content\",\n)()\n\ninterface ShorthandModalContentProps {\n /**\n * The modal body to use.\n */\n body?: ModalBodyProps | ReactNode\n /**\n * The modal cancel button to use.\n */\n cancel?: ButtonProps | ReactNode\n /**\n * The modal footer to use.\n */\n footer?: ModalFooterProps | ReactNode\n /**\n * The modal header to use.\n */\n header?: ModalHeaderProps | ReactNode\n /**\n * The modal middle button to use.\n */\n middle?: ButtonProps | ReactNode\n /**\n * The modal success button to use.\n */\n success?: ButtonProps | ReactNode\n /**\n * The modal title to use.\n */\n title?: ModalTitleProps | ReactNode\n /**\n * The callback invoked when cancel button clicked.\n */\n onCancel?: (onClose: () => void) => void\n /**\n * The callback invoked when middle button clicked.\n */\n onMiddle?: (onClose: () => void) => void\n /**\n * The callback invoked when success button clicked.\n */\n onSuccess?: (onClose: () => void) => void\n}\n\nexport const ShorthandModalContent: FC<ShorthandModalContentProps> = ({\n body,\n cancel,\n footer,\n header,\n middle,\n success,\n title,\n onCancel,\n onMiddle,\n onSuccess,\n}) => {\n const { onClose } = useComponentContext()\n const customHeader = wrapOrPassProps(ModalHeader, header)\n const customTitle = wrapOrPassProps(ModalTitle, title)\n const customBody = wrapOrPassProps(ModalBody, body)\n const customFooter = wrapOrPassProps(ModalFooter, footer)\n const customCancel = wrapOrPassProps(Button, cancel, {\n colorScheme: \"mono\",\n variant: \"ghost\",\n onClick: () => (onCancel ? onCancel(onClose) : onClose()),\n })\n const customMiddle = wrapOrPassProps(Button, middle, {\n colorScheme: \"secondary\",\n onClick: () => (onMiddle ? onMiddle(onClose) : onClose()),\n })\n const customSuccess = wrapOrPassProps(Button, success, {\n colorScheme: \"primary\",\n onClick: () => (onSuccess ? onSuccess(onClose) : onClose()),\n })\n\n return (\n <ModalContent>\n {customHeader ??\n (customTitle ? <ModalHeader>{customTitle}</ModalHeader> : null)}\n {customBody}\n {customFooter ??\n (customCancel || customMiddle || customSuccess ? (\n <ModalFooter>\n {customCancel}\n {customMiddle}\n {customSuccess}\n </ModalFooter>\n ) : null)}\n </ModalContent>\n )\n}\n\nexport interface ModalHeaderProps extends HTMLStyledProps<\"header\"> {}\n\nexport const ModalHeader = withContext<\"header\", ModalHeaderProps>(\n \"header\",\n \"header\",\n)(undefined, (props) => {\n const { getHeaderProps } = useComponentContext()\n\n return { ...getHeaderProps(props) }\n})\n\nexport interface ModalTitleProps extends HTMLStyledProps<\"h2\"> {}\n\nexport const ModalTitle = withContext<\"h2\", ModalTitleProps>(\"h2\", \"title\")(\n undefined,\n (props) => {\n const { getTitleProps } = useComponentContext()\n\n return { ...getTitleProps(props) }\n },\n)\n\nexport interface ModalBodyProps extends HTMLStyledProps {}\n\nexport const ModalBody = withContext<\"div\", ModalBodyProps>(\"div\", \"body\")(\n undefined,\n (props) => {\n const { getBodyProps } = useComponentContext()\n\n return { ...getBodyProps(props) }\n },\n)\n\nexport interface ModalFooterProps extends HTMLStyledProps<\"footer\"> {}\n\nexport const ModalFooter = withContext<\"footer\", ModalFooterProps>(\n \"footer\",\n \"footer\",\n)(undefined, (props) => {\n const { getFooterProps } = useComponentContext()\n\n return { ...getFooterProps(props) }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuFA,MAAM,EACJ,kBACA,cAAc,mBACd,qBACA,iBAAiB,sBACjB,aACA,iBACE,oBACF,SACA,UACF;;;;;;AASA,MAAa,YAAY,cACtB,EACC,iBAAiB,OACjB,kBAAkB,SAClB,WACA,qBAAqB,MACrB,MACA,QACA,UACA,UACA,eACA,QACA,QACA,iBACA,wBAAwB,MACxB,QACA,cACA,SACA,OACA,SACA,kBAAkB,MAClB,cAAc,MACd,aACA,UACA,iBACA,UACA,WACA,GAAG,YACC;CACJ,MAAM,CAAC,iBAAiB,aAAa,iBAAiB,iBACpD,UACA,kBACA,YACF;CACA,MAAM,eAAA,GAAA,cAAA,QAAA,C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 @@
1
- {"version":3,"file":"native-accordion.js","names":["createContext"],"sources":["../../../../src/components/native-accordion/native-accordion.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactNode } from \"react\"\nimport type { HTMLProps, HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { NativeAccordionStyle } from \"./native-accordion.style\"\nimport type {\n UseNativeAccordionItemProps,\n UseNativeAccordionItemReturn,\n UseNativeAccordionProps,\n} from \"./use-native-accordion\"\nimport { Children, cloneElement, isValidElement, useMemo } from \"react\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { createContext, useSplitChildren } from \"../../utils\"\nimport { ChevronDownIcon } from \"../icon\"\nimport { nativeAccordionStyle } from \"./native-accordion.style\"\nimport {\n NativeAccordionContext,\n useNativeAccordion,\n useNativeAccordionItem,\n} from \"./use-native-accordion\"\n\nexport interface NativeAccordionItem extends NativeAccordionItemProps {}\n\ninterface ComponentContext extends Pick<\n NativeAccordionRootProps,\n \"icon\" | \"iconHidden\"\n> {}\n\nexport interface NativeAccordionRootProps\n extends\n Omit<HTMLStyledProps, \"onChange\">,\n ThemeProps<NativeAccordionStyle>,\n UseNativeAccordionProps {\n /**\n * The accordion icon for all items to use.\n */\n icon?: ReactNode\n /**\n * If `true`, hide the accordion icon for all items.\n *\n * @default false\n */\n iconHidden?: boolean\n /**\n * If provided, generate elements based on items.\n */\n items?: NativeAccordionItem[]\n}\n\ninterface ItemComponentContext\n extends\n Pick<NativeAccordionItemProps, \"icon\">,\n Omit<UseNativeAccordionItemReturn, \"getItemProps\"> {}\n\nconst [ItemComponentContext, useItemComponentContext] =\n createContext<ItemComponentContext>({\n name: \"ItemComponentContext\",\n })\n\nconst {\n ComponentContext,\n PropsContext: NativeAccordionPropsContext,\n useComponentContext,\n usePropsContext: useNativeAccordionPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<\n NativeAccordionRootProps,\n NativeAccordionStyle,\n ComponentContext\n>(\"native-accordion\", nativeAccordionStyle)\n\nexport { NativeAccordionPropsContext, useNativeAccordionPropsContext }\n\n/**\n * `NativeAccordion` is a component for a list that displays information in an expandable or collapsible manner using the native HTML details element.\n *\n * @see https://yamada-ui.com/docs/components/native-accordion\n */\nexport const NativeAccordionRoot = withProvider<\n \"div\",\n NativeAccordionRootProps\n>(({ children, icon, iconHidden, items, ...props }) => {\n const { name, getRootProps } = useNativeAccordion(props)\n const computedChildren = useMemo(() => {\n if (children) return children\n\n return items?.map((props, index) => (\n <NativeAccordionItem key={index} {...props} />\n ))\n }, [children, items])\n const context = useMemo(() => ({ name }), [name])\n const componentContext = useMemo(\n () => ({ icon, iconHidden }),\n [icon, iconHidden],\n )\n\n return (\n <NativeAccordionContext value={context}>\n <ComponentContext value={componentContext}>\n <styled.div {...getRootProps()}>{computedChildren}</styled.div>\n </ComponentContext>\n </NativeAccordionContext>\n )\n}, \"root\")()\n\nexport interface NativeAccordionItemProps\n extends HTMLStyledProps<\"details\">, UseNativeAccordionItemProps {\n /**\n * The accordion button to use.\n */\n button?: ReactNode\n /**\n * The accordion icon to use.\n */\n icon?: ReactNode\n}\n\nexport const NativeAccordionItem = withContext<\n \"details\",\n NativeAccordionItemProps\n>(({ button, children, icon, ...rest }) => {\n const {\n disabled,\n getButtonProps,\n getIconProps,\n getItemProps,\n getPanelProps,\n } = useNativeAccordionItem(rest)\n const [omittedChildren, customAccordionButton, customAccordionPanel] =\n useSplitChildren(children, NativeAccordionButton, NativeAccordionPanel)\n const context = useMemo(\n () => ({\n disabled,\n icon,\n getButtonProps,\n getIconProps,\n getPanelProps,\n }),\n [disabled, getIconProps, getPanelProps, getButtonProps, icon],\n )\n\n return (\n <ItemComponentContext value={context}>\n <styled.details {...getItemProps()}>\n {customAccordionButton ?? (\n <NativeAccordionButton>{button}</NativeAccordionButton>\n )}\n {customAccordionPanel ?? (\n <NativeAccordionPanel>{omittedChildren}</NativeAccordionPanel>\n )}\n </styled.details>\n </ItemComponentContext>\n )\n}, \"item\")()\n\nexport interface NativeAccordionButtonProps extends HTMLStyledProps<\"summary\"> {\n /**\n * The accordion icon to use.\n */\n icon?: ReactNode\n}\n\nexport const NativeAccordionButton = withContext<\n \"summary\",\n NativeAccordionButtonProps\n>(({ children, icon: customIcon, ...rest }) => {\n const { icon: rootIcon } = useComponentContext()\n const { icon: itemIcon, getButtonProps } = useItemComponentContext()\n\n return (\n <styled.summary {...getButtonProps(rest)}>\n {children}\n\n <NativeAccordionIcon>\n {customIcon ?? itemIcon ?? rootIcon}\n </NativeAccordionIcon>\n </styled.summary>\n )\n}, \"button\")()\n\nexport interface NativeAccordionIconProps extends HTMLStyledProps<\"svg\"> {}\n\nexport const NativeAccordionIcon = withContext<\"svg\", NativeAccordionIconProps>(\n ({ children = <ChevronDownIcon />, ...rest }) => {\n const { iconHidden } = useComponentContext()\n const { getIconProps } = useItemComponentContext()\n\n if (iconHidden) return null\n\n if (isValidElement<HTMLProps<\"svg\">>(children))\n return cloneElement(\n children,\n getIconProps({\n ...rest,\n ...children.props,\n }),\n )\n\n return Children.count(children) > 1 ? Children.only(null) : null\n },\n \"icon\",\n)()\n\nexport interface NativeAccordionPanelProps extends HTMLStyledProps {}\n\nexport const NativeAccordionPanel = withContext<\n \"div\",\n NativeAccordionPanelProps\n>(({ children, ...rest }) => {\n const { getPanelProps } = useItemComponentContext()\n\n return (\n <styled.div {...getPanelProps(rest)}>\n <styled.div>{children}</styled.div>\n </styled.div>\n )\n}, \"panel\")()\n"],"mappings":";;;;;;;;;;;AAsDA,MAAM,CAAC,sBAAsB,2BAC3BA,gBAAoC,EAClC,MAAM,uBACR,CAAC;AAEH,MAAM,EACJ,kBACA,cAAc,6BACd,qBACA,iBAAiB,gCACjB,aACA,iBACE,oBAIF,oBAAoB,oBAAoB;;;;;;AAS1C,MAAa,sBAAsB,cAGhC,EAAE,UAAU,MAAM,YAAY,OAAO,GAAG,YAAY;CACrD,MAAM,EAAE,MAAM,iBAAiB,mBAAmB,KAAK;CACvD,MAAM,mBAAmB,cAAc;EACrC,IAAI,UAAU,OAA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BAAC,qBAAD,EAAA,UACG,cAAc,YAAY,SACR,CAAA,CACP;;AAEpB,GAAG,QAAQ,CAAC,CAAC;AAIb,MAAa,sBAAsB,aAChC,EAAE,WAAW,oBAAC,iBAAD,CAAkB,CAAA,GAAG,GAAG,WAAW;CAC/C,MAAM,EAAE,eAAe,oBAAoB;CAC3C,MAAM,EAAE,iBAAiB,wBAAwB;CAEjD,IAAI,YAAY,OAAO;CAEvB,IAAI,eAAiC,QAAQ,GAC3C,OAAO,aACL,UACA,aAAa;EACX,GAAG;EACH,GAAG,SAAS;CACd,CAAC,CACH;CAEF,OAAO,SAAS,MAAM,QAAQ,IAAI,IAAI,SAAS,KAAK,IAAI,IAAI;AAC9D,GACA,MACF,CAAC,CAAC;AAIF,MAAa,uBAAuB,aAGjC,EAAE,UAAU,GAAG,WAAW;CAC3B,MAAM,EAAE,kBAAkB,wBAAwB;CAElD,OACE,oBAAC,OAAO,KAAR;EAAY,GAAI,cAAc,IAAI;YAChC,oBAAC,OAAO,KAAR,EAAa,SAAqB,CAAA;CACxB,CAAA;AAEhB,GAAG,OAAO,CAAC,CAAC"}
1
+ {"version":3,"file":"native-accordion.js","names":["createContext"],"sources":["../../../../src/components/native-accordion/native-accordion.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactNode } from \"react\"\nimport type { HTMLProps, HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { NativeAccordionStyle } from \"./native-accordion.style\"\nimport type {\n UseNativeAccordionItemProps,\n UseNativeAccordionItemReturn,\n UseNativeAccordionProps,\n} from \"./use-native-accordion\"\nimport { Children, cloneElement, isValidElement, useMemo } from \"react\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { createContext, useSplitChildren } from \"../../utils\"\nimport { ChevronDownIcon } from \"../icon\"\nimport { nativeAccordionStyle } from \"./native-accordion.style\"\nimport {\n NativeAccordionContext,\n useNativeAccordion,\n useNativeAccordionItem,\n} from \"./use-native-accordion\"\n\nexport interface NativeAccordionItem extends NativeAccordionItemProps {}\n\ninterface ComponentContext extends Pick<\n NativeAccordionRootProps,\n \"icon\" | \"iconHidden\"\n> {}\n\nexport interface NativeAccordionRootProps\n extends\n Omit<HTMLStyledProps, \"onChange\">,\n ThemeProps<NativeAccordionStyle>,\n UseNativeAccordionProps {\n /**\n * The accordion icon for all items to use.\n */\n icon?: ReactNode\n /**\n * If `true`, hide the accordion icon for all items.\n *\n * @default false\n */\n iconHidden?: boolean\n /**\n * If provided, generate elements based on items.\n */\n items?: NativeAccordionItem[]\n}\n\ninterface ItemComponentContext\n extends\n Pick<NativeAccordionItemProps, \"icon\">,\n Omit<UseNativeAccordionItemReturn, \"getItemProps\"> {}\n\nconst [ItemComponentContext, useItemComponentContext] =\n createContext<ItemComponentContext>({\n name: \"ItemComponentContext\",\n })\n\nconst {\n ComponentContext,\n PropsContext: NativeAccordionPropsContext,\n useComponentContext,\n usePropsContext: useNativeAccordionPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<\n NativeAccordionRootProps,\n NativeAccordionStyle,\n ComponentContext\n>(\"native-accordion\", nativeAccordionStyle)\n\nexport { NativeAccordionPropsContext, useNativeAccordionPropsContext }\n\n/**\n * `NativeAccordion` is a component for a list that displays information in an expandable or collapsible manner using the native HTML details element.\n *\n * @see https://yamada-ui.com/docs/components/native-accordion\n */\nexport const NativeAccordionRoot = withProvider<\n \"div\",\n NativeAccordionRootProps\n>(({ children, icon, iconHidden, items, ...props }) => {\n const { name, getRootProps } = useNativeAccordion(props)\n const computedChildren = useMemo(() => {\n if (children) return children\n\n return items?.map((props, index) => (\n <NativeAccordionItem key={index} {...props} />\n ))\n }, [children, items])\n const context = useMemo(() => ({ name }), [name])\n const componentContext = useMemo(\n () => ({ icon, iconHidden }),\n [icon, iconHidden],\n )\n\n return (\n <NativeAccordionContext value={context}>\n <ComponentContext value={componentContext}>\n <styled.div {...getRootProps()}>{computedChildren}</styled.div>\n </ComponentContext>\n </NativeAccordionContext>\n )\n}, \"root\")()\n\nexport interface NativeAccordionItemProps\n extends HTMLStyledProps<\"details\">, UseNativeAccordionItemProps {\n /**\n * The accordion button to use.\n */\n button?: ReactNode\n /**\n * The accordion icon to use.\n */\n icon?: ReactNode\n}\n\nexport const NativeAccordionItem = withContext<\n \"details\",\n NativeAccordionItemProps\n>(({ button, children, icon, ...rest }) => {\n const {\n disabled,\n getButtonProps,\n getIconProps,\n getItemProps,\n getPanelProps,\n } = useNativeAccordionItem(rest)\n const [omittedChildren, customAccordionButton, customAccordionPanel] =\n useSplitChildren(children, NativeAccordionButton, NativeAccordionPanel)\n const context = useMemo(\n () => ({\n disabled,\n icon,\n getButtonProps,\n getIconProps,\n getPanelProps,\n }),\n [disabled, getIconProps, getPanelProps, getButtonProps, icon],\n )\n\n return (\n <ItemComponentContext value={context}>\n <styled.details {...getItemProps()}>\n {customAccordionButton ?? (\n <NativeAccordionButton>{button}</NativeAccordionButton>\n )}\n {customAccordionPanel ?? (\n <NativeAccordionPanel>{omittedChildren}</NativeAccordionPanel>\n )}\n </styled.details>\n </ItemComponentContext>\n )\n}, \"item\")()\n\nexport interface NativeAccordionButtonProps extends HTMLStyledProps<\"summary\"> {\n /**\n * The accordion icon to use.\n */\n icon?: ReactNode\n}\n\nexport const NativeAccordionButton = withContext<\n \"summary\",\n NativeAccordionButtonProps\n>(({ children, icon: customIcon, ...rest }) => {\n const { icon: rootIcon } = useComponentContext()\n const { icon: itemIcon, getButtonProps } = useItemComponentContext()\n\n return (\n <styled.summary {...getButtonProps(rest)}>\n {children}\n\n <NativeAccordionIcon>\n {customIcon ?? itemIcon ?? rootIcon}\n </NativeAccordionIcon>\n </styled.summary>\n )\n}, \"button\")()\n\nexport interface NativeAccordionIconProps extends HTMLStyledProps<\"svg\"> {}\n\nexport const NativeAccordionIcon = withContext<\"svg\", NativeAccordionIconProps>(\n ({ children = <ChevronDownIcon />, ...rest }) => {\n const { iconHidden } = useComponentContext()\n const { getIconProps } = useItemComponentContext()\n\n if (iconHidden) return null\n\n if (isValidElement<HTMLProps<\"svg\">>(children))\n return cloneElement(\n children,\n getIconProps({\n ...rest,\n ...children.props,\n }),\n )\n\n return Children.count(children) > 1 ? Children.only(null) : null\n },\n \"icon\",\n)()\n\nexport interface NativeAccordionPanelProps extends HTMLStyledProps {}\n\nexport const NativeAccordionPanel = withContext<\n \"div\",\n NativeAccordionPanelProps\n>(({ children, ...rest }) => {\n const { getPanelProps } = useItemComponentContext()\n\n return (\n <styled.div {...getPanelProps(rest)}>\n <styled.div>{children}</styled.div>\n </styled.div>\n )\n}, \"panel\")()\n"],"mappings":";;;;;;;;;;;AAsDA,MAAM,CAAC,sBAAsB,2BAC3BA,gBAAoC,EAClC,MAAM,uBACR,CAAC;AAEH,MAAM,EACJ,kBACA,cAAc,6BACd,qBACA,iBAAiB,gCACjB,aACA,iBACE,oBAIF,oBAAoB,oBAAoB;;;;;;AAS1C,MAAa,sBAAsB,cAGhC,EAAE,UAAU,MAAM,YAAY,OAAO,GAAG,YAAY;CACrD,MAAM,EAAE,MAAM,iBAAiB,mBAAmB,KAAK;CACvD,MAAM,mBAAmB,cAAc;EACrC,IAAI,UAAU,OAAO;EAErB,OAAO,OAAO,KAAK,OAAO,UACxB,oBAAC,qBAAD,EAAiC,GAAI,MAAQ,GAAnB,KAAmB,CAC9C;CACH,GAAG,CAAC,UAAU,KAAK,CAAC;CACpB,MAAM,UAAU,eAAe,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC;CAChD,MAAM,mBAAmB,eAChB;EAAE;EAAM;CAAW,IAC1B,CAAC,MAAM,UAAU,CACnB;CAEA,OACE,oBAAC,wBAAD;EAAwB,OAAO;EAC7B,UAAA,oBAAC,kBAAD;GAAkB,OAAO;GACvB,UAAA,oBAAC,OAAO,KAAR;IAAY,GAAI,aAAa;IAAI,UAAA;GAA6B,CAAA;EAC9C,CAAA;CACI,CAAA;AAE5B,GAAG,MAAM,CAAC,CAAC;AAcX,MAAa,sBAAsB,aAGhC,EAAE,QAAQ,UAAU,MAAM,GAAG,WAAW;CAC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WAAW;CAC3B,MAAM,EAAE,kBAAkB,wBAAwB;CAElD,OACE,oBAAC,OAAO,KAAR;EAAY,GAAI,cAAc,IAAI;EAChC,UAAA,oBAAC,OAAO,KAAR,EAAa,SAAqB,CAAA;CACxB,CAAA;AAEhB,GAAG,OAAO,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"native-popover.js","names":[],"sources":["../../../../src/components/native-popover/native-popover.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, PropsWithChildren } from \"react\"\nimport type { HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { NativePopoverStyle } from \"./native-popover.style\"\nimport type {\n UseNativePopoverProps,\n UseNativePopoverReturn,\n} from \"./use-native-popover\"\nimport { useMemo } from \"react\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { cast } from \"../../utils\"\nimport { nativePopoverStyle } from \"./native-popover.style\"\nimport { useNativePopover } from \"./use-native-popover\"\n\ninterface ComponentContext extends Pick<\n UseNativePopoverReturn,\n | \"getAnchorProps\"\n | \"getBodyProps\"\n | \"getCloseTriggerProps\"\n | \"getContentProps\"\n | \"getFooterProps\"\n | \"getHeaderProps\"\n | \"getPositionerProps\"\n | \"getTriggerProps\"\n> {}\n\nexport interface NativePopoverRootProps\n extends\n UseNativePopoverProps,\n ThemeProps<NativePopoverStyle>,\n PropsWithChildren {}\n\nconst {\n ComponentContext,\n PropsContext: NativePopoverPropsContext,\n StyleContext,\n useComponentContext,\n usePropsContext: useNativePopoverPropsContext,\n withContext,\n useRootComponentProps,\n} = createSlotComponent<\n NativePopoverRootProps,\n NativePopoverStyle,\n ComponentContext\n>(\"native-popover\", nativePopoverStyle)\n\nexport { NativePopoverPropsContext, useNativePopoverPropsContext }\n\n/**\n * `NativePopover` is a component that floats around an element to display information using the native HTML Popover API.\n *\n * @see https://yamada-ui.com/docs/components/native-popover\n */\nexport const NativePopoverRoot: FC<NativePopoverRootProps> = (props) => {\n const [styleContext, { children, ...rest }] = useRootComponentProps(props)\n const {\n getAnchorProps,\n getBodyProps,\n getCloseTriggerProps,\n getContentProps,\n getFooterProps,\n getHeaderProps,\n getPositionerProps,\n getTriggerProps,\n } = useNativePopover(rest)\n const componentContext = useMemo(\n () => ({\n getAnchorProps,\n getBodyProps,\n getCloseTriggerProps,\n getContentProps,\n getFooterProps,\n getHeaderProps,\n getPositionerProps,\n getTriggerProps,\n }),\n [\n getAnchorProps,\n getBodyProps,\n getCloseTriggerProps,\n getContentProps,\n getFooterProps,\n getHeaderProps,\n getPositionerProps,\n getTriggerProps,\n ],\n )\n\n return (\n <StyleContext value={styleContext}>\n <ComponentContext value={componentContext}>{children}</ComponentContext>\n </StyleContext>\n )\n}\n\nexport interface NativePopoverTriggerProps extends HTMLStyledProps<\"button\"> {}\n\nexport const NativePopoverTrigger = withContext<\n \"button\",\n NativePopoverTriggerProps\n>(\"button\", \"trigger\")({ asChild: true }, (props) => {\n const { getTriggerProps } = useComponentContext()\n\n return getTriggerProps(props)\n})\n\nexport interface NativePopoverAnchorProps extends HTMLStyledProps {}\n\nexport const NativePopoverAnchor = withContext<\"div\", NativePopoverAnchorProps>(\n \"div\",\n \"anchor\",\n)({ asChild: true }, (props) => {\n const { getAnchorProps } = useComponentContext()\n\n return getAnchorProps(props)\n})\n\ninterface NativePopoverPositionerProps extends HTMLStyledProps {}\n\nconst NativePopoverPositioner = withContext<\n \"div\",\n NativePopoverPositionerProps\n>(\"div\", \"positioner\")({ asChild: true }, (props) => {\n const { getPositionerProps } = useComponentContext()\n\n return getPositionerProps(props)\n})\n\nexport interface NativePopoverCloseTriggerProps extends HTMLStyledProps<\"button\"> {}\n\nexport const NativePopoverCloseTrigger = withContext<\n \"button\",\n NativePopoverCloseTriggerProps\n>(\"button\", { name: \"CloseTrigger\", slot: [\"trigger\", \"close\"] })(\n { asChild: true },\n (props) => {\n const { getCloseTriggerProps } = useComponentContext()\n\n return getCloseTriggerProps(props)\n },\n)\n\nexport interface NativePopoverContentProps\n extends HTMLStyledProps, PropsWithChildren {}\n\nexport const NativePopoverContent = withContext<\n \"div\",\n NativePopoverContentProps\n>(({ children, ...rest }) => {\n const { getContentProps } = useComponentContext()\n\n return (\n <NativePopoverPositioner>\n <styled.div {...getContentProps(cast<HTMLStyledProps>(rest))}>\n {children}\n </styled.div>\n </NativePopoverPositioner>\n )\n}, \"content\")({\n suppressHydrationWarning: true,\n})\n\nexport interface NativePopoverHeaderProps extends HTMLStyledProps {}\n\nexport const NativePopoverHeader = withContext<\"div\", NativePopoverHeaderProps>(\n \"div\",\n \"header\",\n)(undefined, (props) => {\n const { getHeaderProps } = useComponentContext()\n\n return getHeaderProps(props)\n})\n\nexport interface NativePopoverBodyProps extends HTMLStyledProps {}\n\nexport const NativePopoverBody = withContext<\"div\", NativePopoverBodyProps>(\n \"div\",\n \"body\",\n)(undefined, (props) => {\n const { getBodyProps } = useComponentContext()\n\n return getBodyProps(props)\n})\n\nexport interface NativePopoverFooterProps extends HTMLStyledProps {}\n\nexport const NativePopoverFooter = withContext<\"div\", NativePopoverFooterProps>(\n \"div\",\n \"footer\",\n)(undefined, (props) => {\n const { getFooterProps } = useComponentContext()\n\n return getFooterProps(props)\n})\n"],"mappings":";;;;;;;;;AAiCA,MAAM,EACJ,kBACA,cAAc,2BACd,cACA,qBACA,iBAAiB,8BACjB,aACA,0BACE,oBAIF,kBAAkB,kBAAkB;;;;;;AAStC,MAAa,qBAAiD,UAAU;CACtE,MAAM,CAAC,cAAc,EAAE,UAAU,GAAG,UAAU,sBAAsB,KAAK;CACzE,MAAM,EACJ,gBACA,cACA,sBACA,iBACA,gBACA,gBACA,oBACA,oBACE,iBAAiB,IAAI;CACzB,MAAM,mBAAmB,eAChB;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,OACE,oBAAC,cAAD;EAAc,OAAO;YACnB,oBAAC,kBAAD;GAAkB,OAAO;GAAmB;EAA2B,CAAA;CAC3D,C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3B,CAAC;AAID,MAAa,sBAAsB,YACjC,OACA,QACF,CAAC,CAAC,KAAA,IAAY,UAAU;CACtB,MAAM,EAAE,mBAAmB,oBAAoB;CAE/C,OAAO,eAAe,KAAK;AAC7B,CAAC"}
1
+ {"version":3,"file":"native-popover.js","names":[],"sources":["../../../../src/components/native-popover/native-popover.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, PropsWithChildren } from \"react\"\nimport type { HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { NativePopoverStyle } from \"./native-popover.style\"\nimport type {\n UseNativePopoverProps,\n UseNativePopoverReturn,\n} from \"./use-native-popover\"\nimport { useMemo } from \"react\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { cast } from \"../../utils\"\nimport { nativePopoverStyle } from \"./native-popover.style\"\nimport { useNativePopover } from \"./use-native-popover\"\n\ninterface ComponentContext extends Pick<\n UseNativePopoverReturn,\n | \"getAnchorProps\"\n | \"getBodyProps\"\n | \"getCloseTriggerProps\"\n | \"getContentProps\"\n | \"getFooterProps\"\n | \"getHeaderProps\"\n | \"getPositionerProps\"\n | \"getTriggerProps\"\n> {}\n\nexport interface NativePopoverRootProps\n extends\n UseNativePopoverProps,\n ThemeProps<NativePopoverStyle>,\n PropsWithChildren {}\n\nconst {\n ComponentContext,\n PropsContext: NativePopoverPropsContext,\n StyleContext,\n useComponentContext,\n usePropsContext: useNativePopoverPropsContext,\n withContext,\n useRootComponentProps,\n} = createSlotComponent<\n NativePopoverRootProps,\n NativePopoverStyle,\n ComponentContext\n>(\"native-popover\", nativePopoverStyle)\n\nexport { NativePopoverPropsContext, useNativePopoverPropsContext }\n\n/**\n * `NativePopover` is a component that floats around an element to display information using the native HTML Popover API.\n *\n * @see https://yamada-ui.com/docs/components/native-popover\n */\nexport const NativePopoverRoot: FC<NativePopoverRootProps> = (props) => {\n const [styleContext, { children, ...rest }] = useRootComponentProps(props)\n const {\n getAnchorProps,\n getBodyProps,\n getCloseTriggerProps,\n getContentProps,\n getFooterProps,\n getHeaderProps,\n getPositionerProps,\n getTriggerProps,\n } = useNativePopover(rest)\n const componentContext = useMemo(\n () => ({\n getAnchorProps,\n getBodyProps,\n getCloseTriggerProps,\n getContentProps,\n getFooterProps,\n getHeaderProps,\n getPositionerProps,\n getTriggerProps,\n }),\n [\n getAnchorProps,\n getBodyProps,\n getCloseTriggerProps,\n getContentProps,\n getFooterProps,\n getHeaderProps,\n getPositionerProps,\n getTriggerProps,\n ],\n )\n\n return (\n <StyleContext value={styleContext}>\n <ComponentContext value={componentContext}>{children}</ComponentContext>\n </StyleContext>\n )\n}\n\nexport interface NativePopoverTriggerProps extends HTMLStyledProps<\"button\"> {}\n\nexport const NativePopoverTrigger = withContext<\n \"button\",\n NativePopoverTriggerProps\n>(\"button\", \"trigger\")({ asChild: true }, (props) => {\n const { getTriggerProps } = useComponentContext()\n\n return getTriggerProps(props)\n})\n\nexport interface NativePopoverAnchorProps extends HTMLStyledProps {}\n\nexport const NativePopoverAnchor = withContext<\"div\", NativePopoverAnchorProps>(\n \"div\",\n \"anchor\",\n)({ asChild: true }, (props) => {\n const { getAnchorProps } = useComponentContext()\n\n return getAnchorProps(props)\n})\n\ninterface NativePopoverPositionerProps extends HTMLStyledProps {}\n\nconst NativePopoverPositioner = withContext<\n \"div\",\n NativePopoverPositionerProps\n>(\"div\", \"positioner\")({ asChild: true }, (props) => {\n const { getPositionerProps } = useComponentContext()\n\n return getPositionerProps(props)\n})\n\nexport interface NativePopoverCloseTriggerProps extends HTMLStyledProps<\"button\"> {}\n\nexport const NativePopoverCloseTrigger = withContext<\n \"button\",\n NativePopoverCloseTriggerProps\n>(\"button\", { name: \"CloseTrigger\", slot: [\"trigger\", \"close\"] })(\n { asChild: true },\n (props) => {\n const { getCloseTriggerProps } = useComponentContext()\n\n return getCloseTriggerProps(props)\n },\n)\n\nexport interface NativePopoverContentProps\n extends HTMLStyledProps, PropsWithChildren {}\n\nexport const NativePopoverContent = withContext<\n \"div\",\n NativePopoverContentProps\n>(({ children, ...rest }) => {\n const { getContentProps } = useComponentContext()\n\n return (\n <NativePopoverPositioner>\n <styled.div {...getContentProps(cast<HTMLStyledProps>(rest))}>\n {children}\n </styled.div>\n </NativePopoverPositioner>\n )\n}, \"content\")({\n suppressHydrationWarning: true,\n})\n\nexport interface NativePopoverHeaderProps extends HTMLStyledProps {}\n\nexport const NativePopoverHeader = withContext<\"div\", NativePopoverHeaderProps>(\n \"div\",\n \"header\",\n)(undefined, (props) => {\n const { getHeaderProps } = useComponentContext()\n\n return getHeaderProps(props)\n})\n\nexport interface NativePopoverBodyProps extends HTMLStyledProps {}\n\nexport const NativePopoverBody = withContext<\"div\", NativePopoverBodyProps>(\n \"div\",\n \"body\",\n)(undefined, (props) => {\n const { getBodyProps } = useComponentContext()\n\n return getBodyProps(props)\n})\n\nexport interface NativePopoverFooterProps extends HTMLStyledProps {}\n\nexport const NativePopoverFooter = withContext<\"div\", NativePopoverFooterProps>(\n \"div\",\n \"footer\",\n)(undefined, (props) => {\n const { getFooterProps } = useComponentContext()\n\n return getFooterProps(props)\n})\n"],"mappings":";;;;;;;;;AAiCA,MAAM,EACJ,kBACA,cAAc,2BACd,cACA,qBACA,iBAAiB,8BACjB,aACA,0BACE,oBAIF,kBAAkB,kBAAkB;;;;;;AAStC,MAAa,qBAAiD,UAAU;CACtE,MAAM,CAAC,cAAc,EAAE,UAAU,GAAG,UAAU,sBAAsB,KAAK;CACzE,MAAM,EACJ,gBACA,cACA,sBACA,iBACA,gBACA,gBACA,oBACA,oBACE,iBAAiB,IAAI;CACzB,MAAM,mBAAmB,eAChB;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,OACE,oBAAC,cAAD;EAAc,OAAO;EACnB,UAAA,oBAAC,kBAAD;GAAkB,OAAO;GAAmB;EAA2B,CAAA;CAC3D,CAAA;AAElB;AAIA,MAAa,uBAAuB,YAGlC,UAAU,SAAS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,CAAC,KAAA,IAAY,UAAU;CACtB,MAAM,EAAE,mBAAmB,oBAAoB;CAE/C,OAAO,eAAe,KAAK;AAC7B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"native-select.js","names":["InputGroup.Root","InputGroup.Element"],"sources":["../../../../src/components/native-select/native-select.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactNode } from \"react\"\nimport type { HTMLProps, HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport type { UseInputBorderProps } from \"../input\"\nimport type { NativeSelectStyle } from \"./native-select.style\"\nimport type { UseNativeSelectProps } from \"./use-native-select\"\nimport { createSlotComponent, mergeProps } from \"../../core\"\nimport { useGroupItemProps } from \"../group\"\nimport { ChevronDownIcon } from \"../icon\"\nimport { InputGroup, useInputBorder, useInputPropsContext } from \"../input\"\nimport { nativeSelectStyle } from \"./native-select.style\"\nimport { useNativeSelect } from \"./use-native-select\"\n\nexport interface NativeSelectRootProps\n extends\n Omit<HTMLStyledProps<\"select\">, \"size\">,\n UseNativeSelectProps,\n ThemeProps<NativeSelectStyle>,\n FieldProps,\n UseInputBorderProps {\n /**\n * The icon to be used in the select.\n */\n icon?: ReactNode\n /**\n * The props for the end element.\n */\n elementProps?: InputGroup.ElementProps\n /**\n * Props for icon element.\n */\n iconProps?: NativeSelectIconProps\n /**\n * Props for root element.\n */\n rootProps?: InputGroup.RootProps\n}\n\nconst {\n component,\n PropsContext: NativeSelectPropsContext,\n usePropsContext: useNativeSelectPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<NativeSelectRootProps, NativeSelectStyle>(\n \"native-select\",\n nativeSelectStyle,\n)\n\nexport { NativeSelectPropsContext, useNativeSelectPropsContext }\n\n/**\n * `NativeSelect` is a component used for allowing users to select one option from a list. It displays a native dropdown list provided by the browser (user agent).\n *\n * @see https://yamada-ui.com/docs/components/native-select\n */\nexport const NativeSelectRoot = withProvider<\"select\", NativeSelectRootProps>(\n (props) => {\n const [\n groupItemProps,\n {\n className,\n css,\n colorScheme,\n errorBorderColor,\n focusBorderColor,\n icon,\n elementProps,\n iconProps,\n rootProps,\n ...rest\n },\n ] = useGroupItemProps(props)\n const { getFieldProps, getIconProps, getRootProps } = useNativeSelect(rest)\n const varProps = useInputBorder({\n errorBorderColor,\n focusBorderColor,\n })\n\n return (\n <InputGroup.Root\n {...mergeProps(\n { className, css, colorScheme },\n getRootProps(groupItemProps),\n rootProps,\n )()}\n >\n <NativeSelectField {...getFieldProps({ ...varProps })} />\n\n <InputGroup.Element {...elementProps}>\n <NativeSelectIcon icon={icon} {...getIconProps(iconProps)} />\n </InputGroup.Element>\n </InputGroup.Root>\n )\n },\n \"root\",\n)((props) => {\n const context = useInputPropsContext()\n\n return mergeProps(context, props)()\n})\n\ninterface NativeSelectFieldProps extends HTMLStyledProps<\"select\"> {}\n\nconst NativeSelectField = withContext<\"select\", NativeSelectFieldProps>(\n \"select\",\n \"field\",\n)({ \"data-group-propagate\": \"\" })\n\ninterface NativeSelectIconProps extends HTMLStyledProps {\n icon?: ReactNode\n}\n\nconst NativeSelectIcon = withContext<\"div\", NativeSelectIconProps>(\n \"div\",\n \"icon\",\n)(undefined, ({ children, icon, ...rest }) => ({\n children: icon || children || <ChevronDownIcon />,\n ...rest,\n}))\n\nexport interface NativeSelectGroupProps extends HTMLProps<\"optgroup\"> {}\n\nexport const NativeSelectGroup = component<\"optgroup\", NativeSelectGroupProps>(\n \"optgroup\",\n \"group\",\n)()\n\nexport interface NativeSelectOptionProps extends HTMLProps<\"option\"> {}\n\nexport const NativeSelectOption = component<\"option\", NativeSelectOptionProps>(\n \"option\",\n \"option\",\n)()\n\nexport interface NativeSelectSeparatorProps extends HTMLProps<\"hr\"> {}\n\nexport const NativeSelectSeparator = component<\n \"hr\",\n NativeSelectSeparatorProps\n>(\"hr\", \"separator\")()\n"],"mappings":";;;;;;;;;;;;;AAwCA,MAAM,EACJ,WACA,cAAc,0BACd,iBAAiB,6BACjB,aACA,iBACE,oBACF,iBACA,iBACF;;;;;;AASA,MAAa,mBAAmB,cAC7B,UAAU;CACT,MAAM,CACJ,gBACA,EACE,WACA,KACA,aACA,kBACA,kBACA,MACA,cACA,WACA,WACA,GAAG,UAEH,kBAAkB,KAAK;CAC3B,MAAM,EAAE,eAAe,cAAc,iBAAiB,gBAAgB,IAAI;CAC1E,MAAM,WAAW,eAAe;EAC9B;EACA;CACF,CAAC;CAED,OACE,qBAACA,gBAAD;EACE,GAAI,WACF;GAAE;GAAW;GAAK;EAAY,GAC9B,aAAa,cAAc,GAC3B,SACF,CAAC,CAAC;YALJ,CAOE,oBAAC,mBAAD,EAAmB,GAAI,cAAc,EAAE,GAAG,SAAS,CAAC,EAAI,CAAA,GAExD,oBAACC,cAAD;GAAoB,GAAI;aACtB,oBAAC,kBAAD;IAAwB;IAAM,GAAI,aAAa,SAAS;GAAI,CAAA;EAC1C,CAAA,CACL;;AAErB,GACA,MACF,CAAC,EAAE,UAAU;CAGX,OAAO,WAFS,qBAEQ,GAAG,KAAK,CAAC,CAAC;AACpC,CAAC;AAID,MAAM,oBAAoB,YACxB,UACA,OACF,CAAC,CAAC,EAAE,wBAAwB,GAAG,CAAC;AAMhC,MAAM,mBAAmB,YACvB,OACA,MACF,CAAC,CAAC,KAAA,IAAY,EAAE,UAAU,MAAM,GAAG,YAAY;CAC7C,UAAU,QAAQ,YAAY,oBAAC,iBAAD,CAAkB,CAAA;CAChD,GAAG;AACL,EAAE;AAIF,MAAa,oBAAoB,UAC/B,YACA,OACF,CAAC,CAAC;AAIF,MAAa,qBAAqB,UAChC,UACA,QACF,CAAC,CAAC;AAIF,MAAa,wBAAwB,UAGnC,MAAM,WAAW,CAAC,CAAC"}
1
+ {"version":3,"file":"native-select.js","names":["InputGroup.Root","InputGroup.Element"],"sources":["../../../../src/components/native-select/native-select.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactNode } from \"react\"\nimport type { HTMLProps, HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport type { UseInputBorderProps } from \"../input\"\nimport type { NativeSelectStyle } from \"./native-select.style\"\nimport type { UseNativeSelectProps } from \"./use-native-select\"\nimport { createSlotComponent, mergeProps } from \"../../core\"\nimport { useGroupItemProps } from \"../group\"\nimport { ChevronDownIcon } from \"../icon\"\nimport { InputGroup, useInputBorder, useInputPropsContext } from \"../input\"\nimport { nativeSelectStyle } from \"./native-select.style\"\nimport { useNativeSelect } from \"./use-native-select\"\n\nexport interface NativeSelectRootProps\n extends\n Omit<HTMLStyledProps<\"select\">, \"size\">,\n UseNativeSelectProps,\n ThemeProps<NativeSelectStyle>,\n FieldProps,\n UseInputBorderProps {\n /**\n * The icon to be used in the select.\n */\n icon?: ReactNode\n /**\n * The props for the end element.\n */\n elementProps?: InputGroup.ElementProps\n /**\n * Props for icon element.\n */\n iconProps?: NativeSelectIconProps\n /**\n * Props for root element.\n */\n rootProps?: InputGroup.RootProps\n}\n\nconst {\n component,\n PropsContext: NativeSelectPropsContext,\n usePropsContext: useNativeSelectPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<NativeSelectRootProps, NativeSelectStyle>(\n \"native-select\",\n nativeSelectStyle,\n)\n\nexport { NativeSelectPropsContext, useNativeSelectPropsContext }\n\n/**\n * `NativeSelect` is a component used for allowing users to select one option from a list. It displays a native dropdown list provided by the browser (user agent).\n *\n * @see https://yamada-ui.com/docs/components/native-select\n */\nexport const NativeSelectRoot = withProvider<\"select\", NativeSelectRootProps>(\n (props) => {\n const [\n groupItemProps,\n {\n className,\n css,\n colorScheme,\n errorBorderColor,\n focusBorderColor,\n icon,\n elementProps,\n iconProps,\n rootProps,\n ...rest\n },\n ] = useGroupItemProps(props)\n const { getFieldProps, getIconProps, getRootProps } = useNativeSelect(rest)\n const varProps = useInputBorder({\n errorBorderColor,\n focusBorderColor,\n })\n\n return (\n <InputGroup.Root\n {...mergeProps(\n { className, css, colorScheme },\n getRootProps(groupItemProps),\n rootProps,\n )()}\n >\n <NativeSelectField {...getFieldProps({ ...varProps })} />\n\n <InputGroup.Element {...elementProps}>\n <NativeSelectIcon icon={icon} {...getIconProps(iconProps)} />\n </InputGroup.Element>\n </InputGroup.Root>\n )\n },\n \"root\",\n)((props) => {\n const context = useInputPropsContext()\n\n return mergeProps(context, props)()\n})\n\ninterface NativeSelectFieldProps extends HTMLStyledProps<\"select\"> {}\n\nconst NativeSelectField = withContext<\"select\", NativeSelectFieldProps>(\n \"select\",\n \"field\",\n)({ \"data-group-propagate\": \"\" })\n\ninterface NativeSelectIconProps extends HTMLStyledProps {\n icon?: ReactNode\n}\n\nconst NativeSelectIcon = withContext<\"div\", NativeSelectIconProps>(\n \"div\",\n \"icon\",\n)(undefined, ({ children, icon, ...rest }) => ({\n children: icon || children || <ChevronDownIcon />,\n ...rest,\n}))\n\nexport interface NativeSelectGroupProps extends HTMLProps<\"optgroup\"> {}\n\nexport const NativeSelectGroup = component<\"optgroup\", NativeSelectGroupProps>(\n \"optgroup\",\n \"group\",\n)()\n\nexport interface NativeSelectOptionProps extends HTMLProps<\"option\"> {}\n\nexport const NativeSelectOption = component<\"option\", NativeSelectOptionProps>(\n \"option\",\n \"option\",\n)()\n\nexport interface NativeSelectSeparatorProps extends HTMLProps<\"hr\"> {}\n\nexport const NativeSelectSeparator = component<\n \"hr\",\n NativeSelectSeparatorProps\n>(\"hr\", \"separator\")()\n"],"mappings":";;;;;;;;;;;;;AAwCA,MAAM,EACJ,WACA,cAAc,0BACd,iBAAiB,6BACjB,aACA,iBACE,oBACF,iBACA,iBACF;;;;;;AASA,MAAa,mBAAmB,cAC7B,UAAU;CACT,MAAM,CACJ,gBACA,EACE,WACA,KACA,aACA,kBACA,kBACA,MACA,cACA,WACA,WACA,GAAG,UAEH,kBAAkB,KAAK;CAC3B,MAAM,EAAE,eAAe,cAAc,iBAAiB,gBAAgB,IAAI;CAC1E,MAAM,WAAW,eAAe;EAC9B;EACA;CACF,CAAC;CAED,OACE,qBAACA,gBAAD;EACE,GAAI,WACF;GAAE;GAAW;GAAK;EAAY,GAC9B,aAAa,cAAc,GAC3B,SACF,CAAC,CAAC;EALJ,UAAA,CAOE,oBAAC,mBAAD,EAAmB,GAAI,cAAc,EAAE,GAAG,SAAS,CAAC,EAAI,CAAA,GAExD,oBAACC,cAAD;GAAoB,GAAI;GACtB,UAAA,oBAAC,kBAAD;IAAwB;IAAM,GAAI,aAAa,SAAS;GAAI,CAAA;EAC1C,CAAA,CACL;;AAErB,GACA,MACF,CAAC,EAAE,UAAU;CAGX,OAAO,WAFS,qBAEQ,GAAG,KAAK,CAAC,CAAC;AACpC,CAAC;AAID,MAAM,oBAAoB,YACxB,UACA,OACF,CAAC,CAAC,EAAE,wBAAwB,GAAG,CAAC;AAMhC,MAAM,mBAAmB,YACvB,OACA,MACF,CAAC,CAAC,KAAA,IAAY,EAAE,UAAU,MAAM,GAAG,YAAY;CAC7C,UAAU,QAAQ,YAAY,oBAAC,iBAAD,CAAkB,CAAA;CAChD,GAAG;AACL,EAAE;AAIF,MAAa,oBAAoB,UAC/B,YACA,OACF,CAAC,CAAC;AAIF,MAAa,qBAAqB,UAChC,UACA,QACF,CAAC,CAAC;AAIF,MAAa,wBAAwB,UAGnC,MAAM,WAAW,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-native-select.js","names":[],"sources":["../../../../src/components/native-select/use-native-select.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactNode } from \"react\"\nimport type { HTMLProps, PropGetter } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport { cloneElement, useCallback, useMemo } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { ariaAttr } from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\ninterface NativeSelectSharedItem extends Omit<\n HTMLProps<\"option\">,\n \"children\" | \"label\" | \"value\"\n> {\n label: string\n}\n\ninterface NativeSelectItemWithValue extends NativeSelectSharedItem {\n value?: HTMLProps<\"option\">[\"value\"]\n}\n\ninterface NativeSelectItemWithItems extends NativeSelectSharedItem {\n items: NativeSelectItemWithValue[]\n}\n\nexport type NativeSelectItem =\n | NativeSelectItemWithItems\n | NativeSelectItemWithValue\n\nexport interface UseNativeSelectProps extends HTMLProps<\"select\">, FieldProps {\n /**\n * If `true`, include placeholder in options.\n *\n * @default true\n */\n includePlaceholder?: boolean\n /**\n * If provided, generate options based on items.\n *\n * @default []\n */\n items?: NativeSelectItem[]\n /**\n * The placeholder for select.\n */\n placeholder?: string\n}\n\nexport const useNativeSelect = (props: UseNativeSelectProps = {}) => {\n const {\n props: {\n children,\n disabled,\n includePlaceholder = true,\n items = [],\n placeholder,\n readOnly,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const interactive = !(readOnly || disabled)\n\n const computedChildren = useMemo(() => {\n let computedChildren: ReactNode = null\n\n if (children) computedChildren = children\n else if (items.length)\n computedChildren = items.map((item, index) => {\n if (\"items\" in item) {\n const { items, label, ...rest } = item\n\n return cloneElement(<optgroup />, {\n key: index,\n children: items.map(({ label, ...rest }, index) =>\n cloneElement(<option aria-label={label} />, {\n key: index,\n children: label,\n ...rest,\n }),\n ),\n label,\n ...rest,\n })\n } else {\n const { label, ...rest } = item\n\n return cloneElement(<option aria-label={label} />, {\n key: index,\n children: label,\n ...rest,\n })\n }\n })\n\n return (\n <>\n {placeholder ? (\n <option hidden={!includePlaceholder} value=\"\">\n {placeholder}\n </option>\n ) : null}\n\n {computedChildren}\n </>\n )\n }, [children, items, placeholder, includePlaceholder])\n\n const getRootProps: PropGetter = useCallback(\n (props) => ({ ...dataProps, ...props }),\n [dataProps],\n )\n\n const getFieldProps: PropGetter<\"select\"> = useCallback(\n ({ ref, ...props } = {}) =>\n mergeProps(\n {\n disabled,\n readOnly,\n tabIndex: interactive ? undefined : -1,\n ...ariaProps,\n ...dataProps,\n \"aria-disabled\": ariaAttr(!interactive),\n \"aria-label\": placeholder,\n },\n {\n onBlur: eventProps.onBlur,\n onFocus: eventProps.onFocus,\n },\n rest,\n props,\n {\n ref,\n children: props.children ?? computedChildren,\n },\n )(),\n [\n interactive,\n ariaProps,\n computedChildren,\n dataProps,\n eventProps,\n rest,\n placeholder,\n disabled,\n readOnly,\n ],\n )\n\n const getIconProps: PropGetter = useCallback(\n (props) => ({ ...dataProps, ...props }),\n [dataProps],\n )\n\n return { getFieldProps, getIconProps, getRootProps }\n}\n\nexport type UseNativeSelectReturn = ReturnType<typeof useNativeSelect>\n"],"mappings":";;;;;;;AAgDA,MAAa,mBAAmB,QAA8B,CAAC,MAAM;CACnE,MAAM,EACJ,OAAO,EACL,UACA,UACA,qBAAqB,MACrB,QAAQ,CAAC,GACT,aACA,UACA,GAAG,QAEL,WACA,WACA,eACE,cAAc,KAAK;CACvB,MAAM,cAAc,EAAE,YAAY;CAElC,MAAM,mBAAmB,cAAc;EACrC,IAAI,mBAA8B;EAElC,IAAI,UAAU,mBAAmB;OAC5B,IAAI,MAAM,QACb,mBAAmB,MAAM,KAAK,MAAM,UAAU;GAC5C,IAAI,WAAW,MAAM;IACnB,MAAM,EAAE,OAAO,OAAO,GAAG,SAAS;IAElC,OAAO,aAAa,oBAAC,YAAD,CAAW,CAAA,GAAG;KAChC,KAAK;KACL,UAAU,MAAM,KAAK,EAAE,OAAO,GAAG,QAAQ,UACvC,aAAa,oBAAC,UAAD,EAAQ,cAAY,MAAQ,CAAA,GAAG;MAC1C,KAAK;MACL,UAAU;MACV,GAAG;KACL,CAAC,CACH;KACA;KACA,GAAG;IACL,CAAC;GACH,OAAO;IACL,MAAM,EAAE,OAAO,GAAG,SAAS;IAE3B,OAAO,aAAa,oBAAC,UAAD,EAAQ,cAAY,MAAQ,CAAA,GAAG;KACjD,KAAK;KACL,UAAU;KACV,GAAG;IACL,CAAC;GACH;EACF,CAAC;EAEH,OACE,qBAAA,YAAA,EAAA,UAAA,CACG,cACC,oBAAC,UAAD;GAAQ,QAAQ,CAAC;GAAoB,OAAM;aACxC;EACK,CAAA,IACN,MAEH,gBACD,EAAA,CAAA;CAEN,GAAG;EAAC;EAAU;EAAO;EAAa;CAAkB,CAAC;CAErD,MAAM,eAA2B,aAC9B,WAAW;EAAE,GAAG;EAAW,GAAG;CAAM,IACrC,CAAC,SAAS,CACZ;CA2CA,OAAO;EAAE,eAzCmC,aACzC,EAAE,KAAK,GAAG,UAAU,CAAC,MACpB,WACE;GACE;GACA;GACA,UAAU,cAAc,KAAA,IAAY;GACpC,GAAG;GACH,GAAG;GACH,kBAAA,GAAA,cAAA,SAAA,CAA0B,CAAC,WAAW;GACtC,cAAc;EAChB,GACA;GACE,QAAQ,WAAW;GACnB,SAAS,WAAW;EACtB,GACA,MACA,OACA;GACE;GACA,UAAU,MAAM,YAAY;EAC9B,CACF,CAAC,CAAC,GACJ;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAQmB;EAAG,cALS,aAC9B,WAAW;GAAE,GAAG;GAAW,GAAG;EAAM,IACrC,CAAC,SAAS,CAGuB;EAAG;CAAa;AACrD"}
1
+ {"version":3,"file":"use-native-select.js","names":[],"sources":["../../../../src/components/native-select/use-native-select.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactNode } from \"react\"\nimport type { HTMLProps, PropGetter } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport { cloneElement, useCallback, useMemo } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { ariaAttr } from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\ninterface NativeSelectSharedItem extends Omit<\n HTMLProps<\"option\">,\n \"children\" | \"label\" | \"value\"\n> {\n label: string\n}\n\ninterface NativeSelectItemWithValue extends NativeSelectSharedItem {\n value?: HTMLProps<\"option\">[\"value\"]\n}\n\ninterface NativeSelectItemWithItems extends NativeSelectSharedItem {\n items: NativeSelectItemWithValue[]\n}\n\nexport type NativeSelectItem =\n | NativeSelectItemWithItems\n | NativeSelectItemWithValue\n\nexport interface UseNativeSelectProps extends HTMLProps<\"select\">, FieldProps {\n /**\n * If `true`, include placeholder in options.\n *\n * @default true\n */\n includePlaceholder?: boolean\n /**\n * If provided, generate options based on items.\n *\n * @default []\n */\n items?: NativeSelectItem[]\n /**\n * The placeholder for select.\n */\n placeholder?: string\n}\n\nexport const useNativeSelect = (props: UseNativeSelectProps = {}) => {\n const {\n props: {\n children,\n disabled,\n includePlaceholder = true,\n items = [],\n placeholder,\n readOnly,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const interactive = !(readOnly || disabled)\n\n const computedChildren = useMemo(() => {\n let computedChildren: ReactNode = null\n\n if (children) computedChildren = children\n else if (items.length)\n computedChildren = items.map((item, index) => {\n if (\"items\" in item) {\n const { items, label, ...rest } = item\n\n return cloneElement(<optgroup />, {\n key: index,\n children: items.map(({ label, ...rest }, index) =>\n cloneElement(<option aria-label={label} />, {\n key: index,\n children: label,\n ...rest,\n }),\n ),\n label,\n ...rest,\n })\n } else {\n const { label, ...rest } = item\n\n return cloneElement(<option aria-label={label} />, {\n key: index,\n children: label,\n ...rest,\n })\n }\n })\n\n return (\n <>\n {placeholder ? (\n <option hidden={!includePlaceholder} value=\"\">\n {placeholder}\n </option>\n ) : null}\n\n {computedChildren}\n </>\n )\n }, [children, items, placeholder, includePlaceholder])\n\n const getRootProps: PropGetter = useCallback(\n (props) => ({ ...dataProps, ...props }),\n [dataProps],\n )\n\n const getFieldProps: PropGetter<\"select\"> = useCallback(\n ({ ref, ...props } = {}) =>\n mergeProps(\n {\n disabled,\n readOnly,\n tabIndex: interactive ? undefined : -1,\n ...ariaProps,\n ...dataProps,\n \"aria-disabled\": ariaAttr(!interactive),\n \"aria-label\": placeholder,\n },\n {\n onBlur: eventProps.onBlur,\n onFocus: eventProps.onFocus,\n },\n rest,\n props,\n {\n ref,\n children: props.children ?? computedChildren,\n },\n )(),\n [\n interactive,\n ariaProps,\n computedChildren,\n dataProps,\n eventProps,\n rest,\n placeholder,\n disabled,\n readOnly,\n ],\n )\n\n const getIconProps: PropGetter = useCallback(\n (props) => ({ ...dataProps, ...props }),\n [dataProps],\n )\n\n return { getFieldProps, getIconProps, getRootProps }\n}\n\nexport type UseNativeSelectReturn = ReturnType<typeof useNativeSelect>\n"],"mappings":";;;;;;;AAgDA,MAAa,mBAAmB,QAA8B,CAAC,MAAM;CACnE,MAAM,EACJ,OAAO,EACL,UACA,UACA,qBAAqB,MACrB,QAAQ,CAAC,GACT,aACA,UACA,GAAG,QAEL,WACA,WACA,eACE,cAAc,KAAK;CACvB,MAAM,cAAc,EAAE,YAAY;CAElC,MAAM,mBAAmB,cAAc;EACrC,IAAI,mBAA8B;EAElC,IAAI,UAAU,mBAAmB;OAC5B,IAAI,MAAM,QACb,mBAAmB,MAAM,KAAK,MAAM,UAAU;GAC5C,IAAI,WAAW,MAAM;IACnB,MAAM,EAAE,OAAO,OAAO,GAAG,SAAS;IAElC,OAAO,aAAa,oBAAC,YAAD,CAAW,CAAA,GAAG;KAChC,KAAK;KACL,UAAU,MAAM,KAAK,EAAE,OAAO,GAAG,QAAQ,UACvC,aAAa,oBAAC,UAAD,EAAQ,cAAY,MAAQ,CAAA,GAAG;MAC1C,KAAK;MACL,UAAU;MACV,GAAG;KACL,CAAC,CACH;KACA;KACA,GAAG;IACL,CAAC;GACH,OAAO;IACL,MAAM,EAAE,OAAO,GAAG,SAAS;IAE3B,OAAO,aAAa,oBAAC,UAAD,EAAQ,cAAY,MAAQ,CAAA,GAAG;KACjD,KAAK;KACL,UAAU;KACV,GAAG;IACL,CAAC;GACH;EACF,CAAC;EAEH,OACE,qBAAA,YAAA,EAAA,UAAA,CACG,cACC,oBAAC,UAAD;GAAQ,QAAQ,CAAC;GAAoB,OAAM;GACxC,UAAA;EACK,CAAA,IACN,MAEH,gBACD,EAAA,CAAA;CAEN,GAAG;EAAC;EAAU;EAAO;EAAa;CAAkB,CAAC;CAErD,MAAM,eAA2B,aAC9B,WAAW;EAAE,GAAG;EAAW,GAAG;CAAM,IACrC,CAAC,SAAS,CACZ;CA2CA,OAAO;EAAE,eAzCmC,aACzC,EAAE,KAAK,GAAG,UAAU,CAAC,MACpB,WACE;GACE;GACA;GACA,UAAU,cAAc,KAAA,IAAY;GACpC,GAAG;GACH,GAAG;GACH,kBAAA,GAAA,cAAA,SAAA,CAA0B,CAAC,WAAW;GACtC,cAAc;EAChB,GACA;GACE,QAAQ,WAAW;GACnB,SAAS,WAAW;EACtB,GACA,MACA,OACA;GACE;GACA,UAAU,MAAM,YAAY;EAC9B,CACF,CAAC,CAAC,GACJ;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAQmB;EAAG,cALS,aAC9B,WAAW;GAAE,GAAG;GAAW,GAAG;EAAM,IACrC,CAAC,SAAS,CAGuB;EAAG;CAAa;AACrD"}
@@ -1 +1 @@
1
- {"version":3,"file":"native-table.js","names":[],"sources":["../../../../src/components/native-table/native-table.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n CSSProps,\n HTMLStyledProps,\n SimpleDirection,\n ThemeProps,\n} from \"../../core\"\nimport type { NativeTableStyle } from \"./native-table.style\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { nativeTableStyle } from \"./native-table.style\"\n\nexport interface NativeTableRootProps\n extends HTMLStyledProps<\"table\">, ThemeProps<NativeTableStyle> {\n /**\n * The CSS `table-layout` property.\n */\n layout?: CSSProps[\"tableLayout\"]\n /**\n * Whether to enable the scroll area.\n *\n * @default false\n */\n withScrollArea?: boolean\n /**\n * The props for the scroll area.\n */\n scrollAreaProps?: NativeTableAreaProps\n}\n\nconst {\n PropsContext: NativeTablePropsContext,\n usePropsContext: useNativeTablePropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<NativeTableRootProps, NativeTableStyle>(\n \"native-table\",\n nativeTableStyle,\n)\n\nexport { NativeTablePropsContext, useNativeTablePropsContext }\n\n/**\n * `NativeTable` is a component for efficiently organizing and displaying data.\n *\n * @see https://yamada-ui.com/docs/components/native-table\n */\nexport const NativeTableRoot = withProvider(\n ({ withScrollArea, scrollAreaProps, ...rest }) => {\n if (withScrollArea)\n return (\n <NativeTableScrollArea {...scrollAreaProps}>\n <styled.table {...rest} />\n </NativeTableScrollArea>\n )\n else return <styled.table {...rest} />\n },\n \"root\",\n)(undefined, ({ layout: tableLayout, ...rest }) => ({\n tableLayout,\n ...rest,\n}))\n\ninterface NativeTableAreaProps\n extends HTMLStyledProps, ThemeProps<NativeTableStyle> {}\n\nconst NativeTableScrollArea = withContext<\"div\", NativeTableAreaProps>(\n \"div\",\n \"scrollArea\",\n)({ tabIndex: 0 })\n\nexport interface CaptionProps extends HTMLStyledProps<\"caption\"> {\n /**\n * The placement of the table caption.\n *\n * @default 'end'\n */\n placement?: SimpleDirection\n}\n\nexport const Caption = withContext<\"caption\", CaptionProps>(\n \"caption\",\n \"caption\",\n)(undefined, ({ placement = \"end\", ...rest }) => ({\n \"data-placement\": placement,\n captionSide: placement === \"end\" ? \"bottom\" : \"top\",\n ...rest,\n}))\n\nexport interface TheadProps extends HTMLStyledProps<\"thead\"> {}\n\nexport const Thead = withContext<\"thead\", TheadProps>(\"thead\", \"thead\")()\n\nexport interface TbodyProps extends HTMLStyledProps<\"tbody\"> {}\n\nexport const Tbody = withContext<\"tbody\", TbodyProps>(\"tbody\", \"tbody\")()\n\nexport interface TfootProps extends HTMLStyledProps<\"tfoot\"> {}\n\nexport const Tfoot = withContext<\"tfoot\", TfootProps>(\"tfoot\", \"tfoot\")()\n\nexport interface ColgroupProps extends HTMLStyledProps<\"colgroup\"> {}\n\nexport const Colgroup = withContext<\"colgroup\", ColgroupProps>(\n \"colgroup\",\n \"colgroup\",\n)()\n\nexport interface ColProps extends HTMLStyledProps<\"col\"> {}\n\nexport const Col = withContext<\"col\", ColProps>(\"col\", \"col\")()\n\nexport interface TrProps extends HTMLStyledProps<\"tr\"> {}\n\nexport const Tr = withContext<\"tr\", TrProps>(\"tr\", \"tr\")()\n\nexport interface ThProps extends HTMLStyledProps<\"th\"> {\n /**\n * Aligns the cell content to the right.\n *\n * @default false\n */\n numeric?: boolean\n}\n\nexport const Th = withContext<\"th\", ThProps>(\"th\", \"th\")(\n undefined,\n ({ numeric, ...rest }) => ({\n \"data-numeric\": numeric,\n ...rest,\n }),\n)\n\nexport interface TdProps extends HTMLStyledProps<\"td\"> {\n /**\n * Aligns the cell content to the right.\n *\n * @default false\n */\n numeric?: boolean\n}\n\nexport const Td = withContext<\"td\", TdProps>(\"td\", \"td\")(\n undefined,\n ({ numeric, ...rest }) => ({\n \"data-numeric\": numeric,\n ...rest,\n }),\n)\n"],"mappings":";;;;;;AA8BA,MAAM,EACJ,cAAc,yBACd,iBAAiB,4BACjB,aACA,iBACE,oBACF,gBACA,gBACF;;;;;;AASA,MAAa,kBAAkB,cAC5B,EAAE,gBAAgB,iBAAiB,GAAG,WAAW;CAChD,IAAI,gBACF,OACE,oBAAC,uBAAD;EAAuB,GAAI;YACzB,oBAAC,OAAO,OAAR,EAAc,GAAI,KAAO,CAAA;CACJ,CAAA;MAEtB,OAAO,oBAAC,OAAO,OAAR,EAAc,GAAI,KAAO,CAAA;AACvC,GACA,MACF,CAAC,CAAC,KAAA,IAAY,EAAE,QAAQ,aAAa,GAAG,YAAY;CAClD;CACA,GAAG;AACL,EAAE;AAKF,MAAM,wBAAwB,YAC5B,OACA,YACF,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC;AAWjB,MAAa,UAAU,YACrB,WACA,SACF,CAAC,CAAC,KAAA,IAAY,EAAE,YAAY,OAAO,GAAG,YAAY;CAChD,kBAAkB;CAClB,aAAa,cAAc,QAAQ,WAAW;CAC9C,GAAG;AACL,EAAE;AAIF,MAAa,QAAQ,YAAiC,SAAS,OAAO,CAAC,CAAC;AAIxE,MAAa,QAAQ,YAAiC,SAAS,OAAO,CAAC,CAAC;AAIxE,MAAa,QAAQ,YAAiC,SAAS,OAAO,CAAC,CAAC;AAIxE,MAAa,WAAW,YACtB,YACA,UACF,CAAC,CAAC;AAIF,MAAa,MAAM,YAA6B,OAAO,KAAK,CAAC,CAAC;AAI9D,MAAa,KAAK,YAA2B,MAAM,IAAI,CAAC,CAAC;AAWzD,MAAa,KAAK,YAA2B,MAAM,IAAI,CAAC,CACtD,KAAA,IACC,EAAE,SAAS,GAAG,YAAY;CACzB,gBAAgB;CAChB,GAAG;AACL,EACF;AAWA,MAAa,KAAK,YAA2B,MAAM,IAAI,CAAC,CACtD,KAAA,IACC,EAAE,SAAS,GAAG,YAAY;CACzB,gBAAgB;CAChB,GAAG;AACL,EACF"}
1
+ {"version":3,"file":"native-table.js","names":[],"sources":["../../../../src/components/native-table/native-table.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n CSSProps,\n HTMLStyledProps,\n SimpleDirection,\n ThemeProps,\n} from \"../../core\"\nimport type { NativeTableStyle } from \"./native-table.style\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { nativeTableStyle } from \"./native-table.style\"\n\nexport interface NativeTableRootProps\n extends HTMLStyledProps<\"table\">, ThemeProps<NativeTableStyle> {\n /**\n * The CSS `table-layout` property.\n */\n layout?: CSSProps[\"tableLayout\"]\n /**\n * Whether to enable the scroll area.\n *\n * @default false\n */\n withScrollArea?: boolean\n /**\n * The props for the scroll area.\n */\n scrollAreaProps?: NativeTableAreaProps\n}\n\nconst {\n PropsContext: NativeTablePropsContext,\n usePropsContext: useNativeTablePropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<NativeTableRootProps, NativeTableStyle>(\n \"native-table\",\n nativeTableStyle,\n)\n\nexport { NativeTablePropsContext, useNativeTablePropsContext }\n\n/**\n * `NativeTable` is a component for efficiently organizing and displaying data.\n *\n * @see https://yamada-ui.com/docs/components/native-table\n */\nexport const NativeTableRoot = withProvider(\n ({ withScrollArea, scrollAreaProps, ...rest }) => {\n if (withScrollArea)\n return (\n <NativeTableScrollArea {...scrollAreaProps}>\n <styled.table {...rest} />\n </NativeTableScrollArea>\n )\n else return <styled.table {...rest} />\n },\n \"root\",\n)(undefined, ({ layout: tableLayout, ...rest }) => ({\n tableLayout,\n ...rest,\n}))\n\ninterface NativeTableAreaProps\n extends HTMLStyledProps, ThemeProps<NativeTableStyle> {}\n\nconst NativeTableScrollArea = withContext<\"div\", NativeTableAreaProps>(\n \"div\",\n \"scrollArea\",\n)({ tabIndex: 0 })\n\nexport interface CaptionProps extends HTMLStyledProps<\"caption\"> {\n /**\n * The placement of the table caption.\n *\n * @default 'end'\n */\n placement?: SimpleDirection\n}\n\nexport const Caption = withContext<\"caption\", CaptionProps>(\n \"caption\",\n \"caption\",\n)(undefined, ({ placement = \"end\", ...rest }) => ({\n \"data-placement\": placement,\n captionSide: placement === \"end\" ? \"bottom\" : \"top\",\n ...rest,\n}))\n\nexport interface TheadProps extends HTMLStyledProps<\"thead\"> {}\n\nexport const Thead = withContext<\"thead\", TheadProps>(\"thead\", \"thead\")()\n\nexport interface TbodyProps extends HTMLStyledProps<\"tbody\"> {}\n\nexport const Tbody = withContext<\"tbody\", TbodyProps>(\"tbody\", \"tbody\")()\n\nexport interface TfootProps extends HTMLStyledProps<\"tfoot\"> {}\n\nexport const Tfoot = withContext<\"tfoot\", TfootProps>(\"tfoot\", \"tfoot\")()\n\nexport interface ColgroupProps extends HTMLStyledProps<\"colgroup\"> {}\n\nexport const Colgroup = withContext<\"colgroup\", ColgroupProps>(\n \"colgroup\",\n \"colgroup\",\n)()\n\nexport interface ColProps extends HTMLStyledProps<\"col\"> {}\n\nexport const Col = withContext<\"col\", ColProps>(\"col\", \"col\")()\n\nexport interface TrProps extends HTMLStyledProps<\"tr\"> {}\n\nexport const Tr = withContext<\"tr\", TrProps>(\"tr\", \"tr\")()\n\nexport interface ThProps extends HTMLStyledProps<\"th\"> {\n /**\n * Aligns the cell content to the right.\n *\n * @default false\n */\n numeric?: boolean\n}\n\nexport const Th = withContext<\"th\", ThProps>(\"th\", \"th\")(\n undefined,\n ({ numeric, ...rest }) => ({\n \"data-numeric\": numeric,\n ...rest,\n }),\n)\n\nexport interface TdProps extends HTMLStyledProps<\"td\"> {\n /**\n * Aligns the cell content to the right.\n *\n * @default false\n */\n numeric?: boolean\n}\n\nexport const Td = withContext<\"td\", TdProps>(\"td\", \"td\")(\n undefined,\n ({ numeric, ...rest }) => ({\n \"data-numeric\": numeric,\n ...rest,\n }),\n)\n"],"mappings":";;;;;;AA8BA,MAAM,EACJ,cAAc,yBACd,iBAAiB,4BACjB,aACA,iBACE,oBACF,gBACA,gBACF;;;;;;AASA,MAAa,kBAAkB,cAC5B,EAAE,gBAAgB,iBAAiB,GAAG,WAAW;CAChD,IAAI,gBACF,OACE,oBAAC,uBAAD;EAAuB,GAAI;EACzB,UAAA,oBAAC,OAAO,OAAR,EAAc,GAAI,KAAO,CAAA;CACJ,CAAA;MAEtB,OAAO,oBAAC,OAAO,OAAR,EAAc,GAAI,KAAO,CAAA;AACvC,GACA,MACF,CAAC,CAAC,KAAA,IAAY,EAAE,QAAQ,aAAa,GAAG,YAAY;CAClD;CACA,GAAG;AACL,EAAE;AAKF,MAAM,wBAAwB,YAC5B,OACA,YACF,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC;AAWjB,MAAa,UAAU,YACrB,WACA,SACF,CAAC,CAAC,KAAA,IAAY,EAAE,YAAY,OAAO,GAAG,YAAY;CAChD,kBAAkB;CAClB,aAAa,cAAc,QAAQ,WAAW;CAC9C,GAAG;AACL,EAAE;AAIF,MAAa,QAAQ,YAAiC,SAAS,OAAO,CAAC,CAAC;AAIxE,MAAa,QAAQ,YAAiC,SAAS,OAAO,CAAC,CAAC;AAIxE,MAAa,QAAQ,YAAiC,SAAS,OAAO,CAAC,CAAC;AAIxE,MAAa,WAAW,YACtB,YACA,UACF,CAAC,CAAC;AAIF,MAAa,MAAM,YAA6B,OAAO,KAAK,CAAC,CAAC;AAI9D,MAAa,KAAK,YAA2B,MAAM,IAAI,CAAC,CAAC;AAWzD,MAAa,KAAK,YAA2B,MAAM,IAAI,CAAC,CACtD,KAAA,IACC,EAAE,SAAS,GAAG,YAAY;CACzB,gBAAgB;CAChB,GAAG;AACL,EACF;AAWA,MAAa,KAAK,YAA2B,MAAM,IAAI,CAAC,CACtD,KAAA,IACC,EAAE,SAAS,GAAG,YAAY;CACzB,gBAAgB;CAChB,GAAG;AACL,EACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"notice-provider.js","names":[],"sources":["../../../../src/components/notice/notice-provider.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, RefObject } from \"react\"\nimport type {\n HTMLStyledProps,\n NoticeConfig,\n NoticePlacement,\n ThemeProps,\n} from \"../../core\"\nimport type { NoticeStyle } from \"./notice.style\"\nimport { createContext, createRef, use, useId, useMemo, useRef } from \"react\"\nimport { Portal } from \"../portal\"\nimport { NoticeRoot, PLACEMENT_MAP } from \"./notice\"\n\nexport interface NoticeProviderProps\n extends HTMLStyledProps, NoticeConfig, ThemeProps<NoticeStyle> {\n /**\n * Container ref for the portal.\n */\n containerRef?: RefObject<HTMLElement>\n}\n\ninterface NoticeState {\n limit: number\n placement: NoticePlacement\n}\n\nexport interface NoticeMethods {\n getId: (placement: NoticePlacement) => string\n getLimit: (placement: NoticePlacement) => number\n updateLimit: (state: NoticeState) => void\n}\n\ninterface NoticeContext extends NoticeMethods {}\n\nconst NoticeContext = createContext({} as NoticeContext)\n\nexport type Controller = ReturnType<typeof createController>\n\nconst createController = () => ({\n getLimit: createRef<NoticeMethods[\"getLimit\"]>(),\n updateLimit: createRef<NoticeMethods[\"updateLimit\"]>(),\n})\n\nconst createMethods = (\n id: string,\n refs: {\n [K in NoticePlacement]?: RefObject<Controller>\n },\n defaultLimit: number,\n): NoticeMethods => ({\n getId: (placement) => {\n return `${id}-${placement}`\n },\n getLimit: (placement) => {\n const method = refs[placement]?.current.getLimit.current\n\n return method?.(placement) ?? defaultLimit\n },\n updateLimit: (state) => {\n const { placement } = state\n const method = refs[placement]?.current.updateLimit.current\n\n method?.(state)\n },\n})\n\nexport const NoticeProvider: FC<NoticeProviderProps> = ({\n children,\n containerRef,\n expand = false,\n limit = 3,\n}) => {\n const placementMap = useRef<{\n [K in NoticePlacement]?: RefObject<Controller>\n }>({})\n const id = useId()\n\n const value = useMemo(\n () => ({ ...createMethods(id, placementMap.current, limit) }),\n [id, limit],\n )\n\n const components = useMemo(() => {\n return (Object.keys(PLACEMENT_MAP) as NoticePlacement[]).map(\n (placement) => {\n if (!placementMap.current[placement])\n placementMap.current[placement] = { current: createController() }\n\n return (\n <NoticeRoot\n key={placement}\n ref={placementMap.current[placement]}\n expand={expand}\n limit={limit}\n placement={placement}\n />\n )\n },\n )\n }, [limit, expand])\n\n return (\n <NoticeContext value={value}>\n {children}\n <Portal containerRef={containerRef}>{components}</Portal>\n </NoticeContext>\n )\n}\n\nexport const useNoticeContext = (): NoticeContext => {\n const context = use(NoticeContext)\n\n return context\n}\n"],"mappings":";;;;;;AAmCA,MAAM,gBAAgB,cAAc,CAAC,CAAkB;AAIvD,MAAM,0BAA0B;CAC9B,UAAU,UAAqC;CAC/C,aAAa,UAAwC;AACvD;AAEA,MAAM,iBACJ,IACA,MAGA,kBACmB;CACnB,QAAQ,cAAc;EACpB,OAAO,GAAG,GAAG,GAAG;CAClB;CACA,WAAW,cAAc;EACvB,MAAM,SAAS,KAAK,UAAU,EAAE,QAAQ,SAAS;EAEjD,OAAO,SAAS,SAAS,KAAK;CAChC;CACA,cAAc,UAAU;EACtB,MAAM,EAAE,cAAc;EACtB,MAAM,SAAS,KAAK,UAAU,EAAE,QAAQ,YAAY;EAEpD,SAAS,KAAK;CAChB;AACF;AAEA,MAAa,kBAA2C,EACtD,UACA,cACA,SAAS,OACT,QAAQ,QACJ;CACJ,MAAM,eAAe,OAElB,CAAC,CAAC;CACL,MAAM,KAAK,MAAM;CAEjB,MAAM,QAAQ,eACL,EAAE,GAAG,cAAc,IAAI,aAAa,SAAS,KAAK,EAAE,IAC3D,CAAC,IAAI,KAAK,CACZ;CAEA,MAAM,aAAa,cAAc;EAC/B,OAAQ,OAAO,KAAK,aAAa,CAAC,CAAuB,KACtD,cAAc;GACb,IAAI,CAAC,aAAa,QAAQ,YACxB,aAAa,QAAQ,aAAa,EAAE,SAAS,iBAAiB,EAAE;GAElE,OACE,oBAAC,YAAD;IAEE,KAAK,aAAa,QAAQ;IAClB;IACD;IACI;GACZ,GALM,SAKN;EAEL,CACF;CACF,GAAG,CAAC,OAAO,MAAM,CAAC;CAElB,OACE,qBAAC,eAAD;EAAsB;YAAtB,CACG,UACD,oBAAC,QAAD;GAAsB;aAAe;EAAmB,CAAA,CAC3C;;AAEnB;AAEA,MAAa,yBAAwC;CAGnD,OAFgB,IAAI,aAEP;AACf"}
1
+ {"version":3,"file":"notice-provider.js","names":[],"sources":["../../../../src/components/notice/notice-provider.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, RefObject } from \"react\"\nimport type {\n HTMLStyledProps,\n NoticeConfig,\n NoticePlacement,\n ThemeProps,\n} from \"../../core\"\nimport type { NoticeStyle } from \"./notice.style\"\nimport { createContext, createRef, use, useId, useMemo, useRef } from \"react\"\nimport { Portal } from \"../portal\"\nimport { NoticeRoot, PLACEMENT_MAP } from \"./notice\"\n\nexport interface NoticeProviderProps\n extends HTMLStyledProps, NoticeConfig, ThemeProps<NoticeStyle> {\n /**\n * Container ref for the portal.\n */\n containerRef?: RefObject<HTMLElement>\n}\n\ninterface NoticeState {\n limit: number\n placement: NoticePlacement\n}\n\nexport interface NoticeMethods {\n getId: (placement: NoticePlacement) => string\n getLimit: (placement: NoticePlacement) => number\n updateLimit: (state: NoticeState) => void\n}\n\ninterface NoticeContext extends NoticeMethods {}\n\nconst NoticeContext = createContext({} as NoticeContext)\n\nexport type Controller = ReturnType<typeof createController>\n\nconst createController = () => ({\n getLimit: createRef<NoticeMethods[\"getLimit\"]>(),\n updateLimit: createRef<NoticeMethods[\"updateLimit\"]>(),\n})\n\nconst createMethods = (\n id: string,\n refs: {\n [K in NoticePlacement]?: RefObject<Controller>\n },\n defaultLimit: number,\n): NoticeMethods => ({\n getId: (placement) => {\n return `${id}-${placement}`\n },\n getLimit: (placement) => {\n const method = refs[placement]?.current.getLimit.current\n\n return method?.(placement) ?? defaultLimit\n },\n updateLimit: (state) => {\n const { placement } = state\n const method = refs[placement]?.current.updateLimit.current\n\n method?.(state)\n },\n})\n\nexport const NoticeProvider: FC<NoticeProviderProps> = ({\n children,\n containerRef,\n expand = false,\n limit = 3,\n}) => {\n const placementMap = useRef<{\n [K in NoticePlacement]?: RefObject<Controller>\n }>({})\n const id = useId()\n\n const value = useMemo(\n () => ({ ...createMethods(id, placementMap.current, limit) }),\n [id, limit],\n )\n\n const components = useMemo(() => {\n return (Object.keys(PLACEMENT_MAP) as NoticePlacement[]).map(\n (placement) => {\n if (!placementMap.current[placement])\n placementMap.current[placement] = { current: createController() }\n\n return (\n <NoticeRoot\n key={placement}\n ref={placementMap.current[placement]}\n expand={expand}\n limit={limit}\n placement={placement}\n />\n )\n },\n )\n }, [limit, expand])\n\n return (\n <NoticeContext value={value}>\n {children}\n <Portal containerRef={containerRef}>{components}</Portal>\n </NoticeContext>\n )\n}\n\nexport const useNoticeContext = (): NoticeContext => {\n const context = use(NoticeContext)\n\n return context\n}\n"],"mappings":";;;;;;AAmCA,MAAM,gBAAgB,cAAc,CAAC,CAAkB;AAIvD,MAAM,0BAA0B;CAC9B,UAAU,UAAqC;CAC/C,aAAa,UAAwC;AACvD;AAEA,MAAM,iBACJ,IACA,MAGA,kBACmB;CACnB,QAAQ,cAAc;EACpB,OAAO,GAAG,GAAG,GAAG;CAClB;CACA,WAAW,cAAc;EACvB,MAAM,SAAS,KAAK,UAAU,EAAE,QAAQ,SAAS;EAEjD,OAAO,SAAS,SAAS,KAAK;CAChC;CACA,cAAc,UAAU;EACtB,MAAM,EAAE,cAAc;EACtB,MAAM,SAAS,KAAK,UAAU,EAAE,QAAQ,YAAY;EAEpD,SAAS,KAAK;CAChB;AACF;AAEA,MAAa,kBAA2C,EACtD,UACA,cACA,SAAS,OACT,QAAQ,QACJ;CACJ,MAAM,eAAe,OAElB,CAAC,CAAC;CACL,MAAM,KAAK,MAAM;CAEjB,MAAM,QAAQ,eACL,EAAE,GAAG,cAAc,IAAI,aAAa,SAAS,KAAK,EAAE,IAC3D,CAAC,IAAI,KAAK,CACZ;CAEA,MAAM,aAAa,cAAc;EAC/B,OAAQ,OAAO,KAAK,aAAa,CAAC,CAAuB,KACtD,cAAc;GACb,IAAI,CAAC,aAAa,QAAQ,YACxB,aAAa,QAAQ,aAAa,EAAE,SAAS,iBAAiB,EAAE;GAElE,OACE,oBAAC,YAAD;IAEE,KAAK,aAAa,QAAQ;IAClB;IACD;IACI;GACZ,GALM,SAKN;EAEL,CACF;CACF,GAAG,CAAC,OAAO,MAAM,CAAC;CAElB,OACE,qBAAC,eAAD;EAAsB;EAAtB,UAAA,CACG,UACD,oBAAC,QAAD;GAAsB;GAAe,UAAA;EAAmB,CAAA,CAC3C;;AAEnB;AAEA,MAAa,yBAAwC;CAGnD,OAFgB,IAAI,aAEP;AACf"}