@yamada-ui/react 2.0.10-dev-20260224132828 → 2.0.10-dev-20260226095744

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 (357) hide show
  1. package/dist/cjs/components/accordion/use-accordion.cjs.map +1 -1
  2. package/dist/cjs/components/airy/airy.cjs.map +1 -1
  3. package/dist/cjs/components/autocomplete/use-autocomplete.cjs.map +1 -1
  4. package/dist/cjs/components/avatar/use-avatar.cjs.map +1 -1
  5. package/dist/cjs/components/button/button.cjs.map +1 -1
  6. package/dist/cjs/components/calendar/use-calendar.cjs.map +1 -1
  7. package/dist/cjs/components/checkbox/use-checkbox.cjs.map +1 -1
  8. package/dist/cjs/components/color-picker/use-color-picker.cjs.map +1 -1
  9. package/dist/cjs/components/date-picker/use-date-picker.cjs.map +1 -1
  10. package/dist/cjs/components/dropzone/use-dropzone.cjs.map +1 -1
  11. package/dist/cjs/components/field/field.cjs.map +1 -1
  12. package/dist/cjs/components/file-input/file-input.cjs.map +1 -1
  13. package/dist/cjs/components/flip/flip.cjs.map +1 -1
  14. package/dist/cjs/components/for/for.cjs.map +1 -1
  15. package/dist/cjs/components/highlight/highlight.cjs.map +1 -1
  16. package/dist/cjs/components/infinite-scroll-area/use-infinite-scroll.cjs.map +1 -1
  17. package/dist/cjs/components/loading/loading-provider.cjs.map +1 -1
  18. package/dist/cjs/components/menu/use-menu.cjs.map +1 -1
  19. package/dist/cjs/components/notice/use-notice.cjs.map +1 -1
  20. package/dist/cjs/components/pagination/use-pagination.cjs.map +1 -1
  21. package/dist/cjs/components/password-input/use-strength-meter.cjs.map +1 -1
  22. package/dist/cjs/components/picture/picture.cjs.map +1 -1
  23. package/dist/cjs/components/pin-input/use-pin-input.cjs.map +1 -1
  24. package/dist/cjs/components/radio/use-radio.cjs.map +1 -1
  25. package/dist/cjs/components/rating/use-rating.cjs.map +1 -1
  26. package/dist/cjs/components/resizable/use-resizable.cjs.map +1 -1
  27. package/dist/cjs/components/ripple/ripple.cjs.map +1 -1
  28. package/dist/cjs/components/rotate/rotate.cjs.map +1 -1
  29. package/dist/cjs/components/saturation-slider/use-saturation-slider.cjs.map +1 -1
  30. package/dist/cjs/components/scroll-area/use-scroll-area.cjs.map +1 -1
  31. package/dist/cjs/components/segmented-control/use-segmented-control.cjs.map +1 -1
  32. package/dist/cjs/components/select/use-select.cjs.map +1 -1
  33. package/dist/cjs/components/slider/slider.cjs.map +1 -1
  34. package/dist/cjs/components/slider/use-slider.cjs.map +1 -1
  35. package/dist/cjs/components/snacks/snacks.cjs.map +1 -1
  36. package/dist/cjs/components/switch/use-switch.cjs.map +1 -1
  37. package/dist/cjs/components/table/table.cjs.map +1 -1
  38. package/dist/cjs/components/textarea/use-autosize.cjs.map +1 -1
  39. package/dist/cjs/components/toggle/use-toggle-group.cjs.map +1 -1
  40. package/dist/cjs/core/components/use-component-style.cjs.map +1 -1
  41. package/dist/cjs/core/css/styles.cjs.map +1 -1
  42. package/dist/cjs/core/css/utils.cjs.map +1 -1
  43. package/dist/cjs/core/system/breakpoint.cjs.map +1 -1
  44. package/dist/cjs/core/system/color-mode-provider.cjs.map +1 -1
  45. package/dist/cjs/core/system/layer.cjs.map +1 -1
  46. package/dist/cjs/core/system/storage-script.cjs.map +1 -1
  47. package/dist/cjs/core/system/styled.cjs.map +1 -1
  48. package/dist/cjs/core/system/use-system-color-mode.cjs.map +1 -1
  49. package/dist/cjs/hooks/use-async/index.cjs.map +1 -1
  50. package/dist/cjs/hooks/use-boolean/index.cjs.map +1 -1
  51. package/dist/cjs/hooks/use-clickable/index.cjs.map +1 -1
  52. package/dist/cjs/hooks/use-combobox/index.cjs.map +1 -1
  53. package/dist/cjs/hooks/use-controllable-state/index.cjs.map +1 -1
  54. package/dist/cjs/hooks/use-local-storage/index.cjs.map +1 -1
  55. package/dist/cjs/providers/i18n-provider/i18n-provider.cjs.map +1 -1
  56. package/dist/cjs/utils/context.cjs.map +1 -1
  57. package/dist/cjs/utils/store.cjs.map +1 -1
  58. package/dist/esm/components/accordion/use-accordion.js.map +1 -1
  59. package/dist/esm/components/airy/airy.js.map +1 -1
  60. package/dist/esm/components/autocomplete/use-autocomplete.js.map +1 -1
  61. package/dist/esm/components/avatar/use-avatar.js.map +1 -1
  62. package/dist/esm/components/button/button.js.map +1 -1
  63. package/dist/esm/components/calendar/use-calendar.js.map +1 -1
  64. package/dist/esm/components/checkbox/use-checkbox.js.map +1 -1
  65. package/dist/esm/components/color-picker/use-color-picker.js.map +1 -1
  66. package/dist/esm/components/date-picker/use-date-picker.js.map +1 -1
  67. package/dist/esm/components/dropzone/use-dropzone.js.map +1 -1
  68. package/dist/esm/components/field/field.js.map +1 -1
  69. package/dist/esm/components/file-input/file-input.js.map +1 -1
  70. package/dist/esm/components/flip/flip.js.map +1 -1
  71. package/dist/esm/components/for/for.js.map +1 -1
  72. package/dist/esm/components/highlight/highlight.js.map +1 -1
  73. package/dist/esm/components/infinite-scroll-area/use-infinite-scroll.js.map +1 -1
  74. package/dist/esm/components/loading/loading-provider.js.map +1 -1
  75. package/dist/esm/components/menu/use-menu.js.map +1 -1
  76. package/dist/esm/components/notice/use-notice.js.map +1 -1
  77. package/dist/esm/components/pagination/use-pagination.js.map +1 -1
  78. package/dist/esm/components/password-input/use-strength-meter.js.map +1 -1
  79. package/dist/esm/components/picture/picture.js.map +1 -1
  80. package/dist/esm/components/pin-input/use-pin-input.js.map +1 -1
  81. package/dist/esm/components/radio/use-radio.js.map +1 -1
  82. package/dist/esm/components/rating/use-rating.js.map +1 -1
  83. package/dist/esm/components/resizable/use-resizable.js.map +1 -1
  84. package/dist/esm/components/ripple/ripple.js.map +1 -1
  85. package/dist/esm/components/rotate/rotate.js.map +1 -1
  86. package/dist/esm/components/saturation-slider/use-saturation-slider.js.map +1 -1
  87. package/dist/esm/components/scroll-area/use-scroll-area.js.map +1 -1
  88. package/dist/esm/components/segmented-control/use-segmented-control.js.map +1 -1
  89. package/dist/esm/components/select/use-select.js.map +1 -1
  90. package/dist/esm/components/slider/slider.js.map +1 -1
  91. package/dist/esm/components/slider/use-slider.js.map +1 -1
  92. package/dist/esm/components/snacks/snacks.js.map +1 -1
  93. package/dist/esm/components/switch/use-switch.js.map +1 -1
  94. package/dist/esm/components/table/table.js.map +1 -1
  95. package/dist/esm/components/textarea/use-autosize.js.map +1 -1
  96. package/dist/esm/components/toggle/use-toggle-group.js.map +1 -1
  97. package/dist/esm/core/components/use-component-style.js.map +1 -1
  98. package/dist/esm/core/css/styles.js.map +1 -1
  99. package/dist/esm/core/css/utils.js.map +1 -1
  100. package/dist/esm/core/system/breakpoint.js.map +1 -1
  101. package/dist/esm/core/system/color-mode-provider.js.map +1 -1
  102. package/dist/esm/core/system/layer.js.map +1 -1
  103. package/dist/esm/core/system/storage-script.js.map +1 -1
  104. package/dist/esm/core/system/styled.js.map +1 -1
  105. package/dist/esm/core/system/use-system-color-mode.js.map +1 -1
  106. package/dist/esm/hooks/use-async/index.js.map +1 -1
  107. package/dist/esm/hooks/use-boolean/index.js.map +1 -1
  108. package/dist/esm/hooks/use-clickable/index.js.map +1 -1
  109. package/dist/esm/hooks/use-combobox/index.js.map +1 -1
  110. package/dist/esm/hooks/use-controllable-state/index.js.map +1 -1
  111. package/dist/esm/hooks/use-local-storage/index.js.map +1 -1
  112. package/dist/esm/providers/i18n-provider/i18n-provider.js.map +1 -1
  113. package/dist/esm/utils/context.js.map +1 -1
  114. package/dist/esm/utils/store.js.map +1 -1
  115. package/dist/types/components/accordion/accordion.d.ts +2 -4
  116. package/dist/types/components/accordion/accordion.style.d.ts +1 -1
  117. package/dist/types/components/accordion/use-accordion.d.ts +15 -15
  118. package/dist/types/components/airy/airy.d.ts +10 -11
  119. package/dist/types/components/alert/alert.d.ts +2 -5
  120. package/dist/types/components/alpha-slider/alpha-slider.d.ts +2 -3
  121. package/dist/types/components/aspect-ratio/aspect-ratio.d.ts +2 -2
  122. package/dist/types/components/autocomplete/autocomplete.d.ts +2 -4
  123. package/dist/types/components/autocomplete/autocomplete.style.d.ts +1 -1
  124. package/dist/types/components/autocomplete/use-autocomplete.d.ts +18 -20
  125. package/dist/types/components/avatar/avatar.d.ts +5 -5
  126. package/dist/types/components/avatar/avatar.style.d.ts +1 -1
  127. package/dist/types/components/avatar/use-avatar-group.d.ts +2 -2
  128. package/dist/types/components/avatar/use-avatar.d.ts +19 -19
  129. package/dist/types/components/badge/badge.d.ts +2 -2
  130. package/dist/types/components/bleed/bleed.d.ts +2 -2
  131. package/dist/types/components/blockquote/blockquote.d.ts +2 -2
  132. package/dist/types/components/breadcrumb/breadcrumb.d.ts +2 -2
  133. package/dist/types/components/breadcrumb/breadcrumb.style.d.ts +1 -1
  134. package/dist/types/components/breadcrumb/use-breadcrumb.d.ts +2 -2
  135. package/dist/types/components/button/button-group.d.ts +0 -1
  136. package/dist/types/components/button/button.d.ts +8 -9
  137. package/dist/types/components/button/icon-button.d.ts +2 -2
  138. package/dist/types/components/calendar/calendar.d.ts +2 -3
  139. package/dist/types/components/calendar/calendar.style.d.ts +2 -2
  140. package/dist/types/components/calendar/use-calendar.d.ts +12 -13
  141. package/dist/types/components/card/card.d.ts +2 -2
  142. package/dist/types/components/carousel/carousel.d.ts +2 -3
  143. package/dist/types/components/carousel/carousel.style.d.ts +2 -2
  144. package/dist/types/components/carousel/use-carousel.d.ts +3 -3
  145. package/dist/types/components/center/center.d.ts +2 -2
  146. package/dist/types/components/checkbox/checkbox-group.d.ts +0 -2
  147. package/dist/types/components/checkbox/checkbox.d.ts +3 -4
  148. package/dist/types/components/checkbox/use-checkbox-group.d.ts +2 -3
  149. package/dist/types/components/checkbox/use-checkbox.d.ts +8 -9
  150. package/dist/types/components/checkbox-card/checkbox-card-group.d.ts +0 -3
  151. package/dist/types/components/checkbox-card/checkbox-card.d.ts +3 -5
  152. package/dist/types/components/circle-progress/circle-progress.d.ts +2 -3
  153. package/dist/types/components/close-button/close-button.d.ts +2 -3
  154. package/dist/types/components/code/code.d.ts +2 -2
  155. package/dist/types/components/collapse/collapse.d.ts +2 -3
  156. package/dist/types/components/color-picker/color-picker.d.ts +2 -6
  157. package/dist/types/components/color-picker/use-color-picker.d.ts +12 -15
  158. package/dist/types/components/color-selector/color-selector.d.ts +2 -6
  159. package/dist/types/components/color-selector/color-selector.style.d.ts +2 -2
  160. package/dist/types/components/color-selector/use-color-selector.d.ts +3 -5
  161. package/dist/types/components/color-swatch/color-swatch.d.ts +2 -2
  162. package/dist/types/components/container/container.d.ts +2 -2
  163. package/dist/types/components/data-list/data-list.d.ts +2 -2
  164. package/dist/types/components/data-list/data-list.style.d.ts +1 -1
  165. package/dist/types/components/date-picker/date-picker.d.ts +2 -5
  166. package/dist/types/components/date-picker/use-date-picker.d.ts +21 -24
  167. package/dist/types/components/drawer/drawer.d.ts +2 -5
  168. package/dist/types/components/drawer/drawer.style.d.ts +2 -2
  169. package/dist/types/components/drawer/use-drawer.d.ts +0 -2
  170. package/dist/types/components/dropzone/dropzone.d.ts +4 -7
  171. package/dist/types/components/dropzone/use-dropzone.d.ts +4 -5
  172. package/dist/types/components/editable/editable.d.ts +4 -5
  173. package/dist/types/components/editable/use-editable.d.ts +2 -3
  174. package/dist/types/components/em/em.d.ts +2 -2
  175. package/dist/types/components/empty-state/empty-state.d.ts +2 -2
  176. package/dist/types/components/fade/fade.d.ts +2 -3
  177. package/dist/types/components/fade-scale/fade-scale.d.ts +0 -1
  178. package/dist/types/components/field/field.d.ts +4 -4
  179. package/dist/types/components/field/use-field-props.d.ts +3 -3
  180. package/dist/types/components/fieldset/fieldset.d.ts +3 -4
  181. package/dist/types/components/file-button/file-button.d.ts +2 -4
  182. package/dist/types/components/file-button/use-file-button.d.ts +18 -20
  183. package/dist/types/components/file-input/file-input.d.ts +8 -10
  184. package/dist/types/components/file-input/file-input.style.d.ts +1 -1
  185. package/dist/types/components/file-input/use-file-input.d.ts +15 -16
  186. package/dist/types/components/flex/flex.d.ts +2 -2
  187. package/dist/types/components/flip/flip.d.ts +12 -13
  188. package/dist/types/components/flip/flip.style.d.ts +1 -1
  189. package/dist/types/components/float/float.d.ts +2 -2
  190. package/dist/types/components/for/for.d.ts +8 -8
  191. package/dist/types/components/format/format-byte.d.ts +4 -4
  192. package/dist/types/components/format/format-date-time.d.ts +4 -4
  193. package/dist/types/components/format/format-number.d.ts +2 -2
  194. package/dist/types/components/format/use-format-byte.d.ts +0 -1
  195. package/dist/types/components/format/use-format-date-time.d.ts +0 -1
  196. package/dist/types/components/format/use-format-number.d.ts +0 -1
  197. package/dist/types/components/grid/grid-item.d.ts +2 -2
  198. package/dist/types/components/grid/grid.d.ts +2 -2
  199. package/dist/types/components/group/group.d.ts +2 -3
  200. package/dist/types/components/group/use-group.d.ts +2 -2
  201. package/dist/types/components/heading/heading.d.ts +2 -2
  202. package/dist/types/components/highlight/highlight.d.ts +4 -6
  203. package/dist/types/components/hue-slider/hue-slider.d.ts +3 -4
  204. package/dist/types/components/icon/icon.d.ts +5 -5
  205. package/dist/types/components/image/image.d.ts +2 -2
  206. package/dist/types/components/indicator/indicator.d.ts +4 -5
  207. package/dist/types/components/infinite-scroll-area/infinite-scroll-area.d.ts +2 -2
  208. package/dist/types/components/infinite-scroll-area/use-infinite-scroll.d.ts +2 -2
  209. package/dist/types/components/input/input-addon.d.ts +2 -2
  210. package/dist/types/components/input/input-element.d.ts +2 -2
  211. package/dist/types/components/input/input-group.d.ts +0 -2
  212. package/dist/types/components/input/input.d.ts +2 -3
  213. package/dist/types/components/kbd/kbd.d.ts +2 -2
  214. package/dist/types/components/link/link.d.ts +2 -2
  215. package/dist/types/components/link-box/link-box.d.ts +2 -2
  216. package/dist/types/components/list/list.d.ts +2 -2
  217. package/dist/types/components/list/list.style.d.ts +2 -2
  218. package/dist/types/components/loading/loading-provider.d.ts +3 -3
  219. package/dist/types/components/loading/loading.d.ts +3 -4
  220. package/dist/types/components/loading/use-loading-component.d.ts +0 -1
  221. package/dist/types/components/mark/mark.d.ts +2 -2
  222. package/dist/types/components/menu/menu.d.ts +2 -3
  223. package/dist/types/components/menu/menu.style.d.ts +2 -2
  224. package/dist/types/components/menu/use-menu.d.ts +17 -17
  225. package/dist/types/components/modal/modal.d.ts +2 -6
  226. package/dist/types/components/modal/modal.style.d.ts +2 -2
  227. package/dist/types/components/native-select/native-select.d.ts +2 -4
  228. package/dist/types/components/native-select/use-native-select.d.ts +0 -1
  229. package/dist/types/components/native-table/native-table.d.ts +4 -4
  230. package/dist/types/components/notice/notice.style.d.ts +1 -1
  231. package/dist/types/components/notice/use-notice.d.ts +4 -7
  232. package/dist/types/components/number-input/number-input.d.ts +2 -3
  233. package/dist/types/components/number-input/number-input.style.d.ts +1 -1
  234. package/dist/types/components/number-input/use-number-input.d.ts +0 -1
  235. package/dist/types/components/pagination/pagination.d.ts +2 -3
  236. package/dist/types/components/pagination/pagination.style.d.ts +1 -1
  237. package/dist/types/components/pagination/use-pagination.d.ts +6 -6
  238. package/dist/types/components/password-input/password-input.d.ts +2 -3
  239. package/dist/types/components/password-input/strength-meter.d.ts +2 -2
  240. package/dist/types/components/password-input/use-password-input.d.ts +2 -3
  241. package/dist/types/components/password-input/use-strength-meter.d.ts +4 -4
  242. package/dist/types/components/picture/picture.d.ts +4 -5
  243. package/dist/types/components/pin-input/pin-input.d.ts +2 -4
  244. package/dist/types/components/pin-input/use-pin-input.d.ts +18 -19
  245. package/dist/types/components/popover/popover.d.ts +2 -3
  246. package/dist/types/components/progress/progress.d.ts +4 -4
  247. package/dist/types/components/progress/use-progress.d.ts +706 -706
  248. package/dist/types/components/radio/radio-group.d.ts +0 -2
  249. package/dist/types/components/radio/radio.d.ts +4 -5
  250. package/dist/types/components/radio/use-radio-group.d.ts +2 -3
  251. package/dist/types/components/radio/use-radio.d.ts +8 -9
  252. package/dist/types/components/radio-card/radio-card-group.d.ts +0 -3
  253. package/dist/types/components/radio-card/radio-card.d.ts +4 -6
  254. package/dist/types/components/rating/rating.style.d.ts +2 -2
  255. package/dist/types/components/rating/use-rating.d.ts +16 -17
  256. package/dist/types/components/reorder/reorder.d.ts +2 -3
  257. package/dist/types/components/reorder/reorder.style.d.ts +1 -1
  258. package/dist/types/components/reorder/use-reorder.d.ts +3 -3
  259. package/dist/types/components/resizable/resizable.d.ts +2 -2
  260. package/dist/types/components/resizable/resizable.style.d.ts +2 -2
  261. package/dist/types/components/resizable/use-resizable.d.ts +8 -8
  262. package/dist/types/components/ripple/ripple.d.ts +8 -9
  263. package/dist/types/components/ripple/use-ripple.d.ts +2 -2
  264. package/dist/types/components/rotate/rotate.d.ts +10 -11
  265. package/dist/types/components/saturation-slider/saturation-slider.d.ts +2 -2
  266. package/dist/types/components/saturation-slider/use-saturation-slider.d.ts +15 -16
  267. package/dist/types/components/scroll-area/scroll-area.d.ts +2 -2
  268. package/dist/types/components/scroll-area/use-scroll-area.d.ts +6 -6
  269. package/dist/types/components/segmented-control/segmented-control.d.ts +2 -3
  270. package/dist/types/components/segmented-control/segmented-control.style.d.ts +2 -2
  271. package/dist/types/components/segmented-control/use-segmented-control.d.ts +13 -14
  272. package/dist/types/components/select/select.d.ts +2 -4
  273. package/dist/types/components/select/select.style.d.ts +1 -1
  274. package/dist/types/components/select/use-select.d.ts +16 -18
  275. package/dist/types/components/separator/separator.d.ts +2 -2
  276. package/dist/types/components/simple-grid/simple-grid.d.ts +2 -3
  277. package/dist/types/components/skeleton/skeleton.d.ts +2 -2
  278. package/dist/types/components/slide/slide.d.ts +2 -3
  279. package/dist/types/components/slide-fade/slide-fade.d.ts +2 -3
  280. package/dist/types/components/slider/slider.d.ts +7 -7
  281. package/dist/types/components/slider/use-slider.d.ts +16 -17
  282. package/dist/types/components/snacks/snacks.d.ts +4 -6
  283. package/dist/types/components/snacks/use-snacks.d.ts +0 -1
  284. package/dist/types/components/stack/h-stack.d.ts +2 -2
  285. package/dist/types/components/stack/stack.d.ts +2 -2
  286. package/dist/types/components/stack/v-stack.d.ts +2 -2
  287. package/dist/types/components/stack/z-stack.d.ts +2 -2
  288. package/dist/types/components/stat/stat.d.ts +2 -2
  289. package/dist/types/components/status/status.d.ts +2 -2
  290. package/dist/types/components/steps/steps.d.ts +2 -2
  291. package/dist/types/components/steps/steps.style.d.ts +1 -1
  292. package/dist/types/components/steps/use-steps.d.ts +10 -10
  293. package/dist/types/components/switch/switch.d.ts +2 -2
  294. package/dist/types/components/switch/use-switch.d.ts +8 -9
  295. package/dist/types/components/table/table.d.ts +3 -5
  296. package/dist/types/components/tabs/tabs.d.ts +2 -2
  297. package/dist/types/components/tabs/use-tabs.d.ts +16 -16
  298. package/dist/types/components/tag/tag.d.ts +2 -2
  299. package/dist/types/components/tag/tag.style.d.ts +1 -1
  300. package/dist/types/components/text/text.d.ts +2 -2
  301. package/dist/types/components/textarea/textarea.d.ts +2 -4
  302. package/dist/types/components/textarea/use-autosize.d.ts +2 -2
  303. package/dist/types/components/timeline/timeline.d.ts +5 -5
  304. package/dist/types/components/timeline/timeline.style.d.ts +2 -2
  305. package/dist/types/components/toggle/toggle-group.d.ts +1 -1
  306. package/dist/types/components/toggle/toggle.d.ts +5 -7
  307. package/dist/types/components/toggle/use-toggle-group.d.ts +3 -3
  308. package/dist/types/components/toggle/use-toggle.d.ts +2 -3
  309. package/dist/types/components/tooltip/tooltip.d.ts +2 -4
  310. package/dist/types/components/visually-hidden/visually-hidden.d.ts +2 -2
  311. package/dist/types/components/wrap/wrap.d.ts +2 -3
  312. package/dist/types/core/components/create-component.d.ts +9 -7
  313. package/dist/types/core/components/index.types.d.ts +1 -0
  314. package/dist/types/core/components/use-component-style.d.ts +3 -1
  315. package/dist/types/core/components/utils.d.ts +1 -0
  316. package/dist/types/core/constant.d.ts +1 -0
  317. package/dist/types/core/css/calc.d.ts +1 -0
  318. package/dist/types/core/css/config.d.ts +1 -0
  319. package/dist/types/core/css/css.d.ts +1 -0
  320. package/dist/types/core/css/index.types.d.ts +2 -1
  321. package/dist/types/core/css/styles.d.ts +220 -219
  322. package/dist/types/core/css/token.d.ts +1 -0
  323. package/dist/types/core/css/use-css.d.ts +1 -0
  324. package/dist/types/core/css/utils.d.ts +3 -1
  325. package/dist/types/core/generated-theme-tokens.types.d.ts +2 -1
  326. package/dist/types/core/index.d.ts +2 -0
  327. package/dist/types/core/system/breakpoint.d.ts +3 -3
  328. package/dist/types/core/system/color-mode-provider.d.ts +4 -4
  329. package/dist/types/core/system/config.d.ts +1 -0
  330. package/dist/types/core/system/factory.d.ts +1 -0
  331. package/dist/types/core/system/index.types.d.ts +7 -6
  332. package/dist/types/core/system/layer.d.ts +1 -1
  333. package/dist/types/core/system/storage-script.d.ts +5 -5
  334. package/dist/types/core/system/styled.d.ts +5 -4
  335. package/dist/types/core/system/system-provider.d.ts +2 -2
  336. package/dist/types/core/system/use-system-color-mode.d.ts +1 -1
  337. package/dist/types/core/system/var.d.ts +2 -0
  338. package/dist/types/hooks/use-async/index.d.ts +13 -13
  339. package/dist/types/hooks/use-async-callback/index.d.ts +0 -1
  340. package/dist/types/hooks/use-boolean/index.d.ts +1 -1
  341. package/dist/types/hooks/use-breakpoint/use-breakpoint-state.d.ts +2 -2
  342. package/dist/types/hooks/use-clickable/index.d.ts +4 -4
  343. package/dist/types/hooks/use-combobox/index.d.ts +1 -2
  344. package/dist/types/hooks/use-controllable-state/index.d.ts +2 -2
  345. package/dist/types/hooks/use-descendants/index.d.ts +2 -2
  346. package/dist/types/hooks/use-field-sizing/index.d.ts +2 -2
  347. package/dist/types/hooks/use-hover/index.d.ts +2 -2
  348. package/dist/types/hooks/use-local-storage/index.d.ts +1 -1
  349. package/dist/types/hooks/use-popper/index.d.ts +2 -2
  350. package/dist/types/hooks/use-resize-observer/index.d.ts +3 -3
  351. package/dist/types/index.d.ts +0 -98
  352. package/dist/types/providers/i18n-provider/i18n-provider.d.ts +4 -4
  353. package/dist/types/providers/ui-provider/ui-provider.d.ts +2 -3
  354. package/dist/types/utils/children.d.ts +2 -2
  355. package/dist/types/utils/context.d.ts +3 -3
  356. package/dist/types/utils/store.d.ts +2 -2
  357. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"use-checkbox.cjs","names":["useCheckboxGroupContext","useFieldProps","useControllableEventState","getRootProps: PropGetter<\"label\">","props","getInputProps: PropGetter<\"input\">","ariaDescribedby","visuallyHiddenAttributes","mergeRefs"],"sources":["../../../../src/components/checkbox/use-checkbox.ts"],"sourcesContent":["\"use client\"\n\nimport type { ChangeEvent, ChangeEventHandler, FocusEventHandler } from \"react\"\nimport type { HTMLProps, HTMLRefAttributes, PropGetter } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback, useId } from \"react\"\nimport { useControllableEventState } from \"../../hooks/use-controllable-state\"\nimport {\n ariaAttr,\n cx,\n dataAttr,\n handlerAll,\n isNumber,\n isUndefined,\n mergeRefs,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport { useFieldProps } from \"../field\"\nimport { useCheckboxGroupContext } from \"./use-checkbox-group\"\n\nexport interface UseCheckboxProps<Y extends string = string>\n extends\n Omit<HTMLProps<\"label\">, \"onBlur\" | \"onChange\" | \"onFocus\" | \"ref\">,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * id assigned to input.\n */\n id?: string\n /**\n * The name of the input field in a checkbox.\n */\n name?: string\n /**\n * If `true`, the checkbox will be checked.\n */\n checked?: boolean\n /**\n * If `true`, the checkbox will be initially checked.\n *\n * @default false\n */\n defaultChecked?: boolean\n /**\n * If `true`, the checkbox will be indeterminate.\n *\n * @default false\n */\n indeterminate?: boolean\n /**\n * The value of the checkbox.\n */\n value?: Y\n /**\n * The callback invoked when the checkbox is blurred.\n */\n onBlur?: FocusEventHandler<HTMLInputElement>\n /**\n * The callback invoked when the checked state changes.\n */\n onChange?: ChangeEventHandler<HTMLInputElement>\n /**\n * The callback invoked when the checkbox is focused.\n */\n onFocus?: FocusEventHandler<HTMLInputElement>\n}\n\nexport const useCheckbox = <Y extends string = string>({\n \"aria-describedby\": ariaDescribedbyProp,\n ...props\n}: UseCheckboxProps<Y> = {}) => {\n const group = useCheckboxGroupContext()\n const {\n max,\n value: groupValue,\n getInputProps: getGroupInputProps,\n getLabelProps,\n } = group ?? {}\n const uuid = useId()\n const {\n props: {\n id,\n ref,\n name,\n checked: checkedProp,\n defaultChecked = false,\n disabled,\n indeterminate = false,\n readOnly,\n required,\n value,\n onChange: onChangeProp,\n ...rest\n },\n ariaProps: { \"aria-describedby\": ariaDescribedby, ...ariaProps },\n dataProps,\n eventProps,\n } = useFieldProps({\n id: group ? uuid : undefined,\n ...props,\n notSupportReadOnly: true,\n })\n const resolvedAriaDescribedby = group ? ariaDescribedbyProp : ariaDescribedby\n const resolvedChecked =\n !isUndefined(groupValue) && !isUndefined(value)\n ? groupValue.includes(value)\n : checkedProp\n const [checked, setChecked] = useControllableEventState({\n defaultValue: defaultChecked,\n value: resolvedChecked,\n onChange: onChangeProp,\n })\n const trulyDisabled =\n !checked && isNumber(max) && group && group.value.length >= max\n const interactive = !(readOnly || trulyDisabled)\n\n const onChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n if (!interactive) return (ev.defaultPrevented = true)\n\n if (indeterminate) ev.target.checked = true\n\n setChecked(ev)\n },\n [interactive, indeterminate, setChecked],\n )\n\n const getRootProps: PropGetter<\"label\"> = useCallback(\n (props = {}) => {\n const sharedProps = {\n ...dataProps,\n \"data-checked\": dataAttr(checked),\n \"data-indeterminate\": dataAttr(indeterminate),\n ...rest,\n ...props,\n }\n\n return getLabelProps?.(sharedProps) ?? sharedProps\n },\n [dataProps, checked, indeterminate, rest, getLabelProps],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n ({ \"aria-describedby\": ariaDescribedby, ...props } = {}) => {\n const sharedProps = {\n ...dataProps,\n ...ariaProps,\n id,\n type: \"checkbox\",\n name,\n style: visuallyHiddenAttributes.style,\n \"aria-checked\": indeterminate ? (\"mixed\" as const) : checked,\n \"aria-describedby\": cx(resolvedAriaDescribedby, ariaDescribedby),\n \"aria-disabled\": ariaAttr(!interactive),\n \"data-checked\": dataAttr(checked),\n \"data-indeterminate\": dataAttr(indeterminate),\n checked,\n disabled,\n readOnly,\n required,\n value,\n ...props,\n ref: mergeRefs(props.ref, ref),\n onBlur: handlerAll(props.onBlur, eventProps.onBlur),\n onChange: handlerAll(props.onChange, onChange),\n onFocus: handlerAll(props.onFocus, eventProps.onFocus),\n }\n\n return getGroupInputProps?.(sharedProps) ?? sharedProps\n },\n [\n dataProps,\n ariaProps,\n id,\n name,\n indeterminate,\n checked,\n resolvedAriaDescribedby,\n interactive,\n disabled,\n readOnly,\n required,\n value,\n ref,\n eventProps,\n onChange,\n getGroupInputProps,\n ],\n )\n\n const getIndicatorProps: PropGetter = useCallback(\n (props = {}) => ({\n ...dataProps,\n \"aria-hidden\": \"true\",\n \"data-checked\": dataAttr(checked),\n \"data-indeterminate\": dataAttr(indeterminate),\n ...props,\n }),\n [dataProps, checked, indeterminate],\n )\n\n return {\n checked,\n indeterminate,\n getIndicatorProps,\n getInputProps,\n getRootProps,\n onChange,\n }\n}\n\nexport type UseCheckboxReturn = ReturnType<typeof useCheckbox>\n"],"mappings":";;;;;;;;;;;;;AAmEA,MAAa,eAA0C,EACrD,oBAAoB,qBACpB,GAAG,UACoB,EAAE,KAAK;CAC9B,MAAM,QAAQA,oDAAyB;CACvC,MAAM,EACJ,KACA,OAAO,YACP,eAAe,oBACf,kBACE,SAAS,EAAE;CACf,MAAM,yBAAc;CACpB,MAAM,EACJ,OAAO,EACL,IACA,KACA,MACA,SAAS,aACT,iBAAiB,OACjB,UACA,gBAAgB,OAChB,UACA,UACA,OACA,UAAU,cACV,GAAG,QAEL,WAAW,EAAE,oBAAoB,iBAAiB,GAAG,aACrD,WACA,eACEC,sCAAc;EAChB,IAAI,QAAQ,OAAO;EACnB,GAAG;EACH,oBAAoB;EACrB,CAAC;CACF,MAAM,0BAA0B,QAAQ,sBAAsB;CAK9D,MAAM,CAAC,SAAS,cAAcC,qEAA0B;EACtD,cAAc;EACd,OALA,oDAAa,WAAW,IAAI,oDAAa,MAAM,GAC3C,WAAW,SAAS,MAAM,GAC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Ac;GAC7C,GAAGA;GACJ,GACD;GAAC;GAAW;GAAS;GAAc,CACpC;EAMC;EACA;EACA;EACD"}
1
+ {"version":3,"file":"use-checkbox.cjs","names":["useCheckboxGroupContext","useFieldProps","useControllableEventState","getRootProps: PropGetter<\"label\">","props","getInputProps: PropGetter<\"input\">","ariaDescribedby","visuallyHiddenAttributes","mergeRefs"],"sources":["../../../../src/components/checkbox/use-checkbox.ts"],"sourcesContent":["\"use client\"\n\nimport type { ChangeEvent, ChangeEventHandler, FocusEventHandler } from \"react\"\nimport type { HTMLProps, HTMLRefAttributes, PropGetter } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback, useId } from \"react\"\nimport { useControllableEventState } from \"../../hooks/use-controllable-state\"\nimport {\n ariaAttr,\n cx,\n dataAttr,\n handlerAll,\n isNumber,\n isUndefined,\n mergeRefs,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport { useFieldProps } from \"../field\"\nimport { useCheckboxGroupContext } from \"./use-checkbox-group\"\n\nexport interface UseCheckboxProps<Y extends string = string>\n extends\n Omit<HTMLProps<\"label\">, \"onBlur\" | \"onChange\" | \"onFocus\" | \"ref\">,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * If `true`, the checkbox will be checked.\n */\n checked?: boolean\n /**\n * If `true`, the checkbox will be initially checked.\n *\n * @default false\n */\n defaultChecked?: boolean\n /**\n * id assigned to input.\n */\n id?: string\n /**\n * If `true`, the checkbox will be indeterminate.\n *\n * @default false\n */\n indeterminate?: boolean\n /**\n * The name of the input field in a checkbox.\n */\n name?: string\n /**\n * The value of the checkbox.\n */\n value?: Y\n /**\n * The callback invoked when the checkbox is blurred.\n */\n onBlur?: FocusEventHandler<HTMLInputElement>\n /**\n * The callback invoked when the checked state changes.\n */\n onChange?: ChangeEventHandler<HTMLInputElement>\n /**\n * The callback invoked when the checkbox is focused.\n */\n onFocus?: FocusEventHandler<HTMLInputElement>\n}\n\nexport const useCheckbox = <Y extends string = string>({\n \"aria-describedby\": ariaDescribedbyProp,\n ...props\n}: UseCheckboxProps<Y> = {}) => {\n const group = useCheckboxGroupContext()\n const {\n max,\n value: groupValue,\n getInputProps: getGroupInputProps,\n getLabelProps,\n } = group ?? {}\n const uuid = useId()\n const {\n props: {\n id,\n ref,\n name,\n checked: checkedProp,\n defaultChecked = false,\n disabled,\n indeterminate = false,\n readOnly,\n required,\n value,\n onChange: onChangeProp,\n ...rest\n },\n ariaProps: { \"aria-describedby\": ariaDescribedby, ...ariaProps },\n dataProps,\n eventProps,\n } = useFieldProps({\n id: group ? uuid : undefined,\n ...props,\n notSupportReadOnly: true,\n })\n const resolvedAriaDescribedby = group ? ariaDescribedbyProp : ariaDescribedby\n const resolvedChecked =\n !isUndefined(groupValue) && !isUndefined(value)\n ? groupValue.includes(value)\n : checkedProp\n const [checked, setChecked] = useControllableEventState({\n defaultValue: defaultChecked,\n value: resolvedChecked,\n onChange: onChangeProp,\n })\n const trulyDisabled =\n !checked && isNumber(max) && group && group.value.length >= max\n const interactive = !(readOnly || trulyDisabled)\n\n const onChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n if (!interactive) return (ev.defaultPrevented = true)\n\n if (indeterminate) ev.target.checked = true\n\n setChecked(ev)\n },\n [interactive, indeterminate, setChecked],\n )\n\n const getRootProps: PropGetter<\"label\"> = useCallback(\n (props = {}) => {\n const sharedProps = {\n ...dataProps,\n \"data-checked\": dataAttr(checked),\n \"data-indeterminate\": dataAttr(indeterminate),\n ...rest,\n ...props,\n }\n\n return getLabelProps?.(sharedProps) ?? sharedProps\n },\n [dataProps, checked, indeterminate, rest, getLabelProps],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n ({ \"aria-describedby\": ariaDescribedby, ...props } = {}) => {\n const sharedProps = {\n ...dataProps,\n ...ariaProps,\n id,\n type: \"checkbox\",\n name,\n style: visuallyHiddenAttributes.style,\n \"aria-checked\": indeterminate ? (\"mixed\" as const) : checked,\n \"aria-describedby\": cx(resolvedAriaDescribedby, ariaDescribedby),\n \"aria-disabled\": ariaAttr(!interactive),\n \"data-checked\": dataAttr(checked),\n \"data-indeterminate\": dataAttr(indeterminate),\n checked,\n disabled,\n readOnly,\n required,\n value,\n ...props,\n ref: mergeRefs(props.ref, ref),\n onBlur: handlerAll(props.onBlur, eventProps.onBlur),\n onChange: handlerAll(props.onChange, onChange),\n onFocus: handlerAll(props.onFocus, eventProps.onFocus),\n }\n\n return getGroupInputProps?.(sharedProps) ?? sharedProps\n },\n [\n dataProps,\n ariaProps,\n id,\n name,\n indeterminate,\n checked,\n resolvedAriaDescribedby,\n interactive,\n disabled,\n readOnly,\n required,\n value,\n ref,\n eventProps,\n onChange,\n getGroupInputProps,\n ],\n )\n\n const getIndicatorProps: PropGetter = useCallback(\n (props = {}) => ({\n ...dataProps,\n \"aria-hidden\": \"true\",\n \"data-checked\": dataAttr(checked),\n \"data-indeterminate\": dataAttr(indeterminate),\n ...props,\n }),\n [dataProps, checked, indeterminate],\n )\n\n return {\n checked,\n indeterminate,\n getIndicatorProps,\n getInputProps,\n getRootProps,\n onChange,\n }\n}\n\nexport type UseCheckboxReturn = ReturnType<typeof useCheckbox>\n"],"mappings":";;;;;;;;;;;;;AAmEA,MAAa,eAA0C,EACrD,oBAAoB,qBACpB,GAAG,UACoB,EAAE,KAAK;CAC9B,MAAM,QAAQA,oDAAyB;CACvC,MAAM,EACJ,KACA,OAAO,YACP,eAAe,oBACf,kBACE,SAAS,EAAE;CACf,MAAM,yBAAc;CACpB,MAAM,EACJ,OAAO,EACL,IACA,KACA,MACA,SAAS,aACT,iBAAiB,OACjB,UACA,gBAAgB,OAChB,UACA,UACA,OACA,UAAU,cACV,GAAG,QAEL,WAAW,EAAE,oBAAoB,iBAAiB,GAAG,aACrD,WACA,eACEC,sCAAc;EAChB,IAAI,QAAQ,OAAO;EACnB,GAAG;EACH,oBAAoB;EACrB,CAAC;CACF,MAAM,0BAA0B,QAAQ,sBAAsB;CAK9D,MAAM,CAAC,SAAS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EACL;EACA;EACA,2CAbC,UAAQ,EAAE,MAAM;GACf,GAAG;GACH,eAAe;GACf,gEAAyB,QAAQ;GACjC,sEAA+B,cAAc;GAC7C,GAAGA;GACJ,GACD;GAAC;GAAW;GAAS;GAAc,CACpC;EAMC;EACA;EACA;EACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-color-picker.cjs","names":["useI18n","useFieldProps","useCombobox","useControllableState","useEyeDropper","value","getRootProps: PropGetter","props","getFieldProps: PropGetter","mergeRefs","ref","getInputProps: PropGetter<\"input\">","getEyeDropperProps: PropGetter","runKeyAction"],"sources":["../../../../src/components/color-picker/use-color-picker.ts"],"sourcesContent":["\"use client\"\n\nimport type { ChangeEvent, FocusEvent, MouseEvent } from \"react\"\nimport type { HTMLRefAttributes, PropGetter } from \"../../core\"\nimport type { UseComboboxProps } from \"../../hooks/use-combobox\"\nimport type { ColorFormat } from \"../../utils\"\nimport type { UseColorSelectorProps } from \"../color-selector\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback, useEffect, useRef } from \"react\"\nimport { useCombobox } from \"../../hooks/use-combobox\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useEyeDropper } from \"../../hooks/use-eye-dropper\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n ariaAttr,\n calcFormat,\n contains,\n convertColor,\n cx,\n focusTransfer,\n handlerAll,\n mergeRefs,\n runIfFn,\n runKeyAction,\n} from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\nexport interface UseColorPickerProps\n extends\n Omit<\n UseComboboxProps,\n | \"closeOnSelect\"\n | \"initialFocusValue\"\n | \"onChange\"\n | \"ref\"\n | \"selectFocusRef\"\n | \"selectOnSpace\"\n >,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * The `id` attribute of the input element.\n */\n id?: string\n /**\n * The `name` attribute of the input element.\n */\n name?: string\n /**\n * If `true`, allows input.\n *\n * @default true\n */\n allowInput?: boolean\n /**\n * If `true`, the color picker will be closed when the input value changes.\n *\n * @default false\n */\n closeOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * The initial value of the color picker.\n */\n defaultValue?: string\n /**\n * The fallback value of the color picker.\n *\n * @default '#FFFFFF'\n */\n fallbackValue?: string\n /**\n * The format of the color picker.\n * Automatically determines the format of `value` or `defaultValue`.\n *\n * @default 'hex'\n */\n format?: ColorFormat\n /**\n * The function to format the input value.\n */\n formatInput?: (value: string) => string\n /**\n * If `true`, the color picker will be opened when the input value changes.\n *\n * @default true\n */\n openOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * If `true`, the color picker will be opened when the input is focused.\n *\n * @default false\n */\n openOnFocus?: boolean\n /**\n * The pattern used to check the input element.\n */\n pattern?: RegExp\n /**\n * The placeholder for color picker.\n */\n placeholder?: string\n /**\n * The value of the color picker.\n */\n value?: string\n /**\n * The callback invoked when the value changes.\n */\n onChange?: (value: string) => void\n /**\n * The callback invoked when input value state changes.\n */\n onInputChange?: (ev: ChangeEvent<HTMLInputElement>) => void\n}\n\nexport const useColorPicker = (props: UseColorPickerProps) => {\n const { t } = useI18n(\"colorPicker\")\n const {\n props: {\n id,\n ref,\n name,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledbyProp,\n allowInput = true,\n closeOnChange = false,\n defaultValue,\n disabled,\n fallbackValue = \"#FFFFFF\",\n format: formatProp,\n formatInput,\n openOnChange = true,\n openOnClick = true,\n openOnFocus = true,\n pattern,\n placeholder,\n readOnly,\n required,\n value: valueProp,\n onChange: onChangeProp,\n onInputChange: onInputChangeProp,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const {\n interactive,\n open,\n getContentProps: getComboboxContentProps,\n getTriggerProps,\n popoverProps,\n onClose,\n onOpen,\n } = useCombobox({\n disabled,\n openOnClick: false,\n openOnEnter: !allowInput,\n openOnSpace: !allowInput,\n placement: \"end-start\",\n readOnly,\n transferFocus: false,\n ...ariaProps,\n ...dataProps,\n ...eventProps,\n ...rest,\n })\n const format =\n formatProp ?? calcFormat(valueProp ?? defaultValue ?? fallbackValue)\n const alpha = format.endsWith(\"a\")\n const fieldRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const inputRef = useRef<HTMLInputElement>(null)\n const focusByClickRef = useRef<boolean>(false)\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const { supported: supportedEyeDropper, onOpen: onOpenEyeDropper } =\n useEyeDropper()\n\n const onClick = useCallback(() => {\n if (!interactive) return\n\n focusByClickRef.current = true\n\n if (allowInput) inputRef.current?.focus()\n\n if (openOnClick) onOpen()\n }, [allowInput, interactive, onOpen, openOnClick])\n\n const onMouseDown = useCallback(\n (ev: MouseEvent<HTMLDivElement | HTMLInputElement>) => {\n if (!openOnFocus) return\n\n ev.preventDefault()\n ev.stopPropagation()\n },\n [openOnFocus],\n )\n\n const onFieldFocus = useCallback(() => {\n if (allowInput) return\n\n if (openOnFocus) onOpen()\n\n focusByClickRef.current = false\n }, [allowInput, onOpen, openOnFocus])\n\n const onInputFocus = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n ev.preventDefault()\n ev.stopPropagation()\n\n if (openOnFocus && !focusByClickRef.current) onOpen()\n\n focusByClickRef.current = false\n },\n [onOpen, openOnFocus],\n )\n\n const onBlur = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n if (\n contains(fieldRef.current, ev.relatedTarget) ||\n contains(contentRef.current, ev.relatedTarget)\n ) {\n ev.preventDefault()\n } else {\n setValue((prev) => {\n if (!prev) return prev\n\n let value = convertColor(prev)(format)\n\n if (!value) return prev\n\n if (formatInput) value = formatInput(value)\n\n if (pattern) value = value.replace(pattern, \"\")\n\n return value\n })\n }\n },\n [format, formatInput, pattern, setValue],\n )\n\n const onInputChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n if (!allowInput) return\n\n onInputChangeProp?.(ev)\n\n if (runIfFn(closeOnChange, ev)) {\n onClose()\n } else if (runIfFn(openOnChange, ev)) {\n onOpen()\n }\n\n let inputValue = ev.target.value\n\n if (formatInput) inputValue = formatInput(inputValue)\n\n if (pattern) inputValue = inputValue.replace(pattern, \"\")\n\n setValue(inputValue)\n },\n [\n allowInput,\n closeOnChange,\n formatInput,\n onClose,\n onInputChangeProp,\n onOpen,\n openOnChange,\n pattern,\n setValue,\n ],\n )\n\n const onEyeDropperClick = useCallback(async () => {\n if (!interactive) return\n\n const result = await onOpenEyeDropper()\n\n if (result?.sRGBHex) setValue(result.sRGBHex)\n }, [interactive, onOpenEyeDropper, setValue])\n\n useEffect(() => {\n if (!open) return\n\n return focusTransfer(\n contentRef.current,\n allowInput ? inputRef.current : fieldRef.current,\n )\n }, [allowInput, open])\n\n const getRootProps: PropGetter = useCallback(\n (props) => ({\n ...dataProps,\n ...props,\n }),\n [dataProps],\n )\n\n const getFieldProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getTriggerProps({\n ref: mergeRefs(ref, fieldRef),\n \"aria-haspopup\": \"dialog\",\n tabIndex: !allowInput ? 0 : -1,\n ...props,\n onClick: handlerAll(props.onClick, onClick),\n onFocus: handlerAll(props.onFocus, onFieldFocus),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }),\n\n [allowInput, getTriggerProps, onClick, onFieldFocus, onMouseDown],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n ({ \"aria-labelledby\": ariaLabelledby, ...props } = {}) => ({\n id,\n ref: mergeRefs(props.ref, ref, inputRef),\n name,\n style: {\n ...(!allowInput ? { pointerEvents: \"none\" } : {}),\n ...props.style,\n },\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": cx(ariaLabelledby, ariaLabelledbyProp),\n autoComplete: \"off\",\n disabled,\n placeholder,\n readOnly,\n required,\n tabIndex: allowInput ? 0 : -1,\n value,\n ...dataProps,\n ...props,\n onBlur: handlerAll(props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onInputChange),\n onFocus: handlerAll(props.onFocus, onInputFocus),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }),\n [\n allowInput,\n ariaLabel,\n ariaLabelledbyProp,\n dataProps,\n disabled,\n id,\n name,\n onBlur,\n onInputChange,\n onInputFocus,\n onMouseDown,\n placeholder,\n readOnly,\n ref,\n required,\n value,\n ],\n )\n\n const getEyeDropperProps: PropGetter = useCallback(\n (props = {}) => ({\n ...dataProps,\n \"aria-disabled\": ariaAttr(!interactive),\n \"aria-label\": t(\"Pick a color\"),\n hidden: !supportedEyeDropper,\n role: \"button\",\n tabIndex: interactive ? 0 : -1,\n ...props,\n onClick: handlerAll(props.onClick, onEyeDropperClick),\n onKeyDown: handlerAll(props.onKeyDown, (ev) =>\n runKeyAction(ev, {\n Enter: onEyeDropperClick,\n Space: onEyeDropperClick,\n }),\n ),\n }),\n [dataProps, interactive, onEyeDropperClick, supportedEyeDropper, t],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getComboboxContentProps({\n ref: mergeRefs(ref, contentRef),\n role: \"dialog\",\n ...props,\n }),\n [getComboboxContentProps],\n )\n\n const getSelectorProps: PropGetter<UseColorSelectorProps> = useCallback(\n (props = {}) => ({\n disabled,\n fallbackValue,\n format,\n readOnly,\n value,\n ...props,\n onChange: handlerAll(props.onChange, setValue),\n }),\n [disabled, fallbackValue, format, readOnly, value, setValue],\n )\n\n return {\n alpha,\n format,\n interactive,\n open,\n setValue,\n value,\n getContentProps,\n getEyeDropperProps,\n getFieldProps,\n getInputProps,\n getRootProps,\n getSelectorProps,\n popoverProps,\n onClose,\n onOpen,\n }\n}\n\nexport type UseColorPickerReturn = ReturnType<typeof useColorPicker>\n"],"mappings":";;;;;;;;;;;;;;;;AAmHA,MAAa,kBAAkB,UAA+B;CAC5D,MAAM,EAAE,MAAMA,8BAAQ,cAAc;CACpC,MAAM,EACJ,OAAO,EACL,IACA,KACA,MACA,cAAc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7BC,EAAE,YAAK,GAAGN,YAAU,EAAE,KACrB,wBAAwB;GACtB,KAAKE,sBAAUC,OAAK,WAAW;GAC/B,MAAM;GACN,GAAGH;GACJ,CAAC,EACJ,CAAC,wBAAwB,CAC1B;EAuBC;EACA;EACA;EACA;EACA,0CAxBC,UAAQ,EAAE,MAAM;GACf;GACA;GACA;GACA;GACA;GACA,GAAGA;GACH,4DAAqBA,QAAM,UAAU,SAAS;GAC/C,GACD;GAAC;GAAU;GAAe;GAAQ;GAAU;GAAO;GAAS,CAC7D;EAeC;EACA;EACA;EACD"}
1
+ {"version":3,"file":"use-color-picker.cjs","names":["useI18n","useFieldProps","useCombobox","useControllableState","useEyeDropper","value","getRootProps: PropGetter","props","getFieldProps: PropGetter","mergeRefs","ref","getInputProps: PropGetter<\"input\">","getEyeDropperProps: PropGetter","runKeyAction"],"sources":["../../../../src/components/color-picker/use-color-picker.ts"],"sourcesContent":["\"use client\"\n\nimport type { ChangeEvent, FocusEvent, MouseEvent } from \"react\"\nimport type { HTMLRefAttributes, PropGetter } from \"../../core\"\nimport type { UseComboboxProps } from \"../../hooks/use-combobox\"\nimport type { ColorFormat } from \"../../utils\"\nimport type { UseColorSelectorProps } from \"../color-selector\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback, useEffect, useRef } from \"react\"\nimport { useCombobox } from \"../../hooks/use-combobox\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useEyeDropper } from \"../../hooks/use-eye-dropper\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n ariaAttr,\n calcFormat,\n contains,\n convertColor,\n cx,\n focusTransfer,\n handlerAll,\n mergeRefs,\n runIfFn,\n runKeyAction,\n} from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\nexport interface UseColorPickerProps\n extends\n Omit<\n UseComboboxProps,\n | \"closeOnSelect\"\n | \"initialFocusValue\"\n | \"onChange\"\n | \"ref\"\n | \"selectFocusRef\"\n | \"selectOnSpace\"\n >,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * If `true`, allows input.\n *\n * @default true\n */\n allowInput?: boolean\n /**\n * If `true`, the color picker will be closed when the input value changes.\n *\n * @default false\n */\n closeOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * The initial value of the color picker.\n */\n defaultValue?: string\n /**\n * The fallback value of the color picker.\n *\n * @default '#FFFFFF'\n */\n fallbackValue?: string\n /**\n * The format of the color picker.\n * Automatically determines the format of `value` or `defaultValue`.\n *\n * @default 'hex'\n */\n format?: ColorFormat\n /**\n * The `id` attribute of the input element.\n */\n id?: string\n /**\n * The `name` attribute of the input element.\n */\n name?: string\n /**\n * If `true`, the color picker will be opened when the input value changes.\n *\n * @default true\n */\n openOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * If `true`, the color picker will be opened when the input is focused.\n *\n * @default false\n */\n openOnFocus?: boolean\n /**\n * The pattern used to check the input element.\n */\n pattern?: RegExp\n /**\n * The placeholder for color picker.\n */\n placeholder?: string\n /**\n * The value of the color picker.\n */\n value?: string\n /**\n * The function to format the input value.\n */\n formatInput?: (value: string) => string\n /**\n * The callback invoked when the value changes.\n */\n onChange?: (value: string) => void\n /**\n * The callback invoked when input value state changes.\n */\n onInputChange?: (ev: ChangeEvent<HTMLInputElement>) => void\n}\n\nexport const useColorPicker = (props: UseColorPickerProps) => {\n const { t } = useI18n(\"colorPicker\")\n const {\n props: {\n id,\n ref,\n name,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledbyProp,\n allowInput = true,\n closeOnChange = false,\n defaultValue,\n disabled,\n fallbackValue = \"#FFFFFF\",\n format: formatProp,\n formatInput,\n openOnChange = true,\n openOnClick = true,\n openOnFocus = true,\n pattern,\n placeholder,\n readOnly,\n required,\n value: valueProp,\n onChange: onChangeProp,\n onInputChange: onInputChangeProp,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const {\n interactive,\n open,\n getContentProps: getComboboxContentProps,\n getTriggerProps,\n popoverProps,\n onClose,\n onOpen,\n } = useCombobox({\n disabled,\n openOnClick: false,\n openOnEnter: !allowInput,\n openOnSpace: !allowInput,\n placement: \"end-start\",\n readOnly,\n transferFocus: false,\n ...ariaProps,\n ...dataProps,\n ...eventProps,\n ...rest,\n })\n const format =\n formatProp ?? calcFormat(valueProp ?? defaultValue ?? fallbackValue)\n const alpha = format.endsWith(\"a\")\n const fieldRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const inputRef = useRef<HTMLInputElement>(null)\n const focusByClickRef = useRef<boolean>(false)\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const { supported: supportedEyeDropper, onOpen: onOpenEyeDropper } =\n useEyeDropper()\n\n const onClick = useCallback(() => {\n if (!interactive) return\n\n focusByClickRef.current = true\n\n if (allowInput) inputRef.current?.focus()\n\n if (openOnClick) onOpen()\n }, [allowInput, interactive, onOpen, openOnClick])\n\n const onMouseDown = useCallback(\n (ev: MouseEvent<HTMLDivElement | HTMLInputElement>) => {\n if (!openOnFocus) return\n\n ev.preventDefault()\n ev.stopPropagation()\n },\n [openOnFocus],\n )\n\n const onFieldFocus = useCallback(() => {\n if (allowInput) return\n\n if (openOnFocus) onOpen()\n\n focusByClickRef.current = false\n }, [allowInput, onOpen, openOnFocus])\n\n const onInputFocus = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n ev.preventDefault()\n ev.stopPropagation()\n\n if (openOnFocus && !focusByClickRef.current) onOpen()\n\n focusByClickRef.current = false\n },\n [onOpen, openOnFocus],\n )\n\n const onBlur = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n if (\n contains(fieldRef.current, ev.relatedTarget) ||\n contains(contentRef.current, ev.relatedTarget)\n ) {\n ev.preventDefault()\n } else {\n setValue((prev) => {\n if (!prev) return prev\n\n let value = convertColor(prev)(format)\n\n if (!value) return prev\n\n if (formatInput) value = formatInput(value)\n\n if (pattern) value = value.replace(pattern, \"\")\n\n return value\n })\n }\n },\n [format, formatInput, pattern, setValue],\n )\n\n const onInputChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n if (!allowInput) return\n\n onInputChangeProp?.(ev)\n\n if (runIfFn(closeOnChange, ev)) {\n onClose()\n } else if (runIfFn(openOnChange, ev)) {\n onOpen()\n }\n\n let inputValue = ev.target.value\n\n if (formatInput) inputValue = formatInput(inputValue)\n\n if (pattern) inputValue = inputValue.replace(pattern, \"\")\n\n setValue(inputValue)\n },\n [\n allowInput,\n closeOnChange,\n formatInput,\n onClose,\n onInputChangeProp,\n onOpen,\n openOnChange,\n pattern,\n setValue,\n ],\n )\n\n const onEyeDropperClick = useCallback(async () => {\n if (!interactive) return\n\n const result = await onOpenEyeDropper()\n\n if (result?.sRGBHex) setValue(result.sRGBHex)\n }, [interactive, onOpenEyeDropper, setValue])\n\n useEffect(() => {\n if (!open) return\n\n return focusTransfer(\n contentRef.current,\n allowInput ? inputRef.current : fieldRef.current,\n )\n }, [allowInput, open])\n\n const getRootProps: PropGetter = useCallback(\n (props) => ({\n ...dataProps,\n ...props,\n }),\n [dataProps],\n )\n\n const getFieldProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getTriggerProps({\n ref: mergeRefs(ref, fieldRef),\n \"aria-haspopup\": \"dialog\",\n tabIndex: !allowInput ? 0 : -1,\n ...props,\n onClick: handlerAll(props.onClick, onClick),\n onFocus: handlerAll(props.onFocus, onFieldFocus),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }),\n\n [allowInput, getTriggerProps, onClick, onFieldFocus, onMouseDown],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n ({ \"aria-labelledby\": ariaLabelledby, ...props } = {}) => ({\n id,\n ref: mergeRefs(props.ref, ref, inputRef),\n name,\n style: {\n ...(!allowInput ? { pointerEvents: \"none\" } : {}),\n ...props.style,\n },\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": cx(ariaLabelledby, ariaLabelledbyProp),\n autoComplete: \"off\",\n disabled,\n placeholder,\n readOnly,\n required,\n tabIndex: allowInput ? 0 : -1,\n value,\n ...dataProps,\n ...props,\n onBlur: handlerAll(props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onInputChange),\n onFocus: handlerAll(props.onFocus, onInputFocus),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }),\n [\n allowInput,\n ariaLabel,\n ariaLabelledbyProp,\n dataProps,\n disabled,\n id,\n name,\n onBlur,\n onInputChange,\n onInputFocus,\n onMouseDown,\n placeholder,\n readOnly,\n ref,\n required,\n value,\n ],\n )\n\n const getEyeDropperProps: PropGetter = useCallback(\n (props = {}) => ({\n ...dataProps,\n \"aria-disabled\": ariaAttr(!interactive),\n \"aria-label\": t(\"Pick a color\"),\n hidden: !supportedEyeDropper,\n role: \"button\",\n tabIndex: interactive ? 0 : -1,\n ...props,\n onClick: handlerAll(props.onClick, onEyeDropperClick),\n onKeyDown: handlerAll(props.onKeyDown, (ev) =>\n runKeyAction(ev, {\n Enter: onEyeDropperClick,\n Space: onEyeDropperClick,\n }),\n ),\n }),\n [dataProps, interactive, onEyeDropperClick, supportedEyeDropper, t],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getComboboxContentProps({\n ref: mergeRefs(ref, contentRef),\n role: \"dialog\",\n ...props,\n }),\n [getComboboxContentProps],\n )\n\n const getSelectorProps: PropGetter<UseColorSelectorProps> = useCallback(\n (props = {}) => ({\n disabled,\n fallbackValue,\n format,\n readOnly,\n value,\n ...props,\n onChange: handlerAll(props.onChange, setValue),\n }),\n [disabled, fallbackValue, format, readOnly, value, setValue],\n )\n\n return {\n alpha,\n format,\n interactive,\n open,\n setValue,\n value,\n getContentProps,\n getEyeDropperProps,\n getFieldProps,\n getInputProps,\n getRootProps,\n getSelectorProps,\n popoverProps,\n onClose,\n onOpen,\n }\n}\n\nexport type UseColorPickerReturn = Return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OACtCM,yBAAa,IAAI;GACf,OAAO;GACP,OAAO;GACR,CAAC,CACH;EACF,GACD;EAAC;EAAW;EAAa;EAAmB;EAAqB;EAAE,CACpE;AAyBD,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA,yCA7BC,EAAE,YAAK,GAAGN,YAAU,EAAE,KACrB,wBAAwB;GACtB,KAAKE,sBAAUC,OAAK,WAAW;GAC/B,MAAM;GACN,GAAGH;GACJ,CAAC,EACJ,CAAC,wBAAwB,CAC1B;EAuBC;EACA;EACA;EACA;EACA,0CAxBC,UAAQ,EAAE,MAAM;GACf;GACA;GACA;GACA;GACA;GACA,GAAGA;GACH,4DAAqBA,QAAM,UAAU,SAAS;GAC/C,GACD;GAAC;GAAU;GAAe;GAAQ;GAAU;GAAO;GAAS,CAC7D;EAeC;EACA;EACA;EACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-date-picker.cjs","names":["defaultRender: DatePickerRender","DEFAULT_MAX_DATE","DEFAULT_MIN_DATE","useI18n","useFieldProps","useDateTimeFormat","inputFormat","calendarFormat","useCalendarProps","useControllableState","value","getAdjustedMonth","isBeforeDate","isAfterDate","useCombobox","onClear","updateMaybeDateValue","startPlaceholder","inputValue","minDate","maxDate","isComposing","ev","getRootProps: PropGetter","props","getFieldProps: PropGetter","mergeRefs","ref","getInputProps: PropGetter<\"input\", { align?: InputAlign }>","inputProps: HTMLProps<\"input\">","visuallyHiddenAttributes","getContentProps: PropGetter","getCalendarProps: PropGetter<UseCalendarProps<Multiple, Range>>","getIconProps: PropGetter","runKeyAction"],"sources":["../../../../src/components/date-picker/use-date-picker.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n ChangeEvent,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n} from \"react\"\nimport type { HTMLProps, HTMLRefAttributes, PropGetter } from \"../../core\"\nimport type { UseComboboxProps } from \"../../hooks/use-combobox\"\nimport type { Dict } from \"../../utils\"\nimport type {\n CalendarFormat,\n MaybeDateValue,\n UseCalendarProps,\n} from \"../calendar\"\nimport type { FieldProps } from \"../field\"\nimport dayjs from \"dayjs\"\nimport {\n cloneElement,\n isValidElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { useCombobox } from \"../../hooks/use-combobox\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n ariaAttr,\n cast,\n contains,\n dataAttr,\n focusTransfer,\n handlerAll,\n isArray,\n isComposing,\n isDate,\n isNumber,\n isObject,\n mergeRefs,\n runIfFn,\n runKeyAction,\n useUpdateEffect,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport {\n DEFAULT_MAX_DATE,\n DEFAULT_MIN_DATE,\n getAdjustedMonth,\n isAfterDate,\n isBeforeDate,\n updateMaybeDateValue,\n useCalendarProps,\n} from \"../calendar\"\nimport { useFieldProps } from \"../field\"\nimport { useDateTimeFormat } from \"../format\"\n\nexport interface DatePickerFormat extends CalendarFormat {\n input?: Intl.DateTimeFormatOptions | null\n}\n\ntype InputAlign = \"end\" | \"start\"\ntype MaybeInputValue<Range extends boolean = false> = Range extends true\n ? { end?: string; start?: string }\n : string | undefined\n\ninterface DatePickerRenderProps {\n count: number\n date: Date\n focused: boolean\n index: number\n max?: number\n separator: string\n value: string\n onClear: () => void\n}\n\nexport interface DatePickerRender {\n (props: DatePickerRenderProps): ReactNode\n}\n\nconst defaultRender: DatePickerRender = ({\n count,\n focused,\n index,\n max,\n separator,\n value,\n}) => {\n const last = count - 1 === index\n\n return (\n <span style={{ marginInlineEnd: \"var(--gap)\" }}>\n {value}\n {((!isNumber(max) || count < max) && focused) || !last ? separator : null}\n </span>\n )\n}\n\nexport interface UseDatePickerProps<\n Multiple extends boolean = false,\n Range extends boolean = false,\n>\n extends\n Omit<UseCalendarProps<Multiple, Range>, \"format\" | \"ref\">,\n Omit<\n UseComboboxProps,\n \"defaultValue\" | \"initialFocusValue\" | \"onChange\" | \"ref\" | \"value\"\n >,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * The `id` attribute of the input element.\n */\n id?: string\n /**\n * The `name` attribute of the input element.\n */\n name?: string\n /**\n * If `true`, allows input.\n *\n * @default true\n */\n allowInput?: boolean\n /**\n * If `true`, allows input of dates beyond the `minDate` and `maxDate` restrictions.\n *\n * @default true\n */\n allowInputBeyond?: boolean\n /**\n * If `true`, the date picker will be closed when the input value changes.\n *\n * @default false\n */\n closeOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * The initial value of the input.\n */\n defaultInputValue?: MaybeInputValue<Range>\n /**\n * If `true`, the input will be focused when the clear icon is clicked.\n *\n * @default true\n */\n focusOnClear?: boolean\n /**\n * The format used for conversion.\n * Check the docs to see the format of possible modifiers you can pass.\n *\n * @see https://day.js.org/docs/en/display/format#list-of-localized-formats\n */\n format?: DatePickerFormat\n /**\n * The value of the input.\n */\n inputValue?: MaybeInputValue<Range>\n /**\n * If `true`, the date picker will be opened when the input value changes.\n *\n * @default true\n */\n openOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * If `true`, the date picker will be opened when the input is focused.\n *\n * @default true\n */\n openOnFocus?: boolean\n /**\n * Function that converts the input value to Date type.\n */\n parseDate?: (value: string) => Date | undefined\n /**\n * The pattern used to check the input element.\n */\n pattern?: RegExp\n /**\n * The placeholder for date picker.\n */\n placeholder?: string\n /**\n * The function to render the selected date.\n */\n render?: (props: DatePickerRenderProps) => ReactNode\n /**\n * The visual separator between each value.\n *\n * @default ','\n */\n separator?: string\n /**\n * The callback invoked when input value state changes.\n */\n onInputChange?: (value: MaybeInputValue<Range>) => void\n}\n\nexport const useDatePicker = <\n Multiple extends boolean = false,\n Range extends boolean = false,\n>({\n maxDate = DEFAULT_MAX_DATE,\n minDate = DEFAULT_MIN_DATE,\n ...props\n}: UseDatePickerProps<Multiple, Range> = {}) => {\n if (dayjs(minDate).isAfter(dayjs(maxDate))) maxDate = minDate\n\n const { locale: defaultLocale, t } = useI18n(\"datePicker\")\n const {\n props: {\n id,\n ref,\n name,\n allowInput = true,\n allowInputBeyond = false,\n closeOnChange = false,\n multiple = false,\n closeOnSelect = !multiple,\n defaultInputValue,\n defaultMonth = new Date(),\n range = false,\n defaultValue = (range\n ? { end: undefined, start: undefined }\n : multiple\n ? []\n : undefined) as MaybeDateValue<Multiple, Range>,\n disabled,\n focusOnClear = true,\n format,\n inputValue: inputValueProp,\n locale = defaultLocale,\n max,\n month: monthProp,\n openOnChange = true,\n openOnClick = true,\n openOnFocus = true,\n parseDate,\n pattern,\n placeholder: placeholderProp,\n readOnly,\n render = defaultRender,\n required,\n separator = range ? \"-\" : \",\",\n value: valueProp,\n onChange: onChangeProp,\n onChangeMonth: onChangeMonthProp,\n onInputChange: onInputChangeProp,\n ...computedProps\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const dateTimeFormat = useDateTimeFormat({ locale })\n const { calendarFormat, inputFormat } = useMemo(() => {\n const { input: inputFormat, ...calendarFormat } = format ?? {}\n const defaultInputFormat: Intl.DateTimeFormatOptions = {\n day: \"numeric\",\n month: \"long\",\n year: \"numeric\",\n }\n\n return {\n calendarFormat,\n inputFormat:\n inputFormat !== null ? (inputFormat ?? defaultInputFormat) : undefined,\n }\n }, [format])\n const [calendarProps, rest] = useCalendarProps<Multiple, Range>(computedProps)\n const { excludeDate } = calendarProps\n const fieldRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const startInputRef = useRef<HTMLInputElement>(null)\n const endInputRef = useRef<HTMLInputElement>(null)\n const focusByClickRef = useRef<boolean>(false)\n const [focused, setFocused] = useState(false)\n const [value, setValue] = useControllableState({\n defaultValue: defaultValue as MaybeDateValue<Multiple, Range>,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [month, setMonth] = useControllableState({\n defaultValue: () => {\n let value = defaultMonth\n\n if (dayjs(minDate).isAfter(dayjs(defaultMonth)))\n value = dayjs(minDate).set(\"date\", 1).toDate()\n\n if (valueProp) {\n value = getAdjustedMonth(valueProp, value)\n } else if (defaultValue) {\n value = getAdjustedMonth(defaultValue, value)\n }\n\n return value\n },\n value: monthProp,\n onChange: onChangeMonthProp,\n })\n const stringToDate = useCallback(\n (value: string, start: Date = minDate, end: Date = maxDate) => {\n let date = parseDate?.(value)\n\n if (!date && dayjs(value).isValid()) date = dayjs(value, locale).toDate()\n\n if (date == null) return undefined\n if (excludeDate?.(date)) return undefined\n\n if (!allowInputBeyond) {\n if (isBeforeDate(date, start)) date = start\n if (isAfterDate(date, end)) date = end\n }\n\n return date\n },\n [allowInputBeyond, excludeDate, locale, maxDate, minDate, parseDate],\n )\n const dateToString = useCallback(\n (date?: Date) => {\n if (date == null) return \"\"\n\n return dateTimeFormat(date, inputFormat)\n },\n [dateTimeFormat, inputFormat],\n )\n const [inputValue, setInputValue] = useControllableState({\n defaultValue: () => {\n if (defaultInputValue) {\n if (isObject(defaultInputValue)) {\n if (dayjs(defaultInputValue.start).isValid())\n defaultInputValue.start = dateTimeFormat(\n dayjs(defaultInputValue.start).toDate(),\n inputFormat,\n )\n\n if (dayjs(defaultInputValue.end).isValid())\n defaultInputValue.end = dateTimeFormat(\n dayjs(defaultInputValue.end).toDate(),\n inputFormat,\n )\n\n return defaultInputValue\n } else {\n if (dayjs(defaultInputValue).isValid()) {\n return dateTimeFormat(\n dayjs(defaultInputValue).toDate(),\n inputFormat,\n ) as MaybeInputValue<Range>\n } else {\n return defaultInputValue as MaybeInputValue<Range>\n }\n }\n } else if (isDate(value)) {\n return dateToString(value) as MaybeInputValue<Range>\n } else if (isObject(value) && !isArray(value)) {\n return {\n end: dateToString(value.end),\n start: dateToString(value.start),\n } as MaybeInputValue<Range>\n } else {\n return \"\" as MaybeInputValue<Range>\n }\n },\n value: inputValueProp,\n onChange: onInputChangeProp,\n })\n const {\n interactive,\n open,\n getContentProps: getComboboxContentProps,\n getTriggerProps,\n popoverProps,\n onClose,\n onOpen,\n } = useCombobox({\n disabled,\n matchWidth: false,\n openOnClick: false,\n openOnEnter: !allowInput,\n openOnSpace: !allowInput,\n placement: \"end-start\",\n readOnly,\n transferFocus: false,\n ...ariaProps,\n ...dataProps,\n ...eventProps,\n ...rest,\n })\n const children = useMemo<ReactNode>(() => {\n if (!isArray(value)) return null\n\n const count = value.length\n\n return value.map((date, index) => {\n const value = dateToString(date)\n\n const onClear = (ev?: MouseEvent<HTMLElement>) => {\n ev?.preventDefault()\n ev?.stopPropagation()\n\n setValue(\n (prev) =>\n updateMaybeDateValue(date, max)(prev) as MaybeDateValue<\n Multiple,\n Range\n >,\n )\n }\n\n const component = render({\n count,\n date,\n focused,\n index,\n max,\n separator,\n value,\n onClear,\n })\n\n if (isValidElement<Dict>(component)) {\n return cloneElement(component, { ...component.props, key: index })\n } else {\n return component\n }\n })\n }, [dateToString, focused, max, render, separator, setValue, value])\n const { endPlaceholder, startPlaceholder } = useMemo(() => {\n if (range) {\n const startPlaceholder =\n placeholderProp ?? dateTimeFormat(new Date(), inputFormat)\n const endPlaceholder =\n placeholderProp ??\n dateTimeFormat(dayjs().add(1, \"day\").toDate(), inputFormat)\n\n return { endPlaceholder, startPlaceholder }\n } else {\n const placeholder =\n placeholderProp ?? dateTimeFormat(new Date(), inputFormat)\n\n return { endPlaceholder: placeholder, startPlaceholder: placeholder }\n }\n }, [dateTimeFormat, inputFormat, placeholderProp, range])\n\n const onChange = useCallback(\n (value: MaybeDateValue<Multiple, Range>) => {\n setValue(value)\n\n if (isArray(value)) {\n setInputValue(\"\" as MaybeInputValue<Range>)\n } else if (isObject(value) && !isDate(value)) {\n setInputValue({\n end: dateToString(value.end),\n start: dateToString(value.start),\n } as MaybeInputValue<Range>)\n } else {\n setInputValue(dateToString(value) as MaybeInputValue<Range>)\n }\n\n if (!closeOnSelect) return\n\n if (isObject(value) && !isArray(value) && !isDate(value)) {\n if (value.end && value.start) onClose()\n } else {\n onClose()\n }\n },\n [setValue, closeOnSelect, setInputValue, dateToString, onClose],\n )\n\n const onInputChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n if (!allowInput) return\n if (isArray(value) && value.length === max) return\n\n if (runIfFn(closeOnChange, ev)) {\n onClose()\n } else if (runIfFn(openOnChange, ev)) {\n onOpen()\n }\n\n let inputValue = ev.target.value\n\n if (pattern) inputValue = inputValue.replace(pattern, \"\")\n\n if (isArray(value)) {\n const date = stringToDate(inputValue)\n\n setInputValue(inputValue as MaybeInputValue<Range>)\n\n if (date) setMonth(dayjs(date).set(\"date\", 1).toDate())\n } else if (isObject(value) && !isDate(value)) {\n const align = contains(endInputRef.current, ev.target) ? \"end\" : \"start\"\n const minDate =\n value.start && align === \"end\"\n ? dayjs(value.start).add(1, \"day\").toDate()\n : undefined\n const maxDate =\n value.end && align === \"start\"\n ? dayjs(value.end).subtract(1, \"day\").toDate()\n : undefined\n const date = stringToDate(inputValue, minDate, maxDate)\n\n setInputValue((prev) =>\n isObject(prev)\n ? ({\n ...(prev as MaybeInputValue<true>),\n [align]: inputValue,\n } as MaybeInputValue<Range>)\n : prev,\n )\n setValue((prev) =>\n isObject(prev) && !isDate(prev)\n ? ({ ...prev, [align]: date } as MaybeDateValue<Multiple, Range>)\n : prev,\n )\n } else {\n const date = stringToDate(inputValue)\n\n setInputValue(inputValue as MaybeInputValue<Range>)\n setValue(date as MaybeDateValue<Multiple, Range>)\n }\n },\n [\n allowInput,\n closeOnChange,\n max,\n onClose,\n onOpen,\n openOnChange,\n pattern,\n setInputValue,\n setMonth,\n setValue,\n stringToDate,\n value,\n ],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLInputElement>) => {\n if (disabled || isComposing(ev)) return\n\n const inputValue = cast<HTMLInputElement>(ev.target).value\n\n runKeyAction(\n ev,\n {\n Backspace: (ev) => {\n if (!value || isDate(value)) return\n if (!!inputValue.length) return\n\n if (isArray(value)) {\n ev.preventDefault()\n\n setValue((prev) =>\n isArray(prev)\n ? (prev.slice(0, -1) as MaybeDateValue<Multiple, Range>)\n : prev,\n )\n } else if (contains(endInputRef.current, ev.target)) {\n ev.preventDefault()\n\n setInputValue({ end: \"\", start: \"\" } as MaybeInputValue<Range>)\n setValue({ end: undefined, start: undefined } as MaybeDateValue<\n Multiple,\n Range\n >)\n\n startInputRef.current?.focus()\n }\n },\n Enter: (ev) => {\n if (!open || !inputValue.length) return\n\n if (isDate(value) || isArray(value)) {\n const date = stringToDate(inputValue)\n\n if (!date) return\n\n ev.preventDefault()\n\n if (isArray(value)) {\n setInputValue(\"\" as MaybeInputValue<Range>)\n } else {\n setInputValue(dateToString(date) as MaybeInputValue<Range>)\n }\n\n setValue(\n (prev) =>\n updateMaybeDateValue(date, max)(prev) as MaybeDateValue<\n Multiple,\n Range\n >,\n )\n } else if (isObject(value)) {\n const align = contains(endInputRef.current, ev.target)\n ? \"end\"\n : \"start\"\n const minDate =\n value.start && align === \"end\"\n ? dayjs(value.start).add(1, \"day\").toDate()\n : undefined\n const maxDate =\n value.end && align === \"start\"\n ? dayjs(value.end).subtract(1, \"day\").toDate()\n : undefined\n const date = stringToDate(inputValue, minDate, maxDate)\n\n if (!date) return\n\n ev.preventDefault()\n\n setInputValue((prev) =>\n isObject(prev)\n ? ({\n ...(prev as MaybeInputValue<true>),\n [align]: dateToString(date),\n } as MaybeInputValue<Range>)\n : prev,\n )\n setValue((prev) =>\n isObject(prev) && !isDate(prev)\n ? ({ ...prev, [align]: date } as MaybeDateValue<\n Multiple,\n Range\n >)\n : prev,\n )\n\n if (align === \"start\") endInputRef.current?.focus()\n }\n },\n },\n { preventDefault: false },\n )\n },\n [\n dateToString,\n disabled,\n max,\n open,\n setInputValue,\n setValue,\n stringToDate,\n value,\n ],\n )\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n if (!interactive) return\n\n focusByClickRef.current = true\n\n if (allowInput) {\n if (isObject(value) && !isArray(value) && !isDate(value)) {\n if (contains(startInputRef.current, ev.target)) return\n if (contains(endInputRef.current, ev.target)) return\n\n const { end, start } = value\n\n if ((!start && !end) || !!end) {\n startInputRef.current?.focus()\n } else {\n endInputRef.current?.focus()\n }\n } else {\n startInputRef.current?.focus()\n }\n }\n\n if (openOnClick) onOpen()\n },\n [allowInput, interactive, onOpen, openOnClick, value],\n )\n\n const onMouseDown = useCallback(\n (ev: MouseEvent<HTMLDivElement | HTMLInputElement>) => {\n if (!openOnFocus) return\n\n ev.preventDefault()\n ev.stopPropagation()\n },\n [openOnFocus],\n )\n\n const onFieldFocus = useCallback(() => {\n if (allowInput) return\n\n if (openOnFocus) onOpen()\n\n focusByClickRef.current = false\n }, [allowInput, onOpen, openOnFocus])\n\n const onInputFocus = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n ev.preventDefault()\n ev.stopPropagation()\n\n setFocused(true)\n\n if (openOnFocus && !focusByClickRef.current) onOpen()\n\n focusByClickRef.current = false\n },\n [onOpen, openOnFocus],\n )\n\n const onBlur = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n setFocused(false)\n\n if (\n contains(fieldRef.current, ev.relatedTarget) ||\n contains(contentRef.current, ev.relatedTarget)\n ) {\n ev.preventDefault()\n } else {\n if (isArray(value)) {\n setInputValue(\"\" as MaybeInputValue<Range>)\n } else if (isObject(value) && !isDate(value)) {\n setInputValue((prev) =>\n isObject(prev)\n ? ({\n end: dateToString(value.end),\n start: dateToString(value.start),\n } as MaybeInputValue<Range>)\n : prev,\n )\n } else {\n setInputValue(dateToString(value) as MaybeInputValue<Range>)\n }\n }\n },\n [dateToString, setInputValue, value],\n )\n\n const onClear = useCallback(() => {\n if (!interactive) return\n\n setValue((prev) => {\n if (isDate(prev)) {\n return undefined as MaybeDateValue<Multiple, Range>\n } else if (isArray(prev)) {\n return [] as unknown as MaybeDateValue<Multiple, Range>\n } else if (isObject(prev)) {\n return { end: undefined, start: undefined } as MaybeDateValue<\n Multiple,\n Range\n >\n } else {\n return prev\n }\n })\n\n setInputValue(\n (range ? { end: \"\", start: \"\" } : \"\") as MaybeInputValue<Range>,\n )\n\n if (focusOnClear) {\n if (allowInput) {\n startInputRef.current?.focus()\n } else {\n fieldRef.current?.focus()\n }\n }\n }, [allowInput, focusOnClear, interactive, range, setInputValue, setValue])\n\n useEffect(() => {\n if (!open) return\n\n return focusTransfer(\n contentRef.current,\n allowInput ? startInputRef.current : fieldRef.current,\n )\n }, [allowInput, open])\n\n useUpdateEffect(() => {\n setMonth((prev) => getAdjustedMonth(value, prev))\n }, [value, range])\n\n useUpdateEffect(() => {\n if (isArray(valueProp)) return\n\n if (isObject(valueProp) && !isDate(valueProp)) {\n setInputValue({\n end: dateToString(valueProp.end),\n start: dateToString(valueProp.start),\n } as MaybeInputValue<Range>)\n } else {\n setInputValue(dateToString(valueProp) as MaybeInputValue<Range>)\n }\n }, [valueProp])\n\n const getRootProps: PropGetter = useCallback(\n (props) => ({\n \"data-range\": dataAttr(range),\n ...dataProps,\n ...props,\n }),\n [dataProps, range],\n )\n\n const getFieldProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getTriggerProps({\n ref: mergeRefs(ref, fieldRef),\n \"aria-haspopup\": \"dialog\",\n tabIndex: !allowInput ? 0 : -1,\n ...props,\n onClick: handlerAll(props.onClick, onClick),\n onFocus: handlerAll(props.onFocus, onFieldFocus),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }),\n\n [allowInput, getTriggerProps, onClick, onFieldFocus, onMouseDown],\n )\n\n const getInputProps: PropGetter<\"input\", { align?: InputAlign }> =\n useCallback(\n ({ align = \"start\", ...props } = {}) => {\n const inputProps: HTMLProps<\"input\"> = {\n style: {\n ...(!allowInput ? { pointerEvents: \"none\" } : {}),\n ...props.style,\n },\n autoComplete: \"off\",\n disabled,\n readOnly,\n required,\n tabIndex: allowInput ? 0 : -1,\n ...dataProps,\n ...props,\n onBlur: handlerAll(props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onInputChange),\n onFocus: handlerAll(props.onFocus, onInputFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }\n\n if (isObject(inputValue)) {\n if (align === \"start\") {\n inputProps.ref = mergeRefs(props.ref, ref, startInputRef)\n inputProps.value = inputValue.start\n inputProps.placeholder = startPlaceholder\n } else {\n inputProps.ref = mergeRefs(props.ref, ref, endInputRef)\n inputProps.value = inputValue.end\n inputProps.placeholder = endPlaceholder\n }\n\n if (!inputValue.start && align === \"start\") {\n inputProps.id = id\n inputProps.name = name\n }\n\n if (!!inputValue.start && align === \"end\") {\n inputProps.id = id\n inputProps.name = name\n }\n } else {\n inputProps.ref = mergeRefs(props.ref, ref, startInputRef)\n inputProps.value = inputValue\n inputProps.id = id\n inputProps.name = name\n\n if (isArray(value)) {\n inputProps.style = {\n ...(!focused && !!value.length\n ? visuallyHiddenAttributes.style\n : {}),\n ...inputProps.style,\n }\n inputProps.placeholder = !value.length\n ? startPlaceholder\n : undefined\n inputProps[\"data-max\"] = dataAttr(\n isNumber(max) && value.length >= max,\n )\n } else {\n inputProps.placeholder = startPlaceholder\n }\n }\n\n return inputProps\n },\n [\n allowInput,\n dataProps,\n disabled,\n endPlaceholder,\n focused,\n id,\n inputValue,\n max,\n name,\n onBlur,\n onInputFocus,\n onInputChange,\n onKeyDown,\n onMouseDown,\n readOnly,\n ref,\n required,\n startPlaceholder,\n value,\n ],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getComboboxContentProps({\n ref: mergeRefs(ref, contentRef),\n role: \"dialog\",\n ...props,\n }),\n [getComboboxContentProps],\n )\n\n const getCalendarProps: PropGetter<UseCalendarProps<Multiple, Range>> =\n useCallback(\n (props) =>\n ({\n disabled: !interactive,\n format: calendarFormat,\n locale,\n max,\n maxDate,\n minDate,\n month,\n multiple,\n range,\n value,\n onChange,\n onChangeMonth: setMonth,\n ...calendarProps,\n ...props,\n }) as UseCalendarProps<Multiple, Range>,\n [\n interactive,\n calendarFormat,\n locale,\n max,\n maxDate,\n minDate,\n month,\n multiple,\n range,\n value,\n onChange,\n setMonth,\n calendarProps,\n ],\n )\n\n const getIconProps: PropGetter = useCallback(\n (props) => ({ ...dataProps, ...props }),\n [dataProps],\n )\n\n const getClearIconProps: PropGetter = useCallback(\n (props = {}) =>\n getIconProps({\n \"aria-disabled\": ariaAttr(!interactive),\n \"aria-label\": t(\"Clear value\"),\n role: \"button\",\n tabIndex: interactive ? 0 : -1,\n ...props,\n onClick: handlerAll(props.onClick, onClear),\n onKeyDown: handlerAll(props.onKeyDown, (ev) =>\n runKeyAction(ev, { Enter: onClear, Space: onClear }),\n ),\n }),\n [getIconProps, interactive, onClear, t],\n )\n\n return {\n children,\n dateToString,\n inputValue,\n interactive,\n month,\n open,\n range,\n separator,\n setInputValue,\n setMonth,\n setValue,\n stringToDate,\n value,\n getCalendarProps,\n getClearIconProps,\n getContentProps,\n getFieldProps,\n getIconProps,\n getInputProps,\n getRootProps,\n popoverProps,\n onChange,\n onClose,\n onInputChange,\n onOpen,\n }\n}\n\nexport type UseDatePickerReturn = ReturnType<typeof useDatePicker>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAqFA,MAAMA,iBAAmC,EACvC,OACA,SACA,OACA,KACA,WACA,YACI;CACJ,MAAM,OAAO,QAAQ,MAAM;AAE3B,QACE,4CAAC;EAAK,OAAO,EAAE,iBAAiB,cAAc;aAC3C,QACE,iDAAU,IAAI,IAAI,QAAQ,QAAQ,WAAY,CAAC,OAAO,YAAY;GAChE;;AAuGX,MAAa,iBAGX,EACA,UAAUC,uCACV,UAAUC,uCACV,GAAG,UACoC,EAAE,KAAK;AAC9C,wBAAU,QAAQ,CAAC,2BAAc,QAAQ,CAAC,CAAE,WAAU;CAEtD,MAAM,EAAE,QAAQ,eAAe,MAAMC,8BAAQ,aAAa;CAC1D,MAAM,EACJ,OAAO,EACL,IACA,KACA,MACA,aAAa,MACb,mBAAmB,OACnB,gBAAgB,OAChB,WAAW,OACX,gBAAgB,CAAC,UACjB,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CAAC,CACrD;GACF,CAAC,EACJ;GAAC;GAAc;GAAa;GAAS;GAAE,CACxC;EAkBC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"use-date-picker.cjs","names":["defaultRender: DatePickerRender","DEFAULT_MAX_DATE","DEFAULT_MIN_DATE","useI18n","useFieldProps","useDateTimeFormat","inputFormat","calendarFormat","useCalendarProps","useControllableState","value","getAdjustedMonth","isBeforeDate","isAfterDate","useCombobox","onClear","updateMaybeDateValue","startPlaceholder","inputValue","minDate","maxDate","isComposing","ev","getRootProps: PropGetter","props","getFieldProps: PropGetter","mergeRefs","ref","getInputProps: PropGetter<\"input\", { align?: InputAlign }>","inputProps: HTMLProps<\"input\">","visuallyHiddenAttributes","getContentProps: PropGetter","getCalendarProps: PropGetter<UseCalendarProps<Multiple, Range>>","getIconProps: PropGetter","runKeyAction"],"sources":["../../../../src/components/date-picker/use-date-picker.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n ChangeEvent,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n} from \"react\"\nimport type { HTMLProps, HTMLRefAttributes, PropGetter } from \"../../core\"\nimport type { UseComboboxProps } from \"../../hooks/use-combobox\"\nimport type { Dict } from \"../../utils\"\nimport type {\n CalendarFormat,\n MaybeDateValue,\n UseCalendarProps,\n} from \"../calendar\"\nimport type { FieldProps } from \"../field\"\nimport dayjs from \"dayjs\"\nimport {\n cloneElement,\n isValidElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { useCombobox } from \"../../hooks/use-combobox\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n ariaAttr,\n cast,\n contains,\n dataAttr,\n focusTransfer,\n handlerAll,\n isArray,\n isComposing,\n isDate,\n isNumber,\n isObject,\n mergeRefs,\n runIfFn,\n runKeyAction,\n useUpdateEffect,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport {\n DEFAULT_MAX_DATE,\n DEFAULT_MIN_DATE,\n getAdjustedMonth,\n isAfterDate,\n isBeforeDate,\n updateMaybeDateValue,\n useCalendarProps,\n} from \"../calendar\"\nimport { useFieldProps } from \"../field\"\nimport { useDateTimeFormat } from \"../format\"\n\nexport interface DatePickerFormat extends CalendarFormat {\n input?: Intl.DateTimeFormatOptions | null\n}\n\ntype InputAlign = \"end\" | \"start\"\ntype MaybeInputValue<Range extends boolean = false> = Range extends true\n ? { end?: string; start?: string }\n : string | undefined\n\ninterface DatePickerRenderProps {\n count: number\n date: Date\n focused: boolean\n index: number\n separator: string\n value: string\n onClear: () => void\n max?: number\n}\n\nexport interface DatePickerRender {\n (props: DatePickerRenderProps): ReactNode\n}\n\nconst defaultRender: DatePickerRender = ({\n count,\n focused,\n index,\n max,\n separator,\n value,\n}) => {\n const last = count - 1 === index\n\n return (\n <span style={{ marginInlineEnd: \"var(--gap)\" }}>\n {value}\n {((!isNumber(max) || count < max) && focused) || !last ? separator : null}\n </span>\n )\n}\n\nexport interface UseDatePickerProps<\n Multiple extends boolean = false,\n Range extends boolean = false,\n>\n extends\n Omit<UseCalendarProps<Multiple, Range>, \"format\" | \"ref\">,\n Omit<\n UseComboboxProps,\n \"defaultValue\" | \"initialFocusValue\" | \"onChange\" | \"ref\" | \"value\"\n >,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * If `true`, allows input.\n *\n * @default true\n */\n allowInput?: boolean\n /**\n * If `true`, allows input of dates beyond the `minDate` and `maxDate` restrictions.\n *\n * @default true\n */\n allowInputBeyond?: boolean\n /**\n * If `true`, the date picker will be closed when the input value changes.\n *\n * @default false\n */\n closeOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * The initial value of the input.\n */\n defaultInputValue?: MaybeInputValue<Range>\n /**\n * If `true`, the input will be focused when the clear icon is clicked.\n *\n * @default true\n */\n focusOnClear?: boolean\n /**\n * The format used for conversion.\n * Check the docs to see the format of possible modifiers you can pass.\n *\n * @see https://day.js.org/docs/en/display/format#list-of-localized-formats\n */\n format?: DatePickerFormat\n /**\n * The `id` attribute of the input element.\n */\n id?: string\n /**\n * The value of the input.\n */\n inputValue?: MaybeInputValue<Range>\n /**\n * The `name` attribute of the input element.\n */\n name?: string\n /**\n * If `true`, the date picker will be opened when the input value changes.\n *\n * @default true\n */\n openOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * If `true`, the date picker will be opened when the input is focused.\n *\n * @default true\n */\n openOnFocus?: boolean\n /**\n * The pattern used to check the input element.\n */\n pattern?: RegExp\n /**\n * The placeholder for date picker.\n */\n placeholder?: string\n /**\n * The visual separator between each value.\n *\n * @default ','\n */\n separator?: string\n /**\n * The callback invoked when input value state changes.\n */\n onInputChange?: (value: MaybeInputValue<Range>) => void\n /**\n * Function that converts the input value to Date type.\n */\n parseDate?: (value: string) => Date | undefined\n /**\n * The function to render the selected date.\n */\n render?: (props: DatePickerRenderProps) => ReactNode\n}\n\nexport const useDatePicker = <\n Multiple extends boolean = false,\n Range extends boolean = false,\n>({\n maxDate = DEFAULT_MAX_DATE,\n minDate = DEFAULT_MIN_DATE,\n ...props\n}: UseDatePickerProps<Multiple, Range> = {}) => {\n if (dayjs(minDate).isAfter(dayjs(maxDate))) maxDate = minDate\n\n const { locale: defaultLocale, t } = useI18n(\"datePicker\")\n const {\n props: {\n id,\n ref,\n name,\n allowInput = true,\n allowInputBeyond = false,\n closeOnChange = false,\n multiple = false,\n closeOnSelect = !multiple,\n defaultInputValue,\n defaultMonth = new Date(),\n range = false,\n defaultValue = (range\n ? { end: undefined, start: undefined }\n : multiple\n ? []\n : undefined) as MaybeDateValue<Multiple, Range>,\n disabled,\n focusOnClear = true,\n format,\n inputValue: inputValueProp,\n locale = defaultLocale,\n max,\n month: monthProp,\n openOnChange = true,\n openOnClick = true,\n openOnFocus = true,\n parseDate,\n pattern,\n placeholder: placeholderProp,\n readOnly,\n render = defaultRender,\n required,\n separator = range ? \"-\" : \",\",\n value: valueProp,\n onChange: onChangeProp,\n onChangeMonth: onChangeMonthProp,\n onInputChange: onInputChangeProp,\n ...computedProps\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const dateTimeFormat = useDateTimeFormat({ locale })\n const { calendarFormat, inputFormat } = useMemo(() => {\n const { input: inputFormat, ...calendarFormat } = format ?? {}\n const defaultInputFormat: Intl.DateTimeFormatOptions = {\n day: \"numeric\",\n month: \"long\",\n year: \"numeric\",\n }\n\n return {\n calendarFormat,\n inputFormat:\n inputFormat !== null ? (inputFormat ?? defaultInputFormat) : undefined,\n }\n }, [format])\n const [calendarProps, rest] = useCalendarProps<Multiple, Range>(computedProps)\n const { excludeDate } = calendarProps\n const fieldRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const startInputRef = useRef<HTMLInputElement>(null)\n const endInputRef = useRef<HTMLInputElement>(null)\n const focusByClickRef = useRef<boolean>(false)\n const [focused, setFocused] = useState(false)\n const [value, setValue] = useControllableState({\n defaultValue: defaultValue as MaybeDateValue<Multiple, Range>,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [month, setMonth] = useControllableState({\n defaultValue: () => {\n let value = defaultMonth\n\n if (dayjs(minDate).isAfter(dayjs(defaultMonth)))\n value = dayjs(minDate).set(\"date\", 1).toDate()\n\n if (valueProp) {\n value = getAdjustedMonth(valueProp, value)\n } else if (defaultValue) {\n value = getAdjustedMonth(defaultValue, value)\n }\n\n return value\n },\n value: monthProp,\n onChange: onChangeMonthProp,\n })\n const stringToDate = useCallback(\n (value: string, start: Date = minDate, end: Date = maxDate) => {\n let date = parseDate?.(value)\n\n if (!date && dayjs(value).isValid()) date = dayjs(value, locale).toDate()\n\n if (date == null) return undefined\n if (excludeDate?.(date)) return undefined\n\n if (!allowInputBeyond) {\n if (isBeforeDate(date, start)) date = start\n if (isAfterDate(date, end)) date = end\n }\n\n return date\n },\n [allowInputBeyond, excludeDate, locale, maxDate, minDate, parseDate],\n )\n const dateToString = useCallback(\n (date?: Date) => {\n if (date == null) return \"\"\n\n return dateTimeFormat(date, inputFormat)\n },\n [dateTimeFormat, inputFormat],\n )\n const [inputValue, setInputValue] = useControllableState({\n defaultValue: () => {\n if (defaultInputValue) {\n if (isObject(defaultInputValue)) {\n if (dayjs(defaultInputValue.start).isValid())\n defaultInputValue.start = dateTimeFormat(\n dayjs(defaultInputValue.start).toDate(),\n inputFormat,\n )\n\n if (dayjs(defaultInputValue.end).isValid())\n defaultInputValue.end = dateTimeFormat(\n dayjs(defaultInputValue.end).toDate(),\n inputFormat,\n )\n\n return defaultInputValue\n } else {\n if (dayjs(defaultInputValue).isValid()) {\n return dateTimeFormat(\n dayjs(defaultInputValue).toDate(),\n inputFormat,\n ) as MaybeInputValue<Range>\n } else {\n return defaultInputValue as MaybeInputValue<Range>\n }\n }\n } else if (isDate(value)) {\n return dateToString(value) as MaybeInputValue<Range>\n } else if (isObject(value) && !isArray(value)) {\n return {\n end: dateToString(value.end),\n start: dateToString(value.start),\n } as MaybeInputValue<Range>\n } else {\n return \"\" as MaybeInputValue<Range>\n }\n },\n value: inputValueProp,\n onChange: onInputChangeProp,\n })\n const {\n interactive,\n open,\n getContentProps: getComboboxContentProps,\n getTriggerProps,\n popoverProps,\n onClose,\n onOpen,\n } = useCombobox({\n disabled,\n matchWidth: false,\n openOnClick: false,\n openOnEnter: !allowInput,\n openOnSpace: !allowInput,\n placement: \"end-start\",\n readOnly,\n transferFocus: false,\n ...ariaProps,\n ...dataProps,\n ...eventProps,\n ...rest,\n })\n const children = useMemo<ReactNode>(() => {\n if (!isArray(value)) return null\n\n const count = value.length\n\n return value.map((date, index) => {\n const value = dateToString(date)\n\n const onClear = (ev?: MouseEvent<HTMLElement>) => {\n ev?.preventDefault()\n ev?.stopPropagation()\n\n setValue(\n (prev) =>\n updateMaybeDateValue(date, max)(prev) as MaybeDateValue<\n Multiple,\n Range\n >,\n )\n }\n\n const component = render({\n count,\n date,\n focused,\n index,\n max,\n separator,\n value,\n onClear,\n })\n\n if (isValidElement<Dict>(component)) {\n return cloneElement(component, { ...component.props, key: index })\n } else {\n return component\n }\n })\n }, [dateToString, focused, max, render, separator, setValue, value])\n const { endPlaceholder, startPlaceholder } = useMemo(() => {\n if (range) {\n const startPlaceholder =\n placeholderProp ?? dateTimeFormat(new Date(), inputFormat)\n const endPlaceholder =\n placeholderProp ??\n dateTimeFormat(dayjs().add(1, \"day\").toDate(), inputFormat)\n\n return { endPlaceholder, startPlaceholder }\n } else {\n const placeholder =\n placeholderProp ?? dateTimeFormat(new Date(), inputFormat)\n\n return { endPlaceholder: placeholder, startPlaceholder: placeholder }\n }\n }, [dateTimeFormat, inputFormat, placeholderProp, range])\n\n const onChange = useCallback(\n (value: MaybeDateValue<Multiple, Range>) => {\n setValue(value)\n\n if (isArray(value)) {\n setInputValue(\"\" as MaybeInputValue<Range>)\n } else if (isObject(value) && !isDate(value)) {\n setInputValue({\n end: dateToString(value.end),\n start: dateToString(value.start),\n } as MaybeInputValue<Range>)\n } else {\n setInputValue(dateToString(value) as MaybeInputValue<Range>)\n }\n\n if (!closeOnSelect) return\n\n if (isObject(value) && !isArray(value) && !isDate(value)) {\n if (value.end && value.start) onClose()\n } else {\n onClose()\n }\n },\n [setValue, closeOnSelect, setInputValue, dateToString, onClose],\n )\n\n const onInputChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n if (!allowInput) return\n if (isArray(value) && value.length === max) return\n\n if (runIfFn(closeOnChange, ev)) {\n onClose()\n } else if (runIfFn(openOnChange, ev)) {\n onOpen()\n }\n\n let inputValue = ev.target.value\n\n if (pattern) inputValue = inputValue.replace(pattern, \"\")\n\n if (isArray(value)) {\n const date = stringToDate(inputValue)\n\n setInputValue(inputValue as MaybeInputValue<Range>)\n\n if (date) setMonth(dayjs(date).set(\"date\", 1).toDate())\n } else if (isObject(value) && !isDate(value)) {\n const align = contains(endInputRef.current, ev.target) ? \"end\" : \"start\"\n const minDate =\n value.start && align === \"end\"\n ? dayjs(value.start).add(1, \"day\").toDate()\n : undefined\n const maxDate =\n value.end && align === \"start\"\n ? dayjs(value.end).subtract(1, \"day\").toDate()\n : undefined\n const date = stringToDate(inputValue, minDate, maxDate)\n\n setInputValue((prev) =>\n isObject(prev)\n ? ({\n ...(prev as MaybeInputValue<true>),\n [align]: inputValue,\n } as MaybeInputValue<Range>)\n : prev,\n )\n setValue((prev) =>\n isObject(prev) && !isDate(prev)\n ? ({ ...prev, [align]: date } as MaybeDateValue<Multiple, Range>)\n : prev,\n )\n } else {\n const date = stringToDate(inputValue)\n\n setInputValue(inputValue as MaybeInputValue<Range>)\n setValue(date as MaybeDateValue<Multiple, Range>)\n }\n },\n [\n allowInput,\n closeOnChange,\n max,\n onClose,\n onOpen,\n openOnChange,\n pattern,\n setInputValue,\n setMonth,\n setValue,\n stringToDate,\n value,\n ],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLInputElement>) => {\n if (disabled || isComposing(ev)) return\n\n const inputValue = cast<HTMLInputElement>(ev.target).value\n\n runKeyAction(\n ev,\n {\n Backspace: (ev) => {\n if (!value || isDate(value)) return\n if (!!inputValue.length) return\n\n if (isArray(value)) {\n ev.preventDefault()\n\n setValue((prev) =>\n isArray(prev)\n ? (prev.slice(0, -1) as MaybeDateValue<Multiple, Range>)\n : prev,\n )\n } else if (contains(endInputRef.current, ev.target)) {\n ev.preventDefault()\n\n setInputValue({ end: \"\", start: \"\" } as MaybeInputValue<Range>)\n setValue({ end: undefined, start: undefined } as MaybeDateValue<\n Multiple,\n Range\n >)\n\n startInputRef.current?.focus()\n }\n },\n Enter: (ev) => {\n if (!open || !inputValue.length) return\n\n if (isDate(value) || isArray(value)) {\n const date = stringToDate(inputValue)\n\n if (!date) return\n\n ev.preventDefault()\n\n if (isArray(value)) {\n setInputValue(\"\" as MaybeInputValue<Range>)\n } else {\n setInputValue(dateToString(date) as MaybeInputValue<Range>)\n }\n\n setValue(\n (prev) =>\n updateMaybeDateValue(date, max)(prev) as MaybeDateValue<\n Multiple,\n Range\n >,\n )\n } else if (isObject(value)) {\n const align = contains(endInputRef.current, ev.target)\n ? \"end\"\n : \"start\"\n const minDate =\n value.start && align === \"end\"\n ? dayjs(value.start).add(1, \"day\").toDate()\n : undefined\n const maxDate =\n value.end && align === \"start\"\n ? dayjs(value.end).subtract(1, \"day\").toDate()\n : undefined\n const date = stringToDate(inputValue, minDate, maxDate)\n\n if (!date) return\n\n ev.preventDefault()\n\n setInputValue((prev) =>\n isObject(prev)\n ? ({\n ...(prev as MaybeInputValue<true>),\n [align]: dateToString(date),\n } as MaybeInputValue<Range>)\n : prev,\n )\n setValue((prev) =>\n isObject(prev) && !isDate(prev)\n ? ({ ...prev, [align]: date } as MaybeDateValue<\n Multiple,\n Range\n >)\n : prev,\n )\n\n if (align === \"start\") endInputRef.current?.focus()\n }\n },\n },\n { preventDefault: false },\n )\n },\n [\n dateToString,\n disabled,\n max,\n open,\n setInputValue,\n setValue,\n stringToDate,\n value,\n ],\n )\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n if (!interactive) return\n\n focusByClickRef.current = true\n\n if (allowInput) {\n if (isObject(value) && !isArray(value) && !isDate(value)) {\n if (contains(startInputRef.current, ev.target)) return\n if (contains(endInputRef.current, ev.target)) return\n\n const { end, start } = value\n\n if ((!start && !end) || !!end) {\n startInputRef.current?.focus()\n } else {\n endInputRef.current?.focus()\n }\n } else {\n startInputRef.current?.focus()\n }\n }\n\n if (openOnClick) onOpen()\n },\n [allowInput, interactive, onOpen, openOnClick, value],\n )\n\n const onMouseDown = useCallback(\n (ev: MouseEvent<HTMLDivElement | HTMLInputElement>) => {\n if (!openOnFocus) return\n\n ev.preventDefault()\n ev.stopPropagation()\n },\n [openOnFocus],\n )\n\n const onFieldFocus = useCallback(() => {\n if (allowInput) return\n\n if (openOnFocus) onOpen()\n\n focusByClickRef.current = false\n }, [allowInput, onOpen, openOnFocus])\n\n const onInputFocus = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n ev.preventDefault()\n ev.stopPropagation()\n\n setFocused(true)\n\n if (openOnFocus && !focusByClickRef.current) onOpen()\n\n focusByClickRef.current = false\n },\n [onOpen, openOnFocus],\n )\n\n const onBlur = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n setFocused(false)\n\n if (\n contains(fieldRef.current, ev.relatedTarget) ||\n contains(contentRef.current, ev.relatedTarget)\n ) {\n ev.preventDefault()\n } else {\n if (isArray(value)) {\n setInputValue(\"\" as MaybeInputValue<Range>)\n } else if (isObject(value) && !isDate(value)) {\n setInputValue((prev) =>\n isObject(prev)\n ? ({\n end: dateToString(value.end),\n start: dateToString(value.start),\n } as MaybeInputValue<Range>)\n : prev,\n )\n } else {\n setInputValue(dateToString(value) as MaybeInputValue<Range>)\n }\n }\n },\n [dateToString, setInputValue, value],\n )\n\n const onClear = useCallback(() => {\n if (!interactive) return\n\n setValue((prev) => {\n if (isDate(prev)) {\n return undefined as MaybeDateValue<Multiple, Range>\n } else if (isArray(prev)) {\n return [] as unknown as MaybeDateValue<Multiple, Range>\n } else if (isObject(prev)) {\n return { end: undefined, start: undefined } as MaybeDateValue<\n Multiple,\n Range\n >\n } else {\n return prev\n }\n })\n\n setInputValue(\n (range ? { end: \"\", start: \"\" } : \"\") as MaybeInputValue<Range>,\n )\n\n if (focusOnClear) {\n if (allowInput) {\n startInputRef.current?.focus()\n } else {\n fieldRef.current?.focus()\n }\n }\n }, [allowInput, focusOnClear, interactive, range, setInputValue, setValue])\n\n useEffect(() => {\n if (!open) return\n\n return focusTransfer(\n contentRef.current,\n allowInput ? startInputRef.current : fieldRef.current,\n )\n }, [allowInput, open])\n\n useUpdateEffect(() => {\n setMonth((prev) => getAdjustedMonth(value, prev))\n }, [value, range])\n\n useUpdateEffect(() => {\n if (isArray(valueProp)) return\n\n if (isObject(valueProp) && !isDate(valueProp)) {\n setInputValue({\n end: dateToString(valueProp.end),\n start: dateToString(valueProp.start),\n } as MaybeInputValue<Range>)\n } else {\n setInputValue(dateToString(valueProp) as MaybeInputValue<Range>)\n }\n }, [valueProp])\n\n const getRootProps: PropGetter = useCallback(\n (props) => ({\n \"data-range\": dataAttr(range),\n ...dataProps,\n ...props,\n }),\n [dataProps, range],\n )\n\n const getFieldProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getTriggerProps({\n ref: mergeRefs(ref, fieldRef),\n \"aria-haspopup\": \"dialog\",\n tabIndex: !allowInput ? 0 : -1,\n ...props,\n onClick: handlerAll(props.onClick, onClick),\n onFocus: handlerAll(props.onFocus, onFieldFocus),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }),\n\n [allowInput, getTriggerProps, onClick, onFieldFocus, onMouseDown],\n )\n\n const getInputProps: PropGetter<\"input\", { align?: InputAlign }> =\n useCallback(\n ({ align = \"start\", ...props } = {}) => {\n const inputProps: HTMLProps<\"input\"> = {\n style: {\n ...(!allowInput ? { pointerEvents: \"none\" } : {}),\n ...props.style,\n },\n autoComplete: \"off\",\n disabled,\n readOnly,\n required,\n tabIndex: allowInput ? 0 : -1,\n ...dataProps,\n ...props,\n onBlur: handlerAll(props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onInputChange),\n onFocus: handlerAll(props.onFocus, onInputFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }\n\n if (isObject(inputValue)) {\n if (align === \"start\") {\n inputProps.ref = mergeRefs(props.ref, ref, startInputRef)\n inputProps.value = inputValue.start\n inputProps.placeholder = startPlaceholder\n } else {\n inputProps.ref = mergeRefs(props.ref, ref, endInputRef)\n inputProps.value = inputValue.end\n inputProps.placeholder = endPlaceholder\n }\n\n if (!inputValue.start && align === \"start\") {\n inputProps.id = id\n inputProps.name = name\n }\n\n if (!!inputValue.start && align === \"end\") {\n inputProps.id = id\n inputProps.name = name\n }\n } else {\n inputProps.ref = mergeRefs(props.ref, ref, startInputRef)\n inputProps.value = inputValue\n inputProps.id = id\n inputProps.name = name\n\n if (isArray(value)) {\n inputProps.style = {\n ...(!focused && !!value.length\n ? visuallyHiddenAttributes.style\n : {}),\n ...inputProps.style,\n }\n inputProps.placeholder = !value.length\n ? startPlaceholder\n : undefined\n inputProps[\"data-max\"] = dataAttr(\n isNumber(max) && value.length >= max,\n )\n } else {\n inputProps.placeholder = startPlaceholder\n }\n }\n\n return inputProps\n },\n [\n allowInput,\n dataProps,\n disabled,\n endPlaceholder,\n focused,\n id,\n inputValue,\n max,\n name,\n onBlur,\n onInputFocus,\n onInputChange,\n onKeyDown,\n onMouseDown,\n readOnly,\n ref,\n required,\n startPlaceholder,\n value,\n ],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getComboboxContentProps({\n ref: mergeRefs(ref, contentRef),\n role: \"dialog\",\n ...props,\n }),\n [getComboboxContentProps],\n )\n\n const getCalendarProps: PropGetter<UseCalendarProps<Multiple, Range>> =\n useCallback(\n (props) =>\n ({\n disabled: !interactive,\n format: calendarFormat,\n locale,\n max,\n maxDate,\n minDate,\n month,\n multiple,\n range,\n value,\n onChange,\n onChangeMonth: setMonth,\n ...calendarProps,\n ...props,\n }) as UseCalendarProps<Multiple, Range>,\n [\n interactive,\n calendarFormat,\n locale,\n max,\n maxDate,\n minDate,\n month,\n multiple,\n range,\n value,\n onChange,\n setMonth,\n calendarProps,\n ],\n )\n\n const getIconProps: PropGetter = useCallback(\n (props) => ({ ...dataProps, ...props }),\n [dataProps],\n )\n\n const getClearIconProps: PropGetter = useCallback(\n (props = {}) =>\n getIconProps({\n \"aria-disabled\": ariaAttr(!interactive),\n \"aria-label\": t(\"Clear value\"),\n role: \"button\",\n tabIndex: interactive ? 0 : -1,\n ...props,\n onClick: handlerAll(props.onClick, onClear),\n onKeyDown: handlerAll(props.onKeyDown, (ev) =>\n runKeyAction(ev, { Enter: onClear, Space: onClear }),\n ),\n }),\n [getIconProps, interactive, onClear, t],\n )\n\n return {\n children,\n dateToString,\n inputValue,\n interactive,\n month,\n open,\n range,\n separator,\n setInputValue,\n setMonth,\n setValue,\n stringToDate,\n value,\n getCalendarProps,\n getClearIconProps,\n getContentProps,\n getFieldProps,\n getIconProps,\n getInputProps,\n getRootProps,\n popoverProps,\n onChange,\n onClose,\n onInputChange,\n onOpen,\n }\n}\n\nexport type UseDatePickerReturn = ReturnType<typeof useDatePicker>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAqFA,MAAMA,iBAAmC,EACvC,OACA,SACA,OACA,KACA,WACA,YACI;CACJ,MAAM,OAAO,QAAQ,MAAM;AAE3B,QACE,4CAAC;EAAK,OAAO,EAAE,iBAAiB,cAAc;aAC3C,QACE,iDAAU,IAAI,IAAI,QAAQ,QAAQ,WAAY,CAAC,OAAO,YAAY;GAChE;;AAuGX,MAAa,iBAGX,EACA,UAAUC,uCACV,UAAUC,uCACV,GAAG,UACoC,EAAE,KAAK;AAC9C,wBAAU,QAAQ,CAAC,2BAAc,QAAQ,CAAC,CAAE,WAAU;CAEtD,MAAM,EAAE,QAAQ,eAAe,MAAMC,8BAAQ,aAAa;CAC1D,MAAM,EACJ,OAAO,EACL,IACA,KACA,MACA,aAAa,MACb,mBAAmB,OACnB,gBAAgB,OAChB,WAAW,OACX,gBAAgB,CAAC,UACjB,mBACA,+BAAe,IAAI,MAAM,EACzB,QAAQ,OACR,eAAgB,QACZ;EAAE,KAAK;EAAW,OAAO;EAAW,GACpC,WACE,EAAE,GACF,QACN,UACA,eAAe,MACf,QACA,YAAY,gBACZ,SAAS,eACT,KACA,OAAO,WACP,eAAe,MACf,cAAc,MACd,cAAc,MACd,WACA,SACA,aAAa,iBACb,UACA,SAAS,eACT,UACA,YAAY,QAAQ,MAAM,KAC1B,OAAO,WACP,UAAU,cACV,eAAe,mBACf,eAAe,mBACf,GAAG,iBAEL,WACA,WACA,eACEC,sCAAc,MAAM;CACxB,MAAM,iBAAiBC,+CAAkB,EAAE,QAAQ,CAAC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EACA;EACA;EACA;EACA;EACA;EACD,CACF;CAEH,MAAMC,0CACH,EAAE,YAAK,GAAGP,YAAU,EAAE,KACrB,wBAAwB;EACtB,KAAKE,sBAAUC,OAAK,WAAW;EAC/B,MAAM;EACN,GAAGH;EACJ,CAAC,EACJ,CAAC,wBAAwB,CAC1B;CAED,MAAMQ,2CAED,aACE;EACC,UAAU,CAAC;EACX,QAAQ;EACR;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,eAAe;EACf,GAAG;EACH,GAAGR;EACJ,GACH;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CACF;CAEH,MAAMS,uCACH,aAAW;EAAE,GAAG;EAAW,GAAGT;EAAO,GACtC,CAAC,UAAU,CACZ;AAkBD,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,2CA9BC,UAAQ,EAAE,KACT,aAAa;GACX,iEAA0B,CAAC,YAAY;GACvC,cAAc,EAAE,cAAc;GAC9B,MAAM;GACN,UAAU,cAAc,IAAI;GAC5B,GAAGA;GACH,2DAAoBA,QAAM,SAAS,QAAQ;GAC3C,6DAAsBA,QAAM,YAAY,OACtCU,yBAAa,IAAI;IAAE,OAAO;IAAS,OAAO;IAAS,CAAC,CACrD;GACF,CAAC,EACJ;GAAC;GAAc;GAAa;GAAS;GAAE,CACxC;EAkBC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-dropzone.cjs","names":["fromEvent","useFieldProps","getRootProps: PropGetter","props","mergeRefs"],"sources":["../../../../src/components/dropzone/use-dropzone.ts"],"sourcesContent":["\"use client\"\n\nimport type { RefObject } from \"react\"\nimport type { Accept, DropzoneOptions } from \"react-dropzone\"\nimport type { HTMLProps, PropGetter } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport { fromEvent } from \"file-selector\"\nimport { useCallback, useId } from \"react\"\nimport { useDropzone as useOriginalDropzone } from \"react-dropzone\"\nimport {\n ariaAttr,\n assignRef,\n cx,\n dataAttr,\n isArray,\n mergeRefs,\n} from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\nexport interface UseDropzoneProps\n extends Omit<HTMLProps, \"onDrop\" | \"onError\">, FieldProps {\n /**\n * The HTML `name` attribute used for forms.\n */\n name?: string\n /**\n * Set accepted file types.\n */\n accept?: Accept | string[]\n /**\n * Set to true to focus the root element on render.\n *\n * @default false\n */\n autoFocus?: boolean\n /**\n * Use this to provide a custom file aggregator.\n */\n getFilesFromEvent?: DropzoneOptions[\"getFilesFromEvent\"]\n /**\n * If `true`, display the dropzone loading icon.\n *\n * @default false\n */\n loading?: boolean\n /**\n * Maximum accepted number of files.\n * The default value is 0 which means there is no limitation to how many files are accepted.\n *\n * @default 0\n */\n maxFiles?: number\n /**\n * Maximum file size (in bytes).\n *\n * @default Infinity\n */\n maxSize?: number\n /**\n * Minimum file size (in bytes).\n *\n * @default 0\n */\n minSize?: number\n /**\n * Allow drag and drop (or selection from the file dialog) of multiple files.\n *\n * @default false\n */\n multiple?: boolean\n /**\n * If true, disables click to open the native file selection dialog.\n *\n * @default false\n */\n noClick?: boolean\n /**\n * If true, disables drag and drop.\n *\n * @default false\n */\n noDrag?: boolean\n /**\n * If true, stops drag event propagation to parents.\n *\n * @default false\n */\n noDragEventsBubbling?: boolean\n /**\n * If true, disables `space` and `enter` to open the native file selection dialog.\n * Note that it also stops tracking the focus state.\n *\n * @default false\n */\n noKeyboard?: boolean\n /**\n * Ref to a open function.\n */\n openRef?: RefObject<() => void>\n /**\n * If false, allow dropped items to take over the current browser window.\n *\n * @default true\n */\n preventDropOnDocument?: boolean\n /**\n * If true, use the [File System API](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API) to read files.\n *\n * @default false\n */\n useFsAccessApi?: boolean\n /**\n * Custom validation function.\n * It must return null if there's no errors.\n */\n validator?: DropzoneOptions[\"validator\"]\n /**\n * Callback for when the dragenter event occurs.\n */\n onDragEnter?: DropzoneOptions[\"onDragEnter\"]\n /**\n * Callback for when the dragleave event occurs.\n */\n onDragLeave?: DropzoneOptions[\"onDragLeave\"]\n /**\n * Callback for when the dragover event occurs.\n */\n onDragOver?: DropzoneOptions[\"onDragOver\"]\n /**\n * Callback for when the drop event occurs.\n * Note that this callback is invoked after the `getFilesFromEvent` callback is done.\n */\n onDrop?: DropzoneOptions[\"onDrop\"]\n /**\n * Callback for when the drop event occurs.\n * Note that if no files are accepted, this callback is not invoked.\n */\n onDropAccepted?: DropzoneOptions[\"onDropAccepted\"]\n /**\n * Callback for when the drop event occurs.\n * Note that if no files are rejected, this callback is not invoked.\n */\n onDropRejected?: DropzoneOptions[\"onDropRejected\"]\n /**\n * Callback for when there's some error from any of the promises.\n */\n onError?: DropzoneOptions[\"onError\"]\n /**\n * Callback for when closing the file dialog with no selection.\n */\n onFileDialogCancel?: DropzoneOptions[\"onFileDialogCancel\"]\n /**\n * Callback for when opening the file dialog.\n */\n onFileDialogOpen?: DropzoneOptions[\"onFileDialogOpen\"]\n}\n\nexport const useDropzone = (props: UseDropzoneProps = {}) => {\n const {\n props: {\n id,\n name,\n accept,\n autoFocus = false,\n disabled,\n getFilesFromEvent = fromEvent,\n loading,\n maxFiles = 0,\n maxSize = Infinity,\n minSize = 0,\n multiple = false,\n noClick = false,\n noDrag = false,\n noDragEventsBubbling = false,\n noKeyboard = false,\n openRef,\n preventDropOnDocument = true,\n readOnly,\n useFsAccessApi = false,\n validator,\n onDragEnter,\n onDragLeave,\n onDragOver,\n onDrop,\n onDropAccepted,\n onDropRejected,\n onError,\n onFileDialogCancel,\n onFileDialogOpen,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const labelledbyId = useId()\n const interactive = !(loading || readOnly || disabled)\n const {\n acceptedFiles,\n fileRejections,\n isDragAccept: dragAccept,\n isDragActive: dragActive,\n isDragReject: dragReject,\n isFocused: focused,\n open,\n getInputProps: getOriginalInputProps,\n getRootProps: getOriginalRootProps,\n } = useOriginalDropzone({\n accept: isArray(accept)\n ? accept.reduce((prev, current) => ({ ...prev, [current]: [] }), {})\n : accept,\n autoFocus,\n disabled: !interactive,\n getFilesFromEvent,\n maxFiles,\n maxSize,\n minSize,\n multiple,\n noClick,\n noDrag,\n noDragEventsBubbling,\n noKeyboard,\n preventDropOnDocument,\n useFsAccessApi,\n validator,\n onDragEnter,\n onDragLeave,\n onDragOver,\n onDrop,\n onDropAccepted,\n onDropRejected,\n onError,\n onFileDialogCancel,\n onFileDialogOpen,\n })\n const dragIdle = !dragAccept && !dragReject\n\n assignRef(openRef, open)\n\n const getRootProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getOriginalRootProps({\n id: labelledbyId,\n ...dataProps,\n ...eventProps,\n \"aria-disabled\": ariaAttr(!interactive),\n \"data-accept\": dataAttr(dragAccept),\n \"data-idle\": dataAttr(dragIdle),\n \"data-loading\": dataAttr(loading),\n \"data-reject\": dataAttr(dragReject),\n ...rest,\n ...props,\n ref: mergeRefs(ref, rest.ref),\n }),\n [\n getOriginalRootProps,\n labelledbyId,\n dataProps,\n eventProps,\n interactive,\n dragAccept,\n dragIdle,\n loading,\n dragReject,\n rest,\n ],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n ({ \"aria-labelledby\": ariaLabelledby, ...props } = {}) =>\n getOriginalInputProps({\n id,\n name,\n disabled,\n readOnly,\n ...ariaProps,\n ...dataProps,\n ...props,\n \"aria-labelledby\": cx(ariaLabelledby, labelledbyId),\n }),\n [\n getOriginalInputProps,\n id,\n name,\n disabled,\n readOnly,\n ariaProps,\n dataProps,\n labelledbyId,\n ],\n )\n\n return {\n acceptedFiles,\n dragAccept,\n dragActive,\n dragIdle,\n dragReject,\n fileRejections,\n focused,\n loading,\n open,\n getInputProps,\n getRootProps,\n }\n}\n\nexport type UseDropzoneReturn = ReturnType<typeof useDropzone>\n"],"mappings":";;;;;;;;;;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,EAAE,mBAAmB,gBAAgB,GAAGD,YAAU,EAAE,KACnD,sBAAsB;GACpB;GACA;GACA;GACA;GACA,GAAG;GACH,GAAG;GACH,GAAGA;GACH,6DAAsB,gBAAgB,aAAa;GACpD,CAAC,EACJ;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CACF;EAaC;EACD"}
1
+ {"version":3,"file":"use-dropzone.cjs","names":["fromEvent","useFieldProps","getRootProps: PropGetter","props","mergeRefs"],"sources":["../../../../src/components/dropzone/use-dropzone.ts"],"sourcesContent":["\"use client\"\n\nimport type { RefObject } from \"react\"\nimport type { Accept, DropzoneOptions } from \"react-dropzone\"\nimport type { HTMLProps, PropGetter } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport { fromEvent } from \"file-selector\"\nimport { useCallback, useId } from \"react\"\nimport { useDropzone as useOriginalDropzone } from \"react-dropzone\"\nimport {\n ariaAttr,\n assignRef,\n cx,\n dataAttr,\n isArray,\n mergeRefs,\n} from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\nexport interface UseDropzoneProps\n extends Omit<HTMLProps, \"onDrop\" | \"onError\">, FieldProps {\n /**\n * Set accepted file types.\n */\n accept?: Accept | string[]\n /**\n * Set to true to focus the root element on render.\n *\n * @default false\n */\n autoFocus?: boolean\n /**\n * Use this to provide a custom file aggregator.\n */\n getFilesFromEvent?: DropzoneOptions[\"getFilesFromEvent\"]\n /**\n * If `true`, display the dropzone loading icon.\n *\n * @default false\n */\n loading?: boolean\n /**\n * Maximum accepted number of files.\n * The default value is 0 which means there is no limitation to how many files are accepted.\n *\n * @default 0\n */\n maxFiles?: number\n /**\n * Maximum file size (in bytes).\n *\n * @default Infinity\n */\n maxSize?: number\n /**\n * Minimum file size (in bytes).\n *\n * @default 0\n */\n minSize?: number\n /**\n * Allow drag and drop (or selection from the file dialog) of multiple files.\n *\n * @default false\n */\n multiple?: boolean\n /**\n * The HTML `name` attribute used for forms.\n */\n name?: string\n /**\n * If true, disables click to open the native file selection dialog.\n *\n * @default false\n */\n noClick?: boolean\n /**\n * If true, disables drag and drop.\n *\n * @default false\n */\n noDrag?: boolean\n /**\n * If true, stops drag event propagation to parents.\n *\n * @default false\n */\n noDragEventsBubbling?: boolean\n /**\n * If true, disables `space` and `enter` to open the native file selection dialog.\n * Note that it also stops tracking the focus state.\n *\n * @default false\n */\n noKeyboard?: boolean\n /**\n * Ref to a open function.\n */\n openRef?: RefObject<() => void>\n /**\n * If false, allow dropped items to take over the current browser window.\n *\n * @default true\n */\n preventDropOnDocument?: boolean\n /**\n * If true, use the [File System API](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API) to read files.\n *\n * @default false\n */\n useFsAccessApi?: boolean\n /**\n * Custom validation function.\n * It must return null if there's no errors.\n */\n validator?: DropzoneOptions[\"validator\"]\n /**\n * Callback for when the dragenter event occurs.\n */\n onDragEnter?: DropzoneOptions[\"onDragEnter\"]\n /**\n * Callback for when the dragleave event occurs.\n */\n onDragLeave?: DropzoneOptions[\"onDragLeave\"]\n /**\n * Callback for when the dragover event occurs.\n */\n onDragOver?: DropzoneOptions[\"onDragOver\"]\n /**\n * Callback for when the drop event occurs.\n * Note that this callback is invoked after the `getFilesFromEvent` callback is done.\n */\n onDrop?: DropzoneOptions[\"onDrop\"]\n /**\n * Callback for when the drop event occurs.\n * Note that if no files are accepted, this callback is not invoked.\n */\n onDropAccepted?: DropzoneOptions[\"onDropAccepted\"]\n /**\n * Callback for when the drop event occurs.\n * Note that if no files are rejected, this callback is not invoked.\n */\n onDropRejected?: DropzoneOptions[\"onDropRejected\"]\n /**\n * Callback for when there's some error from any of the promises.\n */\n onError?: DropzoneOptions[\"onError\"]\n /**\n * Callback for when closing the file dialog with no selection.\n */\n onFileDialogCancel?: DropzoneOptions[\"onFileDialogCancel\"]\n /**\n * Callback for when opening the file dialog.\n */\n onFileDialogOpen?: DropzoneOptions[\"onFileDialogOpen\"]\n}\n\nexport const useDropzone = (props: UseDropzoneProps = {}) => {\n const {\n props: {\n id,\n name,\n accept,\n autoFocus = false,\n disabled,\n getFilesFromEvent = fromEvent,\n loading,\n maxFiles = 0,\n maxSize = Infinity,\n minSize = 0,\n multiple = false,\n noClick = false,\n noDrag = false,\n noDragEventsBubbling = false,\n noKeyboard = false,\n openRef,\n preventDropOnDocument = true,\n readOnly,\n useFsAccessApi = false,\n validator,\n onDragEnter,\n onDragLeave,\n onDragOver,\n onDrop,\n onDropAccepted,\n onDropRejected,\n onError,\n onFileDialogCancel,\n onFileDialogOpen,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const labelledbyId = useId()\n const interactive = !(loading || readOnly || disabled)\n const {\n acceptedFiles,\n fileRejections,\n isDragAccept: dragAccept,\n isDragActive: dragActive,\n isDragReject: dragReject,\n isFocused: focused,\n open,\n getInputProps: getOriginalInputProps,\n getRootProps: getOriginalRootProps,\n } = useOriginalDropzone({\n accept: isArray(accept)\n ? accept.reduce((prev, current) => ({ ...prev, [current]: [] }), {})\n : accept,\n autoFocus,\n disabled: !interactive,\n getFilesFromEvent,\n maxFiles,\n maxSize,\n minSize,\n multiple,\n noClick,\n noDrag,\n noDragEventsBubbling,\n noKeyboard,\n preventDropOnDocument,\n useFsAccessApi,\n validator,\n onDragEnter,\n onDragLeave,\n onDragOver,\n onDrop,\n onDropAccepted,\n onDropRejected,\n onError,\n onFileDialogCancel,\n onFileDialogOpen,\n })\n const dragIdle = !dragAccept && !dragReject\n\n assignRef(openRef, open)\n\n const getRootProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getOriginalRootProps({\n id: labelledbyId,\n ...dataProps,\n ...eventProps,\n \"aria-disabled\": ariaAttr(!interactive),\n \"data-accept\": dataAttr(dragAccept),\n \"data-idle\": dataAttr(dragIdle),\n \"data-loading\": dataAttr(loading),\n \"data-reject\": dataAttr(dragReject),\n ...rest,\n ...props,\n ref: mergeRefs(ref, rest.ref),\n }),\n [\n getOriginalRootProps,\n labelledbyId,\n dataProps,\n eventProps,\n interactive,\n dragAccept,\n dragIdle,\n loading,\n dragReject,\n rest,\n ],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n ({ \"aria-labelledby\": ariaLabelledby, ...props } = {}) =>\n getOriginalInputProps({\n id,\n name,\n disabled,\n readOnly,\n ...ariaProps,\n ...dataProps,\n ...props,\n \"aria-labelledby\": cx(ariaLabelledby, labelledbyId),\n }),\n [\n getOriginalInputProps,\n id,\n name,\n disabled,\n readOnly,\n ariaProps,\n dataProps,\n labelledbyId,\n ],\n )\n\n return {\n acceptedFiles,\n dragAccept,\n dragActive,\n dragIdle,\n dragReject,\n fileRejections,\n focused,\n loading,\n open,\n getInputProps,\n getRootProps,\n }\n}\n\nexport type UseDropzoneReturn = ReturnType<typeof useDropzone>\n"],"mappings":";;;;;;;;;;;;AA6JA,MAAa,eAAe,QAA0B,EAAE,KAAK;CAC3D,MAAM,EACJ,OAAO,EACL,IACA,MACA,QACA,YAAY,OACZ,UACA,oBAAoBA,yBACpB,SACA,WAAW,GACX,UAAU,UACV,UAAU,GACV,WAAW,OACX,UAAU,OACV,SAAS,OACT,uBAAuB,OACvB,aAAa,OACb,SACA,wBAAwB,MACxB,UACA,iBAAiB,OACjB,WACA,aACA,aACA,YACA,QACA,gBACA,gBACA,SACA,oBACA,kBACA,GAAG,QAEL,WACA,WACA,eACEC,sCAAc,MAAM;CACxB,MAAM,iCAAsB;CAC5B,MAAM,cAAc,EAAE,WAAW,YAAY;CAC7C,MAAM,EACJ,eACA,gBACA,cAAc,YACd,cAAc,YACd,cAAc,YACd,WAAW,SACX,MACA,eAAe,uBACf,cAAc,yDACQ;EACtB,uDAAgB,OAAO,GACnB,OAAO,QAAQ,MAAM,aAAa;GAAE,GAAG;IAAO,UAAU,EAAE;GAAE,GAAG,EAAE,CAAC,GAClE;EACJ;EACA,UAAU,CAAC;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CACF,MAAM,WAAW,CAAC,cAAc,CAAC;AAEjC,uBAAU,SAAS,KAAK;CAExB,MAAMC,uCACH,EAAE,KAAK,GAAGC,YAAU,EAAE,KACrB,qBAAqB;EACnB,IAAI;EACJ,GAAG;EACH,GAAG;EACH,iEAA0B,CAAC,YAAY;EACvC,+DAAwB,WAAW;EACnC,6DAAsB,SAAS;EAC/B,gEAAyB,QAAQ;EACjC,+DAAwB,WAAW;EACnC,GAAG;EACH,GAAGA;EACH,KAAKC,sBAAU,KAAK,KAAK,IAAI;EAC9B,CAAC,EACJ;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CACF;AA0BD,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,uCAjCC,EAAE,mBAAmB,gBAAgB,GAAGD,YAAU,EAAE,KACnD,sBAAsB;GACpB;GACA;GACA;GACA;GACA,GAAG;GACH,GAAG;GACH,GAAGA;GACH,6DAAsB,gBAAgB,aAAa;GACpD,CAAC,EACJ;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CACF;EAaC;EACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"field.cjs","names":["createContext","createSlotComponent","fieldStyle","useSplitChildren","styled","useFieldsetContext"],"sources":["../../../../src/components/field/field.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactNode } from \"react\"\nimport type { HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { FieldStyle } from \"./field.style\"\nimport { isValidElement, useId, useMemo, useState } from \"react\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { createContext, dataAttr, useSplitChildren } from \"../../utils\"\nimport { useFieldsetContext } from \"../fieldset\"\nimport { fieldStyle } from \"./field.style\"\n\nexport interface FieldContext\n extends FieldProps, Pick<FieldRootProps, \"replace\"> {\n id: string\n errorMessageId: string\n focused: boolean\n helperMessageId: string\n labelId: string\n onBlur: () => void\n onFocus: () => void\n}\n\nconst [FieldContext, useFieldContext] = createContext<FieldContext>({\n name: \"FieldContext\",\n strict: false,\n})\n\nexport { FieldContext, useFieldContext }\n\nexport interface FieldProps {\n /**\n * If `true`, the field will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * If `true`, the field will be invalid.\n *\n * @default false\n */\n invalid?: boolean\n /**\n * If `true`, the field will be readonly.\n *\n * @default false\n */\n readOnly?: boolean\n /**\n * If `true`, the field will be required.\n *\n * @default false\n */\n required?: boolean\n}\n\nexport interface FieldRootProps\n extends\n HTMLStyledProps,\n ThemeProps<FieldStyle>,\n Pick<FieldLabelProps, \"optionalIndicator\" | \"requiredIndicator\">,\n FieldProps {\n /**\n * The field error message to use.\n */\n errorMessage?: ReactNode\n /**\n * The field helper message to use.\n */\n helperMessage?: ReactNode\n /**\n * The field label to use.\n */\n label?: ReactNode\n /**\n * If `true`, switch between helper message and error message using invalid.\n *\n * @default true\n */\n replace?: boolean\n /**\n * Props the error message component.\n */\n errorMessageProps?: FieldErrorMessageProps\n /**\n * Props the helper message component.\n */\n helperMessageProps?: FieldHelperMessageProps\n /**\n * Props the label component.\n */\n labelProps?: FieldLabelProps\n}\n\nconst {\n PropsContext: FieldPropsContext,\n usePropsContext: useFieldPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<FieldRootProps, FieldStyle>(\"field\", fieldStyle)\n\nexport { FieldPropsContext, useFieldPropsContext }\n\n/**\n * `Field` is a component used to group form elements with label, helper message, error message, etc.\n *\n * @see https://yamada-ui.com/docs/components/field\n */\nexport const FieldRoot = withProvider<\"div\", FieldRootProps>(\n ({\n id,\n children,\n disabled,\n errorMessage,\n helperMessage,\n invalid,\n label,\n optionalIndicator,\n readOnly,\n replace = true,\n required,\n requiredIndicator,\n errorMessageProps,\n helperMessageProps,\n labelProps,\n ...rest\n }) => {\n const uuid = useId()\n const labelId = useId()\n const helperMessageId = useId()\n const errorMessageId = useId()\n const [focused, setFocused] = useState<boolean>(false)\n const [\n omittedChildren,\n customLabel,\n customHelperMessage,\n customErrorMessage,\n ] = useSplitChildren(\n children,\n FieldLabel,\n FieldHelperMessage,\n FieldErrorMessage,\n )\n\n id ??= uuid\n\n const context = useMemo(\n () => ({\n id,\n disabled,\n errorMessageId,\n focused,\n helperMessageId,\n invalid,\n labelId,\n readOnly,\n replace,\n required,\n onBlur: () => setFocused(false),\n onFocus: () => setFocused(true),\n }),\n [\n id,\n disabled,\n labelId,\n focused,\n invalid,\n helperMessageId,\n errorMessageId,\n readOnly,\n replace,\n required,\n ],\n )\n\n return (\n <FieldContext value={context}>\n <styled.div\n data-disabled={dataAttr(disabled)}\n data-focus={dataAttr(focused)}\n data-invalid={dataAttr(invalid)}\n data-readonly={dataAttr(readOnly)}\n {...rest}\n >\n {customLabel ||\n (label ? (\n <FieldLabel\n optionalIndicator={optionalIndicator}\n requiredIndicator={requiredIndicator}\n {...labelProps}\n >\n {label}\n </FieldLabel>\n ) : null)}\n\n {omittedChildren}\n\n {customHelperMessage ||\n (helperMessage ? (\n <FieldHelperMessage {...helperMessageProps}>\n {helperMessage}\n </FieldHelperMessage>\n ) : null)}\n\n {customErrorMessage ||\n (errorMessage ? (\n <FieldErrorMessage {...errorMessageProps}>\n {errorMessage}\n </FieldErrorMessage>\n ) : null)}\n </styled.div>\n </FieldContext>\n )\n },\n \"root\",\n)()\n\nexport interface FieldLabelProps extends HTMLStyledProps<\"label\"> {\n /**\n * The optional indicator to use.\n */\n optionalIndicator?: ReactNode\n /**\n * If `true`, the field will be required.\n *\n * @default false\n */\n required?: boolean\n /**\n * The required indicator to use.\n */\n requiredIndicator?: ReactNode\n}\n\nexport const FieldLabel = withContext<\"label\", FieldLabelProps>(\n ({\n id,\n htmlFor,\n children,\n optionalIndicator = null,\n required,\n requiredIndicator = null,\n ...rest\n }) => {\n const fieldsetContext = useFieldsetContext()\n const fieldContext = useFieldContext()\n\n id ??= fieldContext?.labelId\n htmlFor ??= fieldContext?.id\n required ??= fieldContext?.required ?? fieldsetContext?.required\n\n const disabled = fieldContext?.disabled ?? fieldsetContext?.disabled\n const invalid = fieldContext?.invalid ?? fieldsetContext?.invalid\n const readOnly = fieldContext?.readOnly ?? fieldsetContext?.readOnly\n const focused = fieldContext?.focused\n\n return (\n <styled.label\n id={id}\n htmlFor={htmlFor}\n data-disabled={dataAttr(disabled)}\n data-focus={dataAttr(focused)}\n data-invalid={dataAttr(invalid)}\n data-readonly={dataAttr(readOnly)}\n {...rest}\n >\n {children}\n\n {required ? (\n requiredIndicator ? (\n <FieldRequiredIndicator>{requiredIndicator}</FieldRequiredIndicator>\n ) : (\n <FieldRequiredIndicator />\n )\n ) : (\n optionalIndicator\n )}\n </styled.label>\n )\n },\n \"label\",\n)()\n\ninterface FieldRequiredIndicatorProps extends HTMLStyledProps<\"span\"> {}\n\nconst FieldRequiredIndicator = withContext<\"span\", FieldRequiredIndicatorProps>(\n ({ children, ...rest }) => {\n if (!isValidElement(children)) {\n return (\n <styled.span aria-hidden role=\"presentation\" {...rest}>\n {children ?? <>*</>}\n </styled.span>\n )\n } else {\n return children\n }\n },\n \"requiredIndicator\",\n)()\n\nexport interface FieldHelperMessageProps extends HTMLStyledProps<\"span\"> {}\n\nexport const FieldHelperMessage = withContext<\"span\", FieldHelperMessageProps>(\n (props) => {\n const fieldsetContext = useFieldsetContext()\n const {\n helperMessageId,\n invalid = fieldsetContext?.invalid,\n replace,\n } = useFieldContext() ?? {}\n\n return (\n <styled.span\n id={helperMessageId}\n hidden={replace && invalid ? true : false}\n {...props}\n />\n )\n },\n \"helperMessage\",\n)()\n\nexport interface FieldErrorMessageProps extends HTMLStyledProps<\"span\"> {}\n\nexport const FieldErrorMessage = withContext<\"span\", FieldErrorMessageProps>(\n (props) => {\n const fieldsetContext = useFieldsetContext()\n const { errorMessageId, invalid = fieldsetContext?.invalid } =\n useFieldContext() ?? {}\n\n return (\n <styled.span\n id={errorMessageId}\n aria-live={invalid ? \"polite\" : undefined}\n hidden={!invalid}\n {...props}\n />\n )\n },\n \"errorMessage\",\n)()\n"],"mappings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a,cAAc,YAAY,iBAAiB;CAExD,MAAM,WAAW,cAAc,YAAY,iBAAiB;CAC5D,MAAM,UAAU,cAAc,WAAW,iBAAiB;CAC1D,MAAM,WAAW,cAAc,YAAY,iBAAiB;CAC5D,MAAM,UAAU,cAAc;AAE9B,QACE,4CAACD,uBAAO;EACF;EACK;EACT,iEAAwB,SAAS;EACjC,8DAAqB,QAAQ;EAC7B,gEAAuB,QAAQ;EAC/B,iEAAwB,SAAS;EACjC,GAAI;aAEH,UAEA,WACC,oBACE,2CAAC,oCAAwB,oBAA2C,GAEpE,2CAAC,2BAAyB,GAG5B;GAEW;GAGnB,QACD,EAAE;AAIH,MAAM,yBAAyB,aAC5B,EAAE,UAAU,GAAG,WAAW;AACzB,KAAI,2BAAgB,SAAS,CAC3B,QACE,2CAACA,uBAAO;EAAK;EAAY,MAAK;EAAe,GAAI;YAC9C,YAAY,mFAAE,MAAI;GACP;KAGhB,QAAO;GAGX,oBACD,EAAE;AAIH,MAAa,qBAAqB,aAC/B,UAAU;CACT,MAAM,kBAAkBC,qCAAoB;CAC5C,MAAM,EACJ,iBACA,UAAU,iBAAiB,SAC3B,YACE,iBAAiB,IAAI,EAAE;AAE3B,QACE,2CAACD,uBAAO;EACN,IAAI;EACJ,QAAQ,WAAW,UAAU,OAAO;EACpC,GAAI;GACJ;GAGN,gBACD,EAAE;AAIH,MAAa,oBAAoB,aAC9B,UAAU;CACT,MAAM,kBAAkBC,qCAAoB;CAC5C,MAAM,EAAE,gBAAgB,UAAU,iBAAiB,YACjD,iBAAiB,IAAI,EAAE;AAEzB,QACE,2CAACD,uBAAO;EACN,IAAI;EACJ,aAAW,UAAU,WAAW;EAChC,QAAQ,CAAC;EACT,GAAI;GACJ;GAGN,eACD,EAAE"}
1
+ {"version":3,"file":"field.cjs","names":["createContext","createSlotComponent","fieldStyle","useSplitChildren","styled","useFieldsetContext"],"sources":["../../../../src/components/field/field.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactNode } from \"react\"\nimport type { HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { FieldStyle } from \"./field.style\"\nimport { isValidElement, useId, useMemo, useState } from \"react\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { createContext, dataAttr, useSplitChildren } from \"../../utils\"\nimport { useFieldsetContext } from \"../fieldset\"\nimport { fieldStyle } from \"./field.style\"\n\nexport interface FieldContext\n extends FieldProps, Pick<FieldRootProps, \"replace\"> {\n errorMessageId: string\n focused: boolean\n helperMessageId: string\n id: string\n labelId: string\n onBlur: () => void\n onFocus: () => void\n}\n\nconst [FieldContext, useFieldContext] = createContext<FieldContext>({\n name: \"FieldContext\",\n strict: false,\n})\n\nexport { FieldContext, useFieldContext }\n\nexport interface FieldProps {\n /**\n * If `true`, the field will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * If `true`, the field will be invalid.\n *\n * @default false\n */\n invalid?: boolean\n /**\n * If `true`, the field will be readonly.\n *\n * @default false\n */\n readOnly?: boolean\n /**\n * If `true`, the field will be required.\n *\n * @default false\n */\n required?: boolean\n}\n\nexport interface FieldRootProps\n extends\n HTMLStyledProps,\n ThemeProps<FieldStyle>,\n Pick<FieldLabelProps, \"optionalIndicator\" | \"requiredIndicator\">,\n FieldProps {\n /**\n * The field error message to use.\n */\n errorMessage?: ReactNode\n /**\n * The field helper message to use.\n */\n helperMessage?: ReactNode\n /**\n * The field label to use.\n */\n label?: ReactNode\n /**\n * If `true`, switch between helper message and error message using invalid.\n *\n * @default true\n */\n replace?: boolean\n /**\n * Props the error message component.\n */\n errorMessageProps?: FieldErrorMessageProps\n /**\n * Props the helper message component.\n */\n helperMessageProps?: FieldHelperMessageProps\n /**\n * Props the label component.\n */\n labelProps?: FieldLabelProps\n}\n\nconst {\n PropsContext: FieldPropsContext,\n usePropsContext: useFieldPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<FieldRootProps, FieldStyle>(\"field\", fieldStyle)\n\nexport { FieldPropsContext, useFieldPropsContext }\n\n/**\n * `Field` is a component used to group form elements with label, helper message, error message, etc.\n *\n * @see https://yamada-ui.com/docs/components/field\n */\nexport const FieldRoot = withProvider<\"div\", FieldRootProps>(\n ({\n id,\n children,\n disabled,\n errorMessage,\n helperMessage,\n invalid,\n label,\n optionalIndicator,\n readOnly,\n replace = true,\n required,\n requiredIndicator,\n errorMessageProps,\n helperMessageProps,\n labelProps,\n ...rest\n }) => {\n const uuid = useId()\n const labelId = useId()\n const helperMessageId = useId()\n const errorMessageId = useId()\n const [focused, setFocused] = useState<boolean>(false)\n const [\n omittedChildren,\n customLabel,\n customHelperMessage,\n customErrorMessage,\n ] = useSplitChildren(\n children,\n FieldLabel,\n FieldHelperMessage,\n FieldErrorMessage,\n )\n\n id ??= uuid\n\n const context = useMemo(\n () => ({\n id,\n disabled,\n errorMessageId,\n focused,\n helperMessageId,\n invalid,\n labelId,\n readOnly,\n replace,\n required,\n onBlur: () => setFocused(false),\n onFocus: () => setFocused(true),\n }),\n [\n id,\n disabled,\n labelId,\n focused,\n invalid,\n helperMessageId,\n errorMessageId,\n readOnly,\n replace,\n required,\n ],\n )\n\n return (\n <FieldContext value={context}>\n <styled.div\n data-disabled={dataAttr(disabled)}\n data-focus={dataAttr(focused)}\n data-invalid={dataAttr(invalid)}\n data-readonly={dataAttr(readOnly)}\n {...rest}\n >\n {customLabel ||\n (label ? (\n <FieldLabel\n optionalIndicator={optionalIndicator}\n requiredIndicator={requiredIndicator}\n {...labelProps}\n >\n {label}\n </FieldLabel>\n ) : null)}\n\n {omittedChildren}\n\n {customHelperMessage ||\n (helperMessage ? (\n <FieldHelperMessage {...helperMessageProps}>\n {helperMessage}\n </FieldHelperMessage>\n ) : null)}\n\n {customErrorMessage ||\n (errorMessage ? (\n <FieldErrorMessage {...errorMessageProps}>\n {errorMessage}\n </FieldErrorMessage>\n ) : null)}\n </styled.div>\n </FieldContext>\n )\n },\n \"root\",\n)()\n\nexport interface FieldLabelProps extends HTMLStyledProps<\"label\"> {\n /**\n * The optional indicator to use.\n */\n optionalIndicator?: ReactNode\n /**\n * If `true`, the field will be required.\n *\n * @default false\n */\n required?: boolean\n /**\n * The required indicator to use.\n */\n requiredIndicator?: ReactNode\n}\n\nexport const FieldLabel = withContext<\"label\", FieldLabelProps>(\n ({\n id,\n htmlFor,\n children,\n optionalIndicator = null,\n required,\n requiredIndicator = null,\n ...rest\n }) => {\n const fieldsetContext = useFieldsetContext()\n const fieldContext = useFieldContext()\n\n id ??= fieldContext?.labelId\n htmlFor ??= fieldContext?.id\n required ??= fieldContext?.required ?? fieldsetContext?.required\n\n const disabled = fieldContext?.disabled ?? fieldsetContext?.disabled\n const invalid = fieldContext?.invalid ?? fieldsetContext?.invalid\n const readOnly = fieldContext?.readOnly ?? fieldsetContext?.readOnly\n const focused = fieldContext?.focused\n\n return (\n <styled.label\n id={id}\n htmlFor={htmlFor}\n data-disabled={dataAttr(disabled)}\n data-focus={dataAttr(focused)}\n data-invalid={dataAttr(invalid)}\n data-readonly={dataAttr(readOnly)}\n {...rest}\n >\n {children}\n\n {required ? (\n requiredIndicator ? (\n <FieldRequiredIndicator>{requiredIndicator}</FieldRequiredIndicator>\n ) : (\n <FieldRequiredIndicator />\n )\n ) : (\n optionalIndicator\n )}\n </styled.label>\n )\n },\n \"label\",\n)()\n\ninterface FieldRequiredIndicatorProps extends HTMLStyledProps<\"span\"> {}\n\nconst FieldRequiredIndicator = withContext<\"span\", FieldRequiredIndicatorProps>(\n ({ children, ...rest }) => {\n if (!isValidElement(children)) {\n return (\n <styled.span aria-hidden role=\"presentation\" {...rest}>\n {children ?? <>*</>}\n </styled.span>\n )\n } else {\n return children\n }\n },\n \"requiredIndicator\",\n)()\n\nexport interface FieldHelperMessageProps extends HTMLStyledProps<\"span\"> {}\n\nexport const FieldHelperMessage = withContext<\"span\", FieldHelperMessageProps>(\n (props) => {\n const fieldsetContext = useFieldsetContext()\n const {\n helperMessageId,\n invalid = fieldsetContext?.invalid,\n replace,\n } = useFieldContext() ?? {}\n\n return (\n <styled.span\n id={helperMessageId}\n hidden={replace && invalid ? true : false}\n {...props}\n />\n )\n },\n \"helperMessage\",\n)()\n\nexport interface FieldErrorMessageProps extends HTMLStyledProps<\"span\"> {}\n\nexport const FieldErrorMessage = withContext<\"span\", FieldErrorMessageProps>(\n (props) => {\n const fieldsetContext = useFieldsetContext()\n const { errorMessageId, invalid = fieldsetContext?.invalid } =\n useFieldContext() ?? {}\n\n return (\n <styled.span\n id={errorMessageId}\n aria-live={invalid ? \"polite\" : undefined}\n hidden={!invalid}\n {...props}\n />\n )\n },\n \"errorMessage\",\n)()\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,MAAM,CAAC,cAAc,mBAAmBA,8BAA4B;CAClE,MAAM;CACN,QAAQ;CACT,CAAC;AAqEF,MAAM,EACJ,cAAc,mBACd,iBAAiB,sBACjB,aACA,iBACEC,6CAAgD,SAASC,+BAAW;;;;;;AASxE,MAAa,YAAY,cACtB,EACC,IACA,UACA,UACA,cACA,eACA,SACA,OACA,mBACA,UACA,UAAU,MACV,UACA,mBACA,mBACA,oBACA,YACA,GAAG,WACC;CACJ,MAAM,yBAAc;CACpB,MAAM,4BAAiB;CACvB,MAAM,oCAAyB;CAC/B,MAAM,mCAAwB;CAC9B,MAAM,CAAC,SAAS,kCAAgC,MAAM;CACtD,MAAM,CACJ,iBACA,aACA,qBACA,sBACEC,kCACF,UACA,YACA,oBACA,kBACD;AAED,QAAO;AA+BP,QACE,2CAAC;EAAa,iCA7BP;GACL;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,cAAc,WAAW,MAAM;GAC/B,eAAe,WAAW,KAAK;GAChC,GACD;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CACF;YAIG,4CAACC,uBAAO;GACN,iEAAwB,SAAS;GACjC,8DAAqB,QAAQ;GAC7B,gEAAuB,QAAQ;GAC/B,iEAAwB,SAAS;GACjC,GAAI;;IAEH,gBACE,QACC,2CAAC;KACoB;KACA;KACnB,GAA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ACT,MAAM,kBAAkBC,qCAAoB;CAC5C,MAAM,EAAE,gBAAgB,UAAU,iBAAiB,YACjD,iBAAiB,IAAI,EAAE;AAEzB,QACE,2CAACD,uBAAO;EACN,IAAI;EACJ,aAAW,UAAU,WAAW;EAChC,QAAQ,CAAC;EACT,GAAI;GACJ;GAGN,eACD,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"file-input.cjs","names":["defaultFormat: (value: File, index: number) => string","createSlotComponent","fileInputStyle","useInputBorder","useFileInput","styled","Portal","useInputPropsContext"],"sources":["../../../../src/components/file-input/file-input.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactNode } from \"react\"\nimport type { HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport type { UseInputBorderProps } from \"../input\"\nimport type { FileInputStyle } from \"./file-input.style\"\nimport type { UseFileInputProps } from \"./use-file-input\"\nimport { cloneElement, isValidElement, useMemo } from \"react\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { useInputBorder, useInputPropsContext } from \"../input\"\nimport { Portal } from \"../portal\"\nimport { fileInputStyle } from \"./file-input.style\"\nimport { useFileInput } from \"./use-file-input\"\n\nconst defaultFormat: (value: File, index: number) => string = ({ name }) => name\n\nexport interface FileInputProps\n extends\n Omit<\n HTMLStyledProps<\"input\">,\n \"children\" | \"defaultValue\" | \"onChange\" | \"value\"\n >,\n ThemeProps<FileInputStyle>,\n UseInputBorderProps,\n FieldProps,\n Omit<UseFileInputProps, \"children\"> {\n /**\n * A callback that returns a React node.\n */\n children?: (files: File[] | undefined) => ReactNode\n /**\n * The component that displays uploaded files.\n */\n component?: (props: { index: number; value: File }) => ReactNode\n /**\n * A callback that formats the name of the uploaded file.\n */\n format?: (value: File, index: number) => string\n /**\n * The string to separate uploaded files.\n *\n * @default ','\n */\n separator?: string\n}\n\nconst {\n PropsContext: FileInputPropsContext,\n usePropsContext: useFileInputPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<FileInputProps, FileInputStyle>(\n \"file-input\",\n fileInputStyle,\n)\n\nexport { FileInputPropsContext, useFileInputPropsContext }\n\n/**\n * `FileInput` is a component used for users to select files.\n *\n * @see https://yamada-ui.com/docs/components/file-input\n */\nexport const FileInput = withProvider<\"input\", FileInputProps>(\n ({\n children,\n component,\n errorBorderColor,\n focusBorderColor,\n format = defaultFormat,\n placeholder,\n separator = \",\",\n ...props\n }) => {\n const varProps = useInputBorder({ errorBorderColor, focusBorderColor })\n const { values, getFieldProps, getInputProps } = useFileInput(props)\n\n const cloneChildren = useMemo(() => {\n if (!values?.length)\n return (\n <styled.span overflow=\"hidden\" whiteSpace=\"nowrap\">\n {placeholder}\n </styled.span>\n )\n\n if (children) return children(values)\n\n return values.map((value, index) => {\n const last = values.length === index + 1\n\n if (component) {\n const node = component({ index, value })\n\n if (isValidElement(node)) {\n return cloneElement(node, { key: index })\n } else {\n return node\n }\n } else {\n return (\n <FileInputTag key={index}>\n {format(value, index)}\n {!last ? separator : null}\n </FileInputTag>\n )\n }\n })\n }, [children, format, placeholder, separator, component, values])\n\n return (\n <>\n <Portal>\n <styled.input {...getInputProps()} />\n </Portal>\n\n <styled.div {...varProps} {...getFieldProps()}>\n {cloneChildren}\n </styled.div>\n </>\n )\n },\n \"root\",\n)((props) => {\n const context = useInputPropsContext()\n\n return { ...context, ...props }\n})\n\ninterface FileInputTagProps extends HTMLStyledProps {}\n\nconst FileInputTag = withContext<\"span\", FileInputTagProps>(\"span\", \"tag\")()\n"],"mappings":";;;;;;;;;;;;;;;;;AAeA,MAAMA,iBAAyD,EAAE,WAAW;AAgC5E,MAAM,EACJ,cAAc,uBACd,iBAAiB,0BACjB,aACA,iBACEC,6CACF,cACAC,wCACD;;;;;;AASD,MAAa,YAAY,cACtB,EACC,UACA,WACA,kBACA,kBACA,SAAS,eACT,aACA,YAAY,KACZ,GAAG,YACC;CACJ,MAAM,WAAWC,wCAAe;EAAE;EAAkB;EAAkB,CAAC;CACvE,MAAM,EAAE,QAAQ,eAAe,kBAAkBC,oCAAa,MAAM;CAEpE,MAAM,yCAA8B;AAClC,MAAI,CAAC,QAAQ,OACX,QACE,2CAACC,uBAAO;GAAK,UAAS;GAAS,YAAW;aACvC;IACW;AAGlB,MAAI,SAAU,QAAO,SAAS,OAAO;AAErC,SAAO,OAAO,KAAK,OAAO,UAAU;GAClC,MAAM,OAAO,OAAO,WAAW,QAAQ;AAEvC,OAAI,WAAW;IACb,MAAM,OAAO,UAAU;KAAE;KAAO;KAAO,CAAC;AAExC,kCAAmB,KAAK,CACtB,gCAAoB,MAAM,EAAE,KAAK,OAAO,CAAC;QAEzC,QAAO;SAGT,QACE,4CAAC,2BACE,OAAO,OAAO,MAAM,EACpB,CAAC,OAAO,YAAY,SAFJ,MAGJ;IAGnB;IACD;EAAC;EAAU;EAAQ;EAAa;EAAW;EAAW;EAAO,CAAC;AAEjE,QACE,qFACE,2CAACC,mCACC,2CAACD,uBAAO,SAAM,GAAI,eAAe,GAAI,GAC9B,EAET,2CAACA,uBAAO;EAAI,GAAI;EAAU,GAAI,eAAe;YAC1C;GACU,IACZ;GAGP,OACD,EAAE,UAAU;AAGX,QAAO;EAAE,GAFOE,oCAAsB;EAEjB,GAAG;EAAO;EAC/B;AAIF,MAAM,eAAe,YAAuC,QAAQ,MAAM,EAAE"}
1
+ {"version":3,"file":"file-input.cjs","names":["defaultFormat: (value: File, index: number) => string","createSlotComponent","fileInputStyle","useInputBorder","useFileInput","styled","Portal","useInputPropsContext"],"sources":["../../../../src/components/file-input/file-input.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactNode } from \"react\"\nimport type { HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport type { UseInputBorderProps } from \"../input\"\nimport type { FileInputStyle } from \"./file-input.style\"\nimport type { UseFileInputProps } from \"./use-file-input\"\nimport { cloneElement, isValidElement, useMemo } from \"react\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { useInputBorder, useInputPropsContext } from \"../input\"\nimport { Portal } from \"../portal\"\nimport { fileInputStyle } from \"./file-input.style\"\nimport { useFileInput } from \"./use-file-input\"\n\nconst defaultFormat: (value: File, index: number) => string = ({ name }) => name\n\nexport interface FileInputProps\n extends\n Omit<\n HTMLStyledProps<\"input\">,\n \"children\" | \"defaultValue\" | \"onChange\" | \"value\"\n >,\n ThemeProps<FileInputStyle>,\n UseInputBorderProps,\n FieldProps,\n Omit<UseFileInputProps, \"children\"> {\n /**\n * The string to separate uploaded files.\n *\n * @default ','\n */\n separator?: string\n /**\n * A callback that returns a React node.\n */\n children?: (files: File[] | undefined) => ReactNode\n /**\n * The component that displays uploaded files.\n */\n component?: (props: { index: number; value: File }) => ReactNode\n /**\n * A callback that formats the name of the uploaded file.\n */\n format?: (value: File, index: number) => string\n}\n\nconst {\n PropsContext: FileInputPropsContext,\n usePropsContext: useFileInputPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<FileInputProps, FileInputStyle>(\n \"file-input\",\n fileInputStyle,\n)\n\nexport { FileInputPropsContext, useFileInputPropsContext }\n\n/**\n * `FileInput` is a component used for users to select files.\n *\n * @see https://yamada-ui.com/docs/components/file-input\n */\nexport const FileInput = withProvider<\"input\", FileInputProps>(\n ({\n children,\n component,\n errorBorderColor,\n focusBorderColor,\n format = defaultFormat,\n placeholder,\n separator = \",\",\n ...props\n }) => {\n const varProps = useInputBorder({ errorBorderColor, focusBorderColor })\n const { values, getFieldProps, getInputProps } = useFileInput(props)\n\n const cloneChildren = useMemo(() => {\n if (!values?.length)\n return (\n <styled.span overflow=\"hidden\" whiteSpace=\"nowrap\">\n {placeholder}\n </styled.span>\n )\n\n if (children) return children(values)\n\n return values.map((value, index) => {\n const last = values.length === index + 1\n\n if (component) {\n const node = component({ index, value })\n\n if (isValidElement(node)) {\n return cloneElement(node, { key: index })\n } else {\n return node\n }\n } else {\n return (\n <FileInputTag key={index}>\n {format(value, index)}\n {!last ? separator : null}\n </FileInputTag>\n )\n }\n })\n }, [children, format, placeholder, separator, component, values])\n\n return (\n <>\n <Portal>\n <styled.input {...getInputProps()} />\n </Portal>\n\n <styled.div {...varProps} {...getFieldProps()}>\n {cloneChildren}\n </styled.div>\n </>\n )\n },\n \"root\",\n)((props) => {\n const context = useInputPropsContext()\n\n return { ...context, ...props }\n})\n\ninterface FileInputTagProps extends HTMLStyledProps {}\n\nconst FileInputTag = withContext<\"span\", FileInputTagProps>(\"span\", \"tag\")()\n"],"mappings":";;;;;;;;;;;;;;;;;AAeA,MAAMA,iBAAyD,EAAE,WAAW;AAgC5E,MAAM,EACJ,cAAc,uBACd,iBAAiB,0BACjB,aACA,iBACEC,6CACF,cACAC,wCACD;;;;;;AASD,MAAa,YAAY,cACtB,EACC,UACA,WACA,kBACA,kBACA,SAAS,eACT,aACA,YAAY,KACZ,GAAG,YACC;CACJ,MAAM,WAAWC,wCAAe;EAAE;EAAkB;EAAkB,CAAC;CACvE,MAAM,EAAE,QAAQ,eAAe,kBAAkBC,oCAAa,MAAM;CAEpE,MAAM,yCAA8B;AAClC,MAAI,CAAC,QAAQ,OACX,QACE,2CAACC,uBAAO;GAAK,UAAS;GAAS,YAAW;aACvC;IACW;AAGlB,MAAI,SAAU,QAAO,SAAS,OAAO;AAErC,SAAO,OAAO,KAAK,OAAO,UAAU;GAClC,MAAM,OAAO,OAAO,WAAW,QAAQ;AAEvC,OAAI,WAAW;IACb,MAAM,OAAO,UAAU;KAAE;KAAO;KAAO,CAAC;AAExC,kCAAmB,KAAK,CACtB,gCAAoB,MAAM,EAAE,KAAK,OAAO,CAAC;QAEzC,QAAO;SAGT,QACE,4CAAC,2BACE,OAAO,OAAO,MAAM,EACpB,CAAC,OAAO,YAAY,SAFJ,MAGJ;IAGnB;IACD;EAAC;EAAU;EAAQ;EAAa;EAAW;EAAW;EAAO,CAAC;AAEjE,QACE,qFACE,2CAACC,mCACC,2CAACD,uBAAO,SAAM,GAAI,eAAe,GAAI,GAC9B,EAET,2CAACA,uBAAO;EAAI,GAAI;EAAU,GAAI,eAAe;YAC1C;GACU,IACZ;GAGP,OACD,EAAE,UAAU;AAGX,QAAO;EAAE,GAFOE,oCAAsB;EAEjB,GAAG;EAAO;EAC/B;AAIF,MAAM,eAAe,YAAuC,QAAQ,MAAM,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"flip.cjs","names":["flipVariants: Variants","createSlotComponent","flipStyle","useControllableState","from","to","motion"],"sources":["../../../../src/components/flip/flip.tsx"],"sourcesContent":["\"use client\"\n\nimport type { Variants } from \"motion/react\"\nimport type { ReactNode } from \"react\"\nimport type { KeyframeIdent, Orientation, ThemeProps } from \"../../core\"\nimport type { HTMLMotionProps } from \"../motion\"\nimport type { FlipStyle } from \"./flip.style\"\nimport { useMemo, useRef, useState } from \"react\"\nimport { createSlotComponent } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { dataAttr, handlerAll, useSafeLayoutEffect } from \"../../utils\"\nimport { motion } from \"../motion\"\nimport { flipStyle } from \"./flip.style\"\n\nconst flipVariants: Variants = {\n enter: ({ ident, orientation, visible }) => ({\n [orientation === \"horizontal\" ? \"rotateY\" : \"rotateX\"]:\n ident === \"from\" ? (visible ? 180 : 0) : visible ? 0 : 180,\n }),\n exit: ({ ident, orientation }) => ({\n [orientation === \"horizontal\" ? \"rotateY\" : \"rotateX\"]:\n ident === \"from\" ? 0 : 180,\n }),\n}\n\ninterface Rect {\n height?: number\n width?: number\n}\n\nexport interface FlipProps\n extends Omit<HTMLMotionProps<\"button\">, \"onChange\">, ThemeProps<FlipStyle> {\n /**\n * You can set the initial state.\n *\n * @default 'from'\n */\n defaultValue?: KeyframeIdent\n /**\n * The animation delay.\n *\n * @default 0\n */\n delay?: number\n /**\n * If `true`, the component is disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * The animation duration.\n *\n * @default 0.4\n */\n duration?: number\n /**\n * Passing React elements to \"from\" is required.\n */\n from: ReactNode\n /**\n * The orientation of the flip effect. Determines whether the flip occurs horizontally or vertically.\n *\n * @default 'horizontal'\n */\n orientation?: Orientation\n /**\n * If `true`, the component is readonly.\n *\n * @default false\n */\n readOnly?: boolean\n /**\n * Passing React elements to \"to\" is required.\n */\n to: ReactNode\n /**\n * Use this when you want to control the animation from outside the component.\n */\n value?: KeyframeIdent\n /**\n * This is a callback function that is called when the animation state changes.\n */\n onChange?: (value: KeyframeIdent) => void\n}\n\nconst {\n PropsContext: FlipPropsContext,\n usePropsContext: useFlipPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<FlipProps, FlipStyle>(\"flip\", flipStyle)\n\nexport { FlipPropsContext, useFlipPropsContext }\n\n/**\n * `Flip` is an animation component that alternates between flipping two elements.\n *\n * @see https://yamada-ui.com/docs/components/flip\n */\nexport const Flip = withProvider(\n ({\n defaultValue = \"from\",\n delay = 0,\n disabled,\n duration = 0.4,\n from,\n orientation = \"horizontal\",\n readOnly,\n to,\n transition = {},\n value: valueProp,\n onChange,\n onClick: onClickProp,\n ...rest\n }) => {\n const [{ height, width }, setRect] = useState<Rect>({})\n const fromRef = useRef<HTMLDivElement | null>(null)\n const toRef = useRef<HTMLDivElement | null>(null)\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange,\n })\n const visible = value === \"to\"\n\n const style = useMemo(\n () => ({\n height: height ? `${height}px` : \"auto\",\n width: width ? `${width}px` : \"auto\",\n }),\n [width, height],\n )\n\n const onClick = () => {\n if (readOnly) return\n\n setValue((prev) => (prev === \"from\" ? \"to\" : \"from\"))\n }\n\n useSafeLayoutEffect(() => {\n const from = fromRef.current\n const to = toRef.current\n\n if (!from || !to) return\n\n if (\n from.offsetWidth !== to.offsetWidth ||\n from.offsetHeight !== to.offsetHeight\n ) {\n console.warn(\n `Flip: \"from\" element (width: ${from.offsetWidth}px, height: ${from.offsetHeight}px) does not match \"to\" element (width: ${to.offsetWidth}px, height: ${to.offsetHeight}px). Please ensure both elements have the same dimensions.`,\n )\n }\n\n setRect({ height: from.offsetHeight, width: from.offsetWidth })\n }, [fromRef, toRef])\n\n return (\n <motion.button\n type=\"button\"\n style={style}\n data-disabled={dataAttr(disabled)}\n data-orientation={orientation}\n data-readonly={dataAttr(readOnly)}\n data-value={value}\n disabled={disabled}\n onClick={handlerAll(onClickProp, onClick)}\n {...rest}\n >\n <FlipFrom\n ref={fromRef}\n custom={{ orientation, visible }}\n transition={{ delay, duration, ...transition }}\n >\n {from}\n </FlipFrom>\n\n <FlipTo\n ref={toRef}\n custom={{ orientation, visible }}\n transition={{ delay, duration, ...transition }}\n >\n {to}\n </FlipTo>\n </motion.button>\n )\n },\n \"root\",\n)()\n\ninterface FlipFromProps extends HTMLMotionProps<\"span\"> {}\n\nconst FlipFrom = withContext<\"span\", FlipFromProps>(\n ({ custom, ...rest }) => {\n return (\n <motion.span\n animate=\"enter\"\n custom={{ ident: \"from\", ...custom }}\n initial=\"exit\"\n variants={flipVariants}\n {...rest}\n />\n )\n },\n [\"item\", \"from\"],\n)()\n\ninterface FlipToProps extends HTMLMotionProps<\"span\"> {}\n\nconst FlipTo = withContext<\"span\", FlipToProps>(\n ({ custom, ...rest }) => {\n return (\n <motion.span\n animate=\"enter\"\n custom={{ ident: \"to\", ...custom }}\n initial=\"exit\"\n variants={flipVariants}\n {...rest}\n />\n )\n },\n [\"item\", \"to\"],\n)()\n"],"mappings":";;;;;;;;;;;;;;;AAcA,MAAMA,eAAyB;CAC7B,QAAQ,EAAE,OAAO,aAAa,eAAe,GAC1C,gBAAgB,eAAe,YAAY,YAC1C,UAAU,SAAU,UAAU,MAAM,IAAK,UAAU,IAAI,KAC1D;CACD,OAAO,EAAE,OAAO,mBAAmB,GAChC,gBAAgB,eAAe,YAAY,YAC1C,UAAU,SAAS,IAAI,KAC1B;CACF;AA+DD,MAAM,EACJ,cAAc,kBACd,iBAAiB,qBACjB,aACA,iBACEC,6CAA0C,QAAQC,6BAAU;;;;;;AAShE,MAAa,OAAO,cACjB,EACC,eAAe,QACf,QAAQ,GACR,UACA,WAAW,IACX,MACA,cAAc,cACd,UACA,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D,EAAE;AAIH,MAAM,WAAW,aACd,EAAE,QAAQ,GAAG,WAAW;AACvB,QACE,2CAACA,uBAAO;EACN,SAAQ;EACR,QAAQ;GAAE,OAAO;GAAQ,GAAG;GAAQ;EACpC,SAAQ;EACR,UAAU;EACV,GAAI;GACJ;GAGN,CAAC,QAAQ,OAAO,CACjB,EAAE;AAIH,MAAM,SAAS,aACZ,EAAE,QAAQ,GAAG,WAAW;AACvB,QACE,2CAACA,uBAAO;EACN,SAAQ;EACR,QAAQ;GAAE,OAAO;GAAM,GAAG;GAAQ;EAClC,SAAQ;EACR,UAAU;EACV,GAAI;GACJ;GAGN,CAAC,QAAQ,KAAK,CACf,EAAE"}
1
+ {"version":3,"file":"flip.cjs","names":["flipVariants: Variants","createSlotComponent","flipStyle","useControllableState","from","to","motion"],"sources":["../../../../src/components/flip/flip.tsx"],"sourcesContent":["\"use client\"\n\nimport type { Variants } from \"motion/react\"\nimport type { ReactNode } from \"react\"\nimport type { KeyframeIdent, Orientation, ThemeProps } from \"../../core\"\nimport type { HTMLMotionProps } from \"../motion\"\nimport type { FlipStyle } from \"./flip.style\"\nimport { useMemo, useRef, useState } from \"react\"\nimport { createSlotComponent } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { dataAttr, handlerAll, useSafeLayoutEffect } from \"../../utils\"\nimport { motion } from \"../motion\"\nimport { flipStyle } from \"./flip.style\"\n\nconst flipVariants: Variants = {\n enter: ({ ident, orientation, visible }) => ({\n [orientation === \"horizontal\" ? \"rotateY\" : \"rotateX\"]:\n ident === \"from\" ? (visible ? 180 : 0) : visible ? 0 : 180,\n }),\n exit: ({ ident, orientation }) => ({\n [orientation === \"horizontal\" ? \"rotateY\" : \"rotateX\"]:\n ident === \"from\" ? 0 : 180,\n }),\n}\n\ninterface Rect {\n height?: number\n width?: number\n}\n\nexport interface FlipProps\n extends Omit<HTMLMotionProps<\"button\">, \"onChange\">, ThemeProps<FlipStyle> {\n /**\n * Passing React elements to \"from\" is required.\n */\n from: ReactNode\n /**\n * Passing React elements to \"to\" is required.\n */\n to: ReactNode\n /**\n * You can set the initial state.\n *\n * @default 'from'\n */\n defaultValue?: KeyframeIdent\n /**\n * The animation delay.\n *\n * @default 0\n */\n delay?: number\n /**\n * If `true`, the component is disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * The animation duration.\n *\n * @default 0.4\n */\n duration?: number\n /**\n * The orientation of the flip effect. Determines whether the flip occurs horizontally or vertically.\n *\n * @default 'horizontal'\n */\n orientation?: Orientation\n /**\n * If `true`, the component is readonly.\n *\n * @default false\n */\n readOnly?: boolean\n /**\n * Use this when you want to control the animation from outside the component.\n */\n value?: KeyframeIdent\n /**\n * This is a callback function that is called when the animation state changes.\n */\n onChange?: (value: KeyframeIdent) => void\n}\n\nconst {\n PropsContext: FlipPropsContext,\n usePropsContext: useFlipPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<FlipProps, FlipStyle>(\"flip\", flipStyle)\n\nexport { FlipPropsContext, useFlipPropsContext }\n\n/**\n * `Flip` is an animation component that alternates between flipping two elements.\n *\n * @see https://yamada-ui.com/docs/components/flip\n */\nexport const Flip = withProvider(\n ({\n defaultValue = \"from\",\n delay = 0,\n disabled,\n duration = 0.4,\n from,\n orientation = \"horizontal\",\n readOnly,\n to,\n transition = {},\n value: valueProp,\n onChange,\n onClick: onClickProp,\n ...rest\n }) => {\n const [{ height, width }, setRect] = useState<Rect>({})\n const fromRef = useRef<HTMLDivElement | null>(null)\n const toRef = useRef<HTMLDivElement | null>(null)\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange,\n })\n const visible = value === \"to\"\n\n const style = useMemo(\n () => ({\n height: height ? `${height}px` : \"auto\",\n width: width ? `${width}px` : \"auto\",\n }),\n [width, height],\n )\n\n const onClick = () => {\n if (readOnly) return\n\n setValue((prev) => (prev === \"from\" ? \"to\" : \"from\"))\n }\n\n useSafeLayoutEffect(() => {\n const from = fromRef.current\n const to = toRef.current\n\n if (!from || !to) return\n\n if (\n from.offsetWidth !== to.offsetWidth ||\n from.offsetHeight !== to.offsetHeight\n ) {\n console.warn(\n `Flip: \"from\" element (width: ${from.offsetWidth}px, height: ${from.offsetHeight}px) does not match \"to\" element (width: ${to.offsetWidth}px, height: ${to.offsetHeight}px). Please ensure both elements have the same dimensions.`,\n )\n }\n\n setRect({ height: from.offsetHeight, width: from.offsetWidth })\n }, [fromRef, toRef])\n\n return (\n <motion.button\n type=\"button\"\n style={style}\n data-disabled={dataAttr(disabled)}\n data-orientation={orientation}\n data-readonly={dataAttr(readOnly)}\n data-value={value}\n disabled={disabled}\n onClick={handlerAll(onClickProp, onClick)}\n {...rest}\n >\n <FlipFrom\n ref={fromRef}\n custom={{ orientation, visible }}\n transition={{ delay, duration, ...transition }}\n >\n {from}\n </FlipFrom>\n\n <FlipTo\n ref={toRef}\n custom={{ orientation, visible }}\n transition={{ delay, duration, ...transition }}\n >\n {to}\n </FlipTo>\n </motion.button>\n )\n },\n \"root\",\n)()\n\ninterface FlipFromProps extends HTMLMotionProps<\"span\"> {}\n\nconst FlipFrom = withContext<\"span\", FlipFromProps>(\n ({ custom, ...rest }) => {\n return (\n <motion.span\n animate=\"enter\"\n custom={{ ident: \"from\", ...custom }}\n initial=\"exit\"\n variants={flipVariants}\n {...rest}\n />\n )\n },\n [\"item\", \"from\"],\n)()\n\ninterface FlipToProps extends HTMLMotionProps<\"span\"> {}\n\nconst FlipTo = withContext<\"span\", FlipToProps>(\n ({ custom, ...rest }) => {\n return (\n <motion.span\n animate=\"enter\"\n custom={{ ident: \"to\", ...custom }}\n initial=\"exit\"\n variants={flipVariants}\n {...rest}\n />\n )\n },\n [\"item\", \"to\"],\n)()\n"],"mappings":";;;;;;;;;;;;;;;AAcA,MAAMA,eAAyB;CAC7B,QAAQ,EAAE,OAAO,aAAa,eAAe,GAC1C,gBAAgB,eAAe,YAAY,YAC1C,UAAU,SAAU,UAAU,MAAM,IAAK,UAAU,IAAI,KAC1D;CACD,OA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AoB,aAAa,QAAQ;EACzC,GAAI;aAEJ,2CAAC;GACC,KAAK;GACL,QAAQ;IAAE;IAAa;IAAS;GAChC,YAAY;IAAE;IAAO;IAAU,GAAG;IAAY;aAE7C;IACQ,EAEX,2CAAC;GACC,KAAK;GACL,QAAQ;IAAE;IAAa;IAAS;GAChC,YAAY;IAAE;IAAO;IAAU,GAAG;IAAY;aAE7C;IACM;GACK;GAGpB,OACD,EAAE;AAIH,MAAM,WAAW,aACd,EAAE,QAAQ,GAAG,WAAW;AACvB,QACE,2CAACA,uBAAO;EACN,SAAQ;EACR,QAAQ;GAAE,OAAO;GAAQ,GAAG;GAAQ;EACpC,SAAQ;EACR,UAAU;EACV,GAAI;GACJ;GAGN,CAAC,QAAQ,OAAO,CACjB,EAAE;AAIH,MAAM,SAAS,aACZ,EAAE,QAAQ,GAAG,WAAW;AACvB,QACE,2CAACA,uBAAO;EACN,SAAQ;EACR,QAAQ;GAAE,OAAO;GAAM,GAAG;GAAQ;EAClC,SAAQ;EACR,UAAU;EACV,GAAI;GACJ;GAGN,CAAC,QAAQ,KAAK,CACf,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"for.cjs","names":[],"sources":["../../../../src/components/for/for.tsx"],"sourcesContent":["import type { ReactNode } from \"react\"\nimport { isArray } from \"../../utils\"\n\nexport interface ForProps<Y> {\n /**\n * The render function to render each item in the array.\n */\n children: (value: Y, index: number, array: Y[]) => ReactNode\n /**\n * The array to iterate over.\n */\n each: readonly Y[] | undefined | Y[]\n /**\n * The fallback content to render when the array is empty.\n */\n fallback?: ReactNode\n /**\n * A function that returns a boolean indicating whether the item should be included in the render result.\n */\n filter?: (value: Y, index: number, array: Y[]) => boolean\n /**\n * The maximum number of items to include in the render result.\n */\n limit?: number\n /**\n * The number of items to skip before including them in the render result.\n * @default 0\n */\n offset?: number\n /**\n * The boolean value to determine the order of the items in the array.\n * If `true`, the items will be reversed.\n * If `sortBy` is provided, inversion is applied to the sorted array.\n * @default false\n */\n reverse?: boolean\n /**\n * The function to sort the items in the array.\n * If function is provided, the items will be sorted based on the return value.\n * If `reverse` is `true`, the inversion is applied to the sorted array.\n */\n sort?: (a: Y, b: Y) => number\n}\n\n/**\n * `For` is a component used to loop over an array and render a component for each item.\n *\n * @see https://yamada-ui.com/docs/components/for\n */\nexport const For = <Y,>({\n children,\n each,\n fallback,\n filter,\n limit,\n offset = 0,\n reverse = false,\n sort,\n}: ForProps<Y>): ReactNode => {\n if (!each || !isArray(each) || !each.length) return fallback || null\n\n const cloned = [...each]\n const filtered = filter ? cloned.filter(filter) : cloned\n const sorted = sort ? filtered.sort(sort) : filtered\n const reversed = reverse ? sorted.reverse() : sorted\n const sliced = reversed.slice(offset, limit ? offset + limit : undefined)\n\n if (!sliced.length) return fallback || null\n\n return sliced.map(children)\n}\n"],"mappings":";;;;;;;;AAiDA,MAAa,OAAW,EACtB,UACA,MACA,UACA,QACA,OACA,SAAS,GACT,UAAU,OACV,WAC4B;AAC5B,KAAI,CAAC,QAAQ,gDAAS,KAAK,IAAI,CAAC,KAAK,OAAQ,QAAO,YAAY;CAEhE,MAAM,SAAS,CAAC,GAAG,KAAK;CACxB,MAAM,WAAW,SAAS,OAAO,OAAO,OAAO,GAAG;CAClD,MAAM,SAAS,OAAO,SAAS,KAAK,KAAK,GAAG;CAE5C,MAAM,UADW,UAAU,OAAO,SAAS,GAAG,QACtB,MAAM,QAAQ,QAAQ,SAAS,QAAQ,OAAU;AAEzE,KAAI,CAAC,OAAO,OAAQ,QAAO,YAAY;AAEvC,QAAO,OAAO,IAAI,SAAS"}
1
+ {"version":3,"file":"for.cjs","names":[],"sources":["../../../../src/components/for/for.tsx"],"sourcesContent":["import type { ReactNode } from \"react\"\nimport { isArray } from \"../../utils\"\n\nexport interface ForProps<Y> {\n /**\n * The array to iterate over.\n */\n each: readonly Y[] | undefined | Y[]\n /**\n * The render function to render each item in the array.\n */\n children: (value: Y, index: number, array: Y[]) => ReactNode\n /**\n * The fallback content to render when the array is empty.\n */\n fallback?: ReactNode\n /**\n * The maximum number of items to include in the render result.\n */\n limit?: number\n /**\n * The number of items to skip before including them in the render result.\n * @default 0\n */\n offset?: number\n /**\n * The boolean value to determine the order of the items in the array.\n * If `true`, the items will be reversed.\n * If `sortBy` is provided, inversion is applied to the sorted array.\n * @default false\n */\n reverse?: boolean\n /**\n * A function that returns a boolean indicating whether the item should be included in the render result.\n */\n filter?: (value: Y, index: number, array: Y[]) => boolean\n /**\n * The function to sort the items in the array.\n * If function is provided, the items will be sorted based on the return value.\n * If `reverse` is `true`, the inversion is applied to the sorted array.\n */\n sort?: (a: Y, b: Y) => number\n}\n\n/**\n * `For` is a component used to loop over an array and render a component for each item.\n *\n * @see https://yamada-ui.com/docs/components/for\n */\nexport const For = <Y,>({\n children,\n each,\n fallback,\n filter,\n limit,\n offset = 0,\n reverse = false,\n sort,\n}: ForProps<Y>): ReactNode => {\n if (!each || !isArray(each) || !each.length) return fallback || null\n\n const cloned = [...each]\n const filtered = filter ? cloned.filter(filter) : cloned\n const sorted = sort ? filtered.sort(sort) : filtered\n const reversed = reverse ? sorted.reverse() : sorted\n const sliced = reversed.slice(offset, limit ? offset + limit : undefined)\n\n if (!sliced.length) return fallback || null\n\n return sliced.map(children)\n}\n"],"mappings":";;;;;;;;AAiDA,MAAa,OAAW,EACtB,UACA,MACA,UACA,QACA,OACA,SAAS,GACT,UAAU,OACV,WAC4B;AAC5B,KAAI,CAAC,QAAQ,gDAAS,KAAK,IAAI,CAAC,KAAK,OAAQ,QAAO,YAAY;CAEhE,MAAM,SAAS,CAAC,GAAG,KAAK;CACxB,MAAM,WAAW,SAAS,OAAO,OAAO,OAAO,GAAG;CAClD,MAAM,SAAS,OAAO,SAAS,KAAK,KAAK,GAAG;CAE5C,MAAM,UADW,UAAU,OAAO,SAAS,GAAG,QACtB,MAAM,QAAQ,QAAQ,SAAS,QAAQ,OAAU;AAEzE,KAAI,CAAC,OAAO,OAAQ,QAAO,YAAY;AAEvC,QAAO,OAAO,IAAI,SAAS"}
@@ -1 +1 @@
1
- {"version":3,"file":"highlight.cjs","names":["Highlight: FC<HighlightProps>","useHighlight","Mark","text","Fragment","Text"],"sources":["../../../../src/components/highlight/highlight.tsx"],"sourcesContent":["import type { FC } from \"react\"\nimport type { MarkProps } from \"../mark\"\nimport type { TextProps } from \"../text\"\nimport { Fragment } from \"react\"\nimport { Mark } from \"../mark\"\nimport { Text } from \"../text\"\nimport { useHighlight } from \"./use-highlight\"\n\nexport interface HighlightProps extends Omit<TextProps, \"children\"> {\n /**\n * The text used for searching.\n */\n children: string\n /**\n * If `true`, `Fragment` is used for rendering.\n *\n * @default false\n */\n fragment?: boolean\n /**\n * Can be a single string or an array of strings. These are the terms that are highlighted in the text.\n */\n query: string | string[]\n /**\n * Properties passed to the Mark component which is used to highlight the matched terms.\n */\n markProps?: MarkProps\n}\n\n/**\n * `Highlight` is a component that highlights specified strings within text. By default, it renders a `p` element.\n *\n * @see https://yamada-ui.com/docs/components/highlight\n */\nexport const Highlight: FC<HighlightProps> = ({\n children: text,\n fragment = false,\n query,\n markProps,\n ...rest\n}) => {\n const chunks = useHighlight({ query, text })\n const { colorScheme } = rest\n\n if (fragment) {\n return (\n <>\n {chunks.map(({ match, text }, index) =>\n match ? (\n <Mark key={index} colorScheme={colorScheme} {...markProps}>\n {text}\n </Mark>\n ) : (\n <Fragment key={index}>{text}</Fragment>\n ),\n )}\n </>\n )\n } else {\n return (\n <Text {...rest}>\n {chunks.map(({ match, text }, index) =>\n match ? (\n <Mark key={index} colorScheme={colorScheme} {...markProps}>\n {text}\n </Mark>\n ) : (\n <Fragment key={index}>{text}</Fragment>\n ),\n )}\n </Text>\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkCA,MAAaA,aAAiC,EAC5C,UAAU,MACV,WAAW,OACX,OACA,WACA,GAAG,WACC;CACJ,MAAM,SAASC,mCAAa;EAAE;EAAO;EAAM,CAAC;CAC5C,MAAM,EAAE,gBAAgB;AAExB,KAAI,SACF,QACE,mFACG,OAAO,KAAK,EAAE,OAAO,gBAAQ,UAC5B,QACE,2CAACC;EAA8B;EAAa,GAAI;YAC7CC;IADQ,MAEJ,GAEP,2CAACC,4BAAsBD,UAAR,MAAwB,CAE1C,GACA;KAGL,QACE,2CAACE;EAAK,GAAI;YACP,OAAO,KAAK,EAAE,OAAO,gBAAQ,UAC5B,QACE,2CAACH;GAA8B;GAAa,GAAI;aAC7CC;KADQ,MAEJ,GAEP,2CAACC,4BAAsBD,UAAR,MAAwB,CAE1C;GACI"}
1
+ {"version":3,"file":"highlight.cjs","names":["Highlight: FC<HighlightProps>","useHighlight","Mark","text","Fragment","Text"],"sources":["../../../../src/components/highlight/highlight.tsx"],"sourcesContent":["import type { FC } from \"react\"\nimport type { MarkProps } from \"../mark\"\nimport type { TextProps } from \"../text\"\nimport { Fragment } from \"react\"\nimport { Mark } from \"../mark\"\nimport { Text } from \"../text\"\nimport { useHighlight } from \"./use-highlight\"\n\nexport interface HighlightProps extends Omit<TextProps, \"children\"> {\n /**\n * The text used for searching.\n */\n children: string\n /**\n * Can be a single string or an array of strings. These are the terms that are highlighted in the text.\n */\n query: string | string[]\n /**\n * If `true`, `Fragment` is used for rendering.\n *\n * @default false\n */\n fragment?: boolean\n /**\n * Properties passed to the Mark component which is used to highlight the matched terms.\n */\n markProps?: MarkProps\n}\n\n/**\n * `Highlight` is a component that highlights specified strings within text. By default, it renders a `p` element.\n *\n * @see https://yamada-ui.com/docs/components/highlight\n */\nexport const Highlight: FC<HighlightProps> = ({\n children: text,\n fragment = false,\n query,\n markProps,\n ...rest\n}) => {\n const chunks = useHighlight({ query, text })\n const { colorScheme } = rest\n\n if (fragment) {\n return (\n <>\n {chunks.map(({ match, text }, index) =>\n match ? (\n <Mark key={index} colorScheme={colorScheme} {...markProps}>\n {text}\n </Mark>\n ) : (\n <Fragment key={index}>{text}</Fragment>\n ),\n )}\n </>\n )\n } else {\n return (\n <Text {...rest}>\n {chunks.map(({ match, text }, index) =>\n match ? (\n <Mark key={index} colorScheme={colorScheme} {...markProps}>\n {text}\n </Mark>\n ) : (\n <Fragment key={index}>{text}</Fragment>\n ),\n )}\n </Text>\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkCA,MAAaA,aAAiC,EAC5C,UAAU,MACV,WAAW,OACX,OACA,WACA,GAAG,WACC;CACJ,MAAM,SAASC,mCAAa;EAAE;EAAO;EAAM,CAAC;CAC5C,MAAM,EAAE,gBAAgB;AAExB,KAAI,SACF,QACE,mFACG,OAAO,KAAK,EAAE,OAAO,gBAAQ,UAC5B,QACE,2CAACC;EAA8B;EAAa,GAAI;YAC7CC;IADQ,MAEJ,GAEP,2CAACC,4BAAsBD,UAAR,MAAwB,CAE1C,GACA;KAGL,QACE,2CAACE;EAAK,GAAI;YACP,OAAO,KAAK,EAAE,OAAO,gBAAQ,UAC5B,QACE,2CAACH;GAA8B;GAAa,GAAI;aAC7CC;KADQ,MAEJ,GAEP,2CAACC,4BAAsBD,UAAR,MAAwB,CAE1C;GACI"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-infinite-scroll.cjs","names":["useEnvironment","useCallbackRef","options: IntersectionObserverInit","root","el"],"sources":["../../../../src/components/infinite-scroll-area/use-infinite-scroll.ts"],"sourcesContent":["\"use client\"\n\nimport type { RefObject } from \"react\"\nimport type { Orientation } from \"../../core\"\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\"\nimport { useEnvironment } from \"../../core\"\nimport { assignRef, useCallbackRef } from \"../../utils\"\n\nconst isScrollable = (el: HTMLElement, vertical: boolean) => {\n const style = getComputedStyle(el)\n\n if ([\"auto\", \"overlay\", \"scroll\"].includes(style.overflow)) return true\n\n if (vertical) {\n return [\"auto\", \"overlay\", \"scroll\"].includes(style.overflowY)\n } else {\n return [\"auto\", \"overlay\", \"scroll\"].includes(style.overflowX)\n }\n}\n\nexport interface UseInfiniteScrollProps extends Omit<\n IntersectionObserverInit,\n \"root\"\n> {\n /**\n * Determines whether scrolling is instant or animates smoothly.\n */\n behavior?: ScrollBehavior\n /**\n * If `true`, the infinite scroll is disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * Ref to a reset index function.\n */\n indexRef?: RefObject<(index: number) => void>\n /**\n * If `true`, invoke `onLoad` function for the first time.\n *\n * @default false\n */\n initialLoad?: boolean\n /**\n * The orientation of the infinite scroll.\n *\n * @default 'vertical'\n */\n orientation?: Orientation\n /**\n * Ref to a reset function.\n */\n resetRef?: RefObject<(index?: number, runScroll?: boolean) => void>\n /**\n * If `true`, reverse direction.\n *\n * @default false\n */\n reverse?: boolean\n /**\n * Margin around the root. Can have values similar to the CSS margin property,\n * e.g. \"10px 20px 30px 40px\" (top, right, bottom, left).\n */\n rootMargin?: string\n /**\n * The element that is used as the viewport for checking visibility of the target.\n * Defaults to the browser viewport if not specified or if `null`.\n */\n rootRef?: RefObject<HTMLElement | null>\n /**\n * If set the `onLoad` function will start from the given index.\n * If `initialLoad` is `true`, index starts from `0`.\n *\n * @default 1\n */\n startIndex?: number\n /**\n * Either a single number or an array of numbers which indicate at what percentage of the target's visibility the observer's callback should be executed.\n */\n threshold?: number | number[]\n /**\n * The callback invoked when trigger is intersect.\n */\n onLoad?: ({\n entry,\n finish,\n index,\n }: {\n entry?: IntersectionObserverEntry\n finish: () => void\n index: number\n }) => Promise<void> | void\n}\n\n/**\n * `useInfiniteScroll` is a custom hook for providing infinite scroll functionality.\n *\n * @see https://yamada-ui.com/docs/hooks/use-infinite-scroll\n */\nexport const useInfiniteScroll = <Y extends HTMLElement = HTMLDivElement>({\n behavior,\n disabled = false,\n indexRef: indexRefProp,\n initialLoad = false,\n orientation = \"vertical\",\n resetRef,\n reverse = false,\n rootMargin,\n rootRef,\n startIndex = initialLoad ? 0 : 1,\n threshold,\n onLoad: onLoadProp,\n}: UseInfiniteScrollProps = {}) => {\n const ref = useRef<Y>(null)\n const { getDocument, getWindow } = useEnvironment()\n const indexRef = useRef<number>(startIndex)\n const processingRef = useRef<boolean>(false)\n const observerRef = useRef<IntersectionObserver | undefined>(undefined)\n const [finish, setFinish] = useState<boolean>(false)\n const onLoad = useCallbackRef(onLoadProp)\n const vertical = orientation === \"vertical\"\n const direction = vertical ? \"top\" : \"left\"\n const options: IntersectionObserverInit = useMemo(() => {\n const root = rootRef?.current\n\n return { root, rootMargin, threshold }\n }, [rootMargin, rootRef, threshold])\n\n const onReset = useCallback(\n (index = 1, runScroll = true) => {\n indexRef.current = index\n\n setFinish(false)\n\n if (runScroll) {\n const root = rootRef?.current\n const body = getDocument()?.body\n const el = root && isScrollable(root, vertical) ? root : body\n\n if (el) {\n const target = el === body ? getWindow() : el\n const position = reverse\n ? vertical\n ? el.scrollHeight\n : el.scrollWidth\n : 0\n\n target?.scrollTo({ behavior, [direction]: position })\n }\n }\n\n if (disabled) return\n\n setTimeout(() => {\n const observer = observerRef.current\n const el = ref.current\n\n if (el) observer?.observe(el)\n })\n },\n [\n disabled,\n rootRef,\n getDocument,\n vertical,\n getWindow,\n reverse,\n behavior,\n direction,\n ],\n )\n\n const onFinish = useCallback(() => {\n const observer = observerRef.current\n const el = ref.current\n\n if (el) observer?.unobserve(el)\n\n setFinish(true)\n }, [])\n\n const createObserver = useCallback(() => {\n const observer = new IntersectionObserver(async ([entry]) => {\n const root = rootRef?.current\n const body = getDocument()?.body\n const el = root && isScrollable(root, vertical) ? root : body\n\n if (!entry?.isIntersecting || processingRef.current || !el) return\n\n const props = { entry, finish: onFinish, index: indexRef.current }\n\n processingRef.current = true\n\n if (root) root.ariaBusy = \"true\"\n\n let prevScrollPosition = 0\n\n if (reverse)\n prevScrollPosition = vertical ? el.scrollHeight : el.scrollWidth\n\n await onLoad(props)\n\n if (reverse)\n setTimeout(() => {\n const target = el === body ? getWindow() : el\n const position =\n (vertical ? el.scrollHeight : el.scrollWidth) - prevScrollPosition\n\n target?.scrollTo({ [direction]: position })\n })\n\n indexRef.current += 1\n processingRef.current = false\n\n if (root) root.ariaBusy = \"false\"\n }, options)\n\n return observer\n }, [\n options,\n rootRef,\n getDocument,\n vertical,\n onFinish,\n reverse,\n onLoad,\n getWindow,\n direction,\n ])\n\n useEffect(() => {\n const setTabIndexAttribute = () => {\n const root = rootRef?.current\n if (\n root &&\n isScrollable(root, vertical) &&\n !root.hasAttribute(\"tabindex\")\n ) {\n root.setAttribute(\"tabindex\", \"0\")\n }\n }\n\n const setupObserver = async () => {\n const el = ref.current\n const index = indexRef.current\n const root = rootRef?.current\n\n if (initialLoad) {\n processingRef.current = true\n\n if (root) root.ariaBusy = \"true\"\n\n await onLoad({ finish: onFinish, index })\n\n indexRef.current += 1\n processingRef.current = false\n\n if (root) root.ariaBusy = \"false\"\n }\n\n if (disabled) return\n\n observerRef.current = createObserver()\n\n const observer = observerRef.current\n\n if (reverse) {\n const root = rootRef?.current\n const body = getDocument()?.body\n const el = root && isScrollable(root, vertical) ? root : body\n\n if (el) {\n const target = el === body ? getWindow() : el\n const position = vertical ? el.scrollHeight : el.scrollWidth\n\n target?.scrollTo({ [direction]: position })\n }\n }\n\n setTimeout(() => {\n if (el) observer.observe(el)\n })\n\n return () => {\n if (el) observer.unobserve(el)\n }\n }\n\n setTabIndexAttribute()\n setupObserver()\n }, [\n createObserver,\n initialLoad,\n disabled,\n reverse,\n vertical,\n onFinish,\n onLoad,\n rootRef,\n getDocument,\n getWindow,\n direction,\n ])\n\n assignRef(resetRef, onReset)\n assignRef(indexRefProp, (index) => (indexRef.current = index))\n\n return { ref, finish }\n}\n"],"mappings":";;;;;;;;;;AAQA,MAAM,gBAAgB,IAAiB,aAAsB;CAC3D,MAAM,QAAQ,iBAAiB,GAAG;AAElC,KAAI;EAAC;EAAQ;EAAW;EAAS,CAAC,SAAS,MAAM,SAAS,CAAE,QAAO;AAEnE,KAAI,SACF,QAAO;EAAC;EAAQ;EAAW;EAAS,CAAC,SAAS,MAAM,UAAU;KAE9D,QAAO;EAAC;EAAQ;EAAW;EAAS,CAAC,SAAS,MAAM,UAAU;;;;;;;AAoFlE,MAAa,qBAA6D,EACxE,UACA,WAAW,O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YAAY;AAE7B,OAAI,SAAS;IACX,MAAMC,SAAO,SAAS;IACtB,MAAM,OAAO,aAAa,EAAE;IAC5B,MAAMC,OAAKD,UAAQ,aAAaA,QAAM,SAAS,GAAGA,SAAO;AAEzD,QAAIC,MAAI;KACN,MAAM,SAASA,SAAO,OAAO,WAAW,GAAGA;KAC3C,MAAM,WAAW,WAAWA,KAAG,eAAeA,KAAG;AAEjD,aAAQ,SAAS,GAAG,YAAY,UAAU,CAAC;;;AAI/C,oBAAiB;AACf,QAAI,GAAI,UAAS,QAAQ,GAAG;KAC5B;AAEF,gBAAa;AACX,QAAI,GAAI,UAAS,UAAU,GAAG;;;AAIlC,wBAAsB;AACtB,iBAAe;IACd;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAEF,uBAAU,UAAU,QAAQ;AAC5B,uBAAU,eAAe,UAAW,SAAS,UAAU,MAAO;AAE9D,QAAO;EAAE;EAAK;EAAQ"}
1
+ {"version":3,"file":"use-infinite-scroll.cjs","names":["useEnvironment","useCallbackRef","options: IntersectionObserverInit","root","el"],"sources":["../../../../src/components/infinite-scroll-area/use-infinite-scroll.ts"],"sourcesContent":["\"use client\"\n\nimport type { RefObject } from \"react\"\nimport type { Orientation } from \"../../core\"\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\"\nimport { useEnvironment } from \"../../core\"\nimport { assignRef, useCallbackRef } from \"../../utils\"\n\nconst isScrollable = (el: HTMLElement, vertical: boolean) => {\n const style = getComputedStyle(el)\n\n if ([\"auto\", \"overlay\", \"scroll\"].includes(style.overflow)) return true\n\n if (vertical) {\n return [\"auto\", \"overlay\", \"scroll\"].includes(style.overflowY)\n } else {\n return [\"auto\", \"overlay\", \"scroll\"].includes(style.overflowX)\n }\n}\n\nexport interface UseInfiniteScrollProps extends Omit<\n IntersectionObserverInit,\n \"root\"\n> {\n /**\n * Determines whether scrolling is instant or animates smoothly.\n */\n behavior?: ScrollBehavior\n /**\n * If `true`, the infinite scroll is disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * Ref to a reset index function.\n */\n indexRef?: RefObject<(index: number) => void>\n /**\n * If `true`, invoke `onLoad` function for the first time.\n *\n * @default false\n */\n initialLoad?: boolean\n /**\n * The orientation of the infinite scroll.\n *\n * @default 'vertical'\n */\n orientation?: Orientation\n /**\n * Ref to a reset function.\n */\n resetRef?: RefObject<(index?: number, runScroll?: boolean) => void>\n /**\n * If `true`, reverse direction.\n *\n * @default false\n */\n reverse?: boolean\n /**\n * Margin around the root. Can have values similar to the CSS margin property,\n * e.g. \"10px 20px 30px 40px\" (top, right, bottom, left).\n */\n rootMargin?: string\n /**\n * The element that is used as the viewport for checking visibility of the target.\n * Defaults to the browser viewport if not specified or if `null`.\n */\n rootRef?: RefObject<HTMLElement | null>\n /**\n * If set the `onLoad` function will start from the given index.\n * If `initialLoad` is `true`, index starts from `0`.\n *\n * @default 1\n */\n startIndex?: number\n /**\n * Either a single number or an array of numbers which indicate at what percentage of the target's visibility the observer's callback should be executed.\n */\n threshold?: number | number[]\n /**\n * The callback invoked when trigger is intersect.\n */\n onLoad?: ({\n entry,\n finish,\n index,\n }: {\n index: number\n finish: () => void\n entry?: IntersectionObserverEntry\n }) => Promise<void> | void\n}\n\n/**\n * `useInfiniteScroll` is a custom hook for providing infinite scroll functionality.\n *\n * @see https://yamada-ui.com/docs/hooks/use-infinite-scroll\n */\nexport const useInfiniteScroll = <Y extends HTMLElement = HTMLDivElement>({\n behavior,\n disabled = false,\n indexRef: indexRefProp,\n initialLoad = false,\n orientation = \"vertical\",\n resetRef,\n reverse = false,\n rootMargin,\n rootRef,\n startIndex = initialLoad ? 0 : 1,\n threshold,\n onLoad: onLoadProp,\n}: UseInfiniteScrollProps = {}) => {\n const ref = useRef<Y>(null)\n const { getDocument, getWindow } = useEnvironment()\n const indexRef = useRef<number>(startIndex)\n const processingRef = useRef<boolean>(false)\n const observerRef = useRef<IntersectionObserver | undefined>(undefined)\n const [finish, setFinish] = useState<boolean>(false)\n const onLoad = useCallbackRef(onLoadProp)\n const vertical = orientation === \"vertical\"\n const direction = vertical ? \"top\" : \"left\"\n const options: IntersectionObserverInit = useMemo(() => {\n const root = rootRef?.current\n\n return { root, rootMargin, threshold }\n }, [rootMargin, rootRef, threshold])\n\n const onReset = useCallback(\n (index = 1, runScroll = true) => {\n indexRef.current = index\n\n setFinish(false)\n\n if (runScroll) {\n const root = rootRef?.current\n const body = getDocument()?.body\n const el = root && isScrollable(root, vertical) ? root : body\n\n if (el) {\n const target = el === body ? getWindow() : el\n const position = reverse\n ? vertical\n ? el.scrollHeight\n : el.scrollWidth\n : 0\n\n target?.scrollTo({ behavior, [direction]: position })\n }\n }\n\n if (disabled) return\n\n setTimeout(() => {\n const observer = observerRef.current\n const el = ref.current\n\n if (el) observer?.observe(el)\n })\n },\n [\n disabled,\n rootRef,\n getDocument,\n vertical,\n getWindow,\n reverse,\n behavior,\n direction,\n ],\n )\n\n const onFinish = useCallback(() => {\n const observer = observerRef.current\n const el = ref.current\n\n if (el) observer?.unobserve(el)\n\n setFinish(true)\n }, [])\n\n const createObserver = useCallback(() => {\n const observer = new IntersectionObserver(async ([entry]) => {\n const root = rootRef?.current\n const body = getDocument()?.body\n const el = root && isScrollable(root, vertical) ? root : body\n\n if (!entry?.isIntersecting || processingRef.current || !el) return\n\n const props = { entry, finish: onFinish, index: indexRef.current }\n\n processingRef.current = true\n\n if (root) root.ariaBusy = \"true\"\n\n let prevScrollPosition = 0\n\n if (reverse)\n prevScrollPosition = vertical ? el.scrollHeight : el.scrollWidth\n\n await onLoad(props)\n\n if (reverse)\n setTimeout(() => {\n const target = el === body ? getWindow() : el\n const position =\n (vertical ? el.scrollHeight : el.scrollWidth) - prevScrollPosition\n\n target?.scrollTo({ [direction]: position })\n })\n\n indexRef.current += 1\n processingRef.current = false\n\n if (root) root.ariaBusy = \"false\"\n }, options)\n\n return observer\n }, [\n options,\n rootRef,\n getDocument,\n vertical,\n onFinish,\n reverse,\n onLoad,\n getWindow,\n direction,\n ])\n\n useEffect(() => {\n const setTabIndexAttribute = () => {\n const root = rootRef?.current\n if (\n root &&\n isScrollable(root, vertical) &&\n !root.hasAttribute(\"tabindex\")\n ) {\n root.setAttribute(\"tabindex\", \"0\")\n }\n }\n\n const setupObserver = async () => {\n const el = ref.current\n const index = indexRef.current\n const root = rootRef?.current\n\n if (initialLoad) {\n processingRef.current = true\n\n if (root) root.ariaBusy = \"true\"\n\n await onLoad({ finish: onFinish, index })\n\n indexRef.current += 1\n processingRef.current = false\n\n if (root) root.ariaBusy = \"false\"\n }\n\n if (disabled) return\n\n observerRef.current = createObserver()\n\n const observer = observerRef.current\n\n if (reverse) {\n const root = rootRef?.current\n const body = getDocument()?.body\n const el = root && isScrollable(root, vertical) ? root : body\n\n if (el) {\n const target = el === body ? getWindow() : el\n const position = vertical ? el.scrollHeight : el.scrollWidth\n\n target?.scrollTo({ [direction]: position })\n }\n }\n\n setTimeout(() => {\n if (el) observer.observe(el)\n })\n\n return () => {\n if (el) observer.unobserve(el)\n }\n }\n\n setTabIndexAttribute()\n setupObserver()\n }, [\n createObserver,\n initialLoad,\n disabled,\n reverse,\n vertical,\n onFinish,\n onLoad,\n rootRef,\n getDocument,\n getWindow,\n direction,\n ])\n\n assignRef(resetRef, onReset)\n assignRef(indexRefProp, (index) => (indexRef.current = index))\n\n return { ref, finish }\n}\n"],"mappings":";;;;;;;;;;AAQA,MAAM,gBAAgB,IAAiB,aAAsB;CAC3D,MAAM,QAAQ,iBAAiB,GAAG;AAElC,KAAI;EAAC;EAAQ;EAAW;EAAS,CAAC,SAAS,MAAM,SAAS,CAAE,QAAO;AAEnE,KAAI,SACF,QAAO;EAAC;EAAQ;EAAW;EAAS,CAAC,SAAS,MAAM,UAAU;KAE9D,QAAO;EAAC;EAAQ;EAAW;EAAS,CAAC,SAAS,MAAM,UAAU;;;;;;;AAoFlE,MAAa,qBAA6D,EACxE,UACA,WAAW,OACX,UAAU,cACV,cAAc,OACd,cAA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