@uselets/ui 1.20.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (295) hide show
  1. package/README.md +322 -425
  2. package/dist/as-child-Dxg3Xo1G.d.ts +41 -0
  3. package/dist/cli/uselets.mjs +5 -4
  4. package/dist/cli/uselets.mjs.map +1 -1
  5. package/dist/components/accordion.d.ts +12 -8
  6. package/dist/components/accordion.js +1 -1
  7. package/dist/components/accordion.js.map +1 -1
  8. package/dist/components/alert-dialog.d.ts +20 -15
  9. package/dist/components/alert-dialog.js +1 -1
  10. package/dist/components/alert-dialog.js.map +1 -1
  11. package/dist/components/alert.d.ts +1 -1
  12. package/dist/components/alert.js +1 -1
  13. package/dist/components/alert.js.map +1 -1
  14. package/dist/components/anchor.d.ts +3 -5
  15. package/dist/components/anchor.js +1 -1
  16. package/dist/components/anchor.js.map +1 -1
  17. package/dist/components/area-chart.d.ts +54 -0
  18. package/dist/components/area-chart.js +1 -1
  19. package/dist/components/area-chart.js.map +1 -1
  20. package/dist/components/avatar.d.ts +12 -7
  21. package/dist/components/avatar.js +1 -1
  22. package/dist/components/avatar.js.map +1 -1
  23. package/dist/components/badge.d.ts +3 -5
  24. package/dist/components/badge.js +1 -1
  25. package/dist/components/badge.js.map +1 -1
  26. package/dist/components/bar-chart.d.ts +48 -0
  27. package/dist/components/bar-chart.js +1 -1
  28. package/dist/components/bar-chart.js.map +1 -1
  29. package/dist/components/bottom-nav.d.ts +7 -3
  30. package/dist/components/bottom-nav.js +1 -1
  31. package/dist/components/bottom-nav.js.map +1 -1
  32. package/dist/components/breadcrumb.d.ts +3 -4
  33. package/dist/components/breadcrumb.js +1 -1
  34. package/dist/components/breadcrumb.js.map +1 -1
  35. package/dist/components/button-group.d.ts +3 -4
  36. package/dist/components/button-group.js +1 -1
  37. package/dist/components/button-group.js.map +1 -1
  38. package/dist/components/button.d.ts +8 -4
  39. package/dist/components/button.js +1 -1
  40. package/dist/components/button.js.map +1 -1
  41. package/dist/components/calendar.d.ts +4 -0
  42. package/dist/components/calendar.js +1 -1
  43. package/dist/components/calendar.js.map +1 -1
  44. package/dist/components/card.d.ts +4 -0
  45. package/dist/components/card.js +1 -1
  46. package/dist/components/card.js.map +1 -1
  47. package/dist/components/carousel.d.ts +11 -3
  48. package/dist/components/carousel.js +1 -1
  49. package/dist/components/carousel.js.map +1 -1
  50. package/dist/components/center.d.ts +1 -1
  51. package/dist/components/center.js +1 -1
  52. package/dist/components/center.js.map +1 -1
  53. package/dist/components/chart.js +4 -4
  54. package/dist/components/chart.js.map +1 -1
  55. package/dist/components/checkbox.d.ts +14 -4
  56. package/dist/components/checkbox.js +1 -1
  57. package/dist/components/checkbox.js.map +1 -1
  58. package/dist/components/code.js +1 -1
  59. package/dist/components/code.js.map +1 -1
  60. package/dist/components/collapsible.d.ts +8 -7
  61. package/dist/components/collapsible.js +1 -1
  62. package/dist/components/collapsible.js.map +1 -1
  63. package/dist/components/combobox.d.ts +48 -26
  64. package/dist/components/combobox.js +1 -1
  65. package/dist/components/combobox.js.map +1 -1
  66. package/dist/components/command.d.ts +16 -2
  67. package/dist/components/command.js +1 -1
  68. package/dist/components/command.js.map +1 -1
  69. package/dist/components/container.d.ts +1 -1
  70. package/dist/components/container.js +1 -1
  71. package/dist/components/container.js.map +1 -1
  72. package/dist/components/data-table.d.ts +177 -2
  73. package/dist/components/data-table.js +1 -1
  74. package/dist/components/data-table.js.map +1 -1
  75. package/dist/components/date-range-picker.d.ts +24 -2
  76. package/dist/components/date-range-picker.js +1 -1
  77. package/dist/components/date-range-picker.js.map +1 -1
  78. package/dist/components/dialog.d.ts +33 -15
  79. package/dist/components/dialog.js +1 -1
  80. package/dist/components/dialog.js.map +1 -1
  81. package/dist/components/direction.d.ts +7 -0
  82. package/dist/components/direction.js +1 -0
  83. package/dist/components/donut-chart.d.ts +12 -0
  84. package/dist/components/donut-chart.js +1 -1
  85. package/dist/components/donut-chart.js.map +1 -1
  86. package/dist/components/drawer.d.ts +33 -15
  87. package/dist/components/drawer.js +1 -1
  88. package/dist/components/drawer.js.map +1 -1
  89. package/dist/components/dropdown-menu.d.ts +36 -26
  90. package/dist/components/dropdown-menu.js +1 -1
  91. package/dist/components/dropdown-menu.js.map +1 -1
  92. package/dist/components/dropzone.d.ts +19 -0
  93. package/dist/components/dropzone.js +1 -1
  94. package/dist/components/dropzone.js.map +1 -1
  95. package/dist/components/empty.js +1 -1
  96. package/dist/components/empty.js.map +1 -1
  97. package/dist/components/field.d.ts +16 -4
  98. package/dist/components/field.js +1 -1
  99. package/dist/components/field.js.map +1 -1
  100. package/dist/components/flex.d.ts +1 -1
  101. package/dist/components/flex.js +1 -1
  102. package/dist/components/flex.js.map +1 -1
  103. package/dist/components/grid.d.ts +13 -0
  104. package/dist/components/grid.js +1 -1
  105. package/dist/components/grid.js.map +1 -1
  106. package/dist/components/group.d.ts +1 -1
  107. package/dist/components/group.js +1 -1
  108. package/dist/components/group.js.map +1 -1
  109. package/dist/components/heading.d.ts +3 -5
  110. package/dist/components/heading.js +1 -1
  111. package/dist/components/heading.js.map +1 -1
  112. package/dist/components/hover-card.d.ts +7 -6
  113. package/dist/components/hover-card.js +1 -1
  114. package/dist/components/hover-card.js.map +1 -1
  115. package/dist/components/input-group.d.ts +2 -2
  116. package/dist/components/input-group.js +1 -1
  117. package/dist/components/input-group.js.map +1 -1
  118. package/dist/components/input-otp.d.ts +4 -2
  119. package/dist/components/input-otp.js +1 -1
  120. package/dist/components/input-otp.js.map +1 -1
  121. package/dist/components/input.d.ts +1 -1
  122. package/dist/components/input.js +1 -1
  123. package/dist/components/input.js.map +1 -1
  124. package/dist/components/kbd.js +1 -1
  125. package/dist/components/kbd.js.map +1 -1
  126. package/dist/components/label.d.ts +3 -4
  127. package/dist/components/label.js +1 -1
  128. package/dist/components/label.js.map +1 -1
  129. package/dist/components/list.d.ts +8 -5
  130. package/dist/components/list.js +1 -1
  131. package/dist/components/list.js.map +1 -1
  132. package/dist/components/logo.d.ts +113 -0
  133. package/dist/components/logo.js +1 -1
  134. package/dist/components/marker.d.ts +4 -5
  135. package/dist/components/marker.js +1 -1
  136. package/dist/components/marker.js.map +1 -1
  137. package/dist/components/mask-input.d.ts +6 -0
  138. package/dist/components/mask-input.js +1 -1
  139. package/dist/components/mask-input.js.map +1 -1
  140. package/dist/components/native-select.d.ts +5 -1
  141. package/dist/components/native-select.js +1 -1
  142. package/dist/components/native-select.js.map +1 -1
  143. package/dist/components/navigation-menu.d.ts +19 -20
  144. package/dist/components/navigation-menu.js +1 -1
  145. package/dist/components/navigation-menu.js.map +1 -1
  146. package/dist/components/number-field.d.ts +18 -13
  147. package/dist/components/number-field.js +1 -1
  148. package/dist/components/number-field.js.map +1 -1
  149. package/dist/components/pagination.d.ts +9 -0
  150. package/dist/components/pagination.js +1 -1
  151. package/dist/components/pagination.js.map +1 -1
  152. package/dist/components/phone-input.d.ts +6 -0
  153. package/dist/components/phone-input.js +1 -1
  154. package/dist/components/phone-input.js.map +1 -1
  155. package/dist/components/pie-chart.d.ts +53 -0
  156. package/dist/components/pie-chart.js +1 -1
  157. package/dist/components/pie-chart.js.map +1 -1
  158. package/dist/components/popover.d.ts +13 -12
  159. package/dist/components/popover.js +1 -1
  160. package/dist/components/popover.js.map +1 -1
  161. package/dist/components/progress.d.ts +9 -3
  162. package/dist/components/progress.js +1 -1
  163. package/dist/components/progress.js.map +1 -1
  164. package/dist/components/radio-group.d.ts +20 -6
  165. package/dist/components/radio-group.js +1 -1
  166. package/dist/components/radio-group.js.map +1 -1
  167. package/dist/components/resizable.d.ts +1 -0
  168. package/dist/components/resizable.js +1 -1
  169. package/dist/components/resizable.js.map +1 -1
  170. package/dist/components/ring-progress.d.ts +9 -1
  171. package/dist/components/ring-progress.js +1 -1
  172. package/dist/components/ring-progress.js.map +1 -1
  173. package/dist/components/scroll-area.d.ts +3 -3
  174. package/dist/components/scroll-area.js +1 -1
  175. package/dist/components/scroll-area.js.map +1 -1
  176. package/dist/components/select.d.ts +25 -20
  177. package/dist/components/select.js +1 -1
  178. package/dist/components/select.js.map +1 -1
  179. package/dist/components/separator.d.ts +9 -4
  180. package/dist/components/separator.js +1 -1
  181. package/dist/components/separator.js.map +1 -1
  182. package/dist/components/sidebar.d.ts +63 -18
  183. package/dist/components/sidebar.js +1 -1
  184. package/dist/components/sidebar.js.map +1 -1
  185. package/dist/components/simple-grid.d.ts +7 -0
  186. package/dist/components/simple-grid.js +1 -1
  187. package/dist/components/simple-grid.js.map +1 -1
  188. package/dist/components/skeleton.d.ts +4 -0
  189. package/dist/components/skeleton.js +1 -1
  190. package/dist/components/skeleton.js.map +1 -1
  191. package/dist/components/slider.d.ts +2 -2
  192. package/dist/components/slider.js +1 -1
  193. package/dist/components/slider.js.map +1 -1
  194. package/dist/components/sonner.js +1 -1
  195. package/dist/components/sonner.js.map +1 -1
  196. package/dist/components/spinner.d.ts +1 -1
  197. package/dist/components/spinner.js +1 -1
  198. package/dist/components/spinner.js.map +1 -1
  199. package/dist/components/stack.d.ts +1 -1
  200. package/dist/components/stack.js +1 -1
  201. package/dist/components/stack.js.map +1 -1
  202. package/dist/components/stepper.d.ts +46 -25
  203. package/dist/components/stepper.js +1 -1
  204. package/dist/components/stepper.js.map +1 -1
  205. package/dist/components/switch.d.ts +17 -3
  206. package/dist/components/switch.js +1 -1
  207. package/dist/components/switch.js.map +1 -1
  208. package/dist/components/table.d.ts +10 -1
  209. package/dist/components/table.js +1 -1
  210. package/dist/components/table.js.map +1 -1
  211. package/dist/components/tabs.d.ts +14 -10
  212. package/dist/components/tabs.js +1 -1
  213. package/dist/components/tabs.js.map +1 -1
  214. package/dist/components/text.d.ts +3 -5
  215. package/dist/components/text.js +1 -1
  216. package/dist/components/text.js.map +1 -1
  217. package/dist/components/textarea.d.ts +1 -1
  218. package/dist/components/textarea.js +1 -1
  219. package/dist/components/textarea.js.map +1 -1
  220. package/dist/components/theme.d.ts +12 -0
  221. package/dist/components/theme.js +1 -1
  222. package/dist/components/theme.js.map +1 -1
  223. package/dist/components/timeline.d.ts +25 -1
  224. package/dist/components/timeline.js +1 -1
  225. package/dist/components/timeline.js.map +1 -1
  226. package/dist/components/toggle-group.d.ts +16 -6
  227. package/dist/components/toggle-group.js +1 -1
  228. package/dist/components/toggle-group.js.map +1 -1
  229. package/dist/components/toggle.d.ts +4 -4
  230. package/dist/components/toggle.js +1 -1
  231. package/dist/components/toggle.js.map +1 -1
  232. package/dist/components/tooltip.d.ts +15 -8
  233. package/dist/components/tooltip.js +1 -1
  234. package/dist/components/tooltip.js.map +1 -1
  235. package/dist/components/unstyled-button.d.ts +3 -5
  236. package/dist/components/unstyled-button.js +1 -1
  237. package/dist/components/unstyled-button.js.map +1 -1
  238. package/dist/components/visibility.d.ts +2 -0
  239. package/dist/components/visibility.js +1 -1
  240. package/dist/components/visibility.js.map +1 -1
  241. package/dist/hooks/use-breakpoint-value.d.ts +1 -0
  242. package/dist/hooks/use-breakpoint-value.js.map +1 -1
  243. package/dist/hooks/use-breakpoint.d.ts +1 -0
  244. package/dist/hooks/use-breakpoint.js.map +1 -1
  245. package/dist/hooks/use-disclosure.d.ts +3 -0
  246. package/dist/hooks/use-disclosure.js +1 -1
  247. package/dist/hooks/use-disclosure.js.map +1 -1
  248. package/dist/hooks/use-document-visibility.d.ts +1 -0
  249. package/dist/hooks/use-document-visibility.js.map +1 -1
  250. package/dist/hooks/use-hotkeys.d.ts +1 -1
  251. package/dist/hooks/use-hotkeys.js +1 -1
  252. package/dist/hooks/use-idle.d.ts +9 -0
  253. package/dist/hooks/use-idle.js.map +1 -1
  254. package/dist/hooks/use-interval.d.ts +1 -0
  255. package/dist/hooks/use-interval.js.map +1 -1
  256. package/dist/hooks/use-local-storage.d.ts +6 -0
  257. package/dist/hooks/use-local-storage.js +1 -1
  258. package/dist/hooks/use-local-storage.js.map +1 -1
  259. package/dist/hooks/use-mask.d.ts +1 -0
  260. package/dist/hooks/use-mask.js.map +1 -1
  261. package/dist/hooks/use-mobile.d.ts +1 -0
  262. package/dist/hooks/use-mobile.js.map +1 -1
  263. package/dist/index.d.ts +9 -7
  264. package/dist/index.js +1 -1
  265. package/dist/lib/as-child.d.ts +2 -0
  266. package/dist/lib/as-child.js +2 -0
  267. package/dist/lib/as-child.js.map +1 -0
  268. package/dist/lib/badge.js.map +1 -1
  269. package/dist/lib/button.js.map +1 -1
  270. package/dist/lib/color.js.map +1 -1
  271. package/dist/lib/compose-refs.js +1 -1
  272. package/dist/lib/compose-refs.js.map +1 -1
  273. package/dist/lib/progress.js.map +1 -1
  274. package/dist/lib/utils.d.ts +1 -1
  275. package/dist/lib/utils.js.map +1 -1
  276. package/dist/logo--R3_XDgA.js +2 -0
  277. package/dist/logo--R3_XDgA.js.map +1 -0
  278. package/dist/postcss.config.js.map +1 -1
  279. package/dist/resolve-class-name-BurP8ngI.js +2 -0
  280. package/dist/resolve-class-name-BurP8ngI.js.map +1 -0
  281. package/dist/skills/uselets-ui/SKILL.md +9 -3
  282. package/dist/skills/uselets-ui/references/component-catalog.md +31 -16
  283. package/dist/skills/uselets-ui/references/migration-v1-to-v2.md +599 -0
  284. package/dist/skills/uselets-ui/references/package-guide.md +23 -7
  285. package/dist/styles/base.css +21 -0
  286. package/dist/{use-hotkeys-DOjcX9Tt.d.ts → use-hotkeys-D1_TEIwN.d.ts} +2 -1
  287. package/dist/use-hotkeys-YDJmGWX6.js.map +1 -1
  288. package/package.json +18 -19
  289. package/skills/uselets-ui/SKILL.md +9 -3
  290. package/skills/uselets-ui/references/component-catalog.md +31 -16
  291. package/skills/uselets-ui/references/migration-v1-to-v2.md +599 -0
  292. package/skills/uselets-ui/references/package-guide.md +23 -7
  293. package/dist/data-table-DWWVGWbU.d.ts +0 -4184
  294. package/dist/logo-B0thHtTS.js +0 -2
  295. package/dist/logo-B0thHtTS.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import"../rolldown-runtime-BhWHdk3m.js";import{cn as e}from"../lib/utils.js";import{Button as t}from"./button.js";import{Calendar as n}from"./calendar.js";import{Input as r}from"./input.js";import{Popover as i,PopoverContent as a,PopoverTrigger as o}from"./popover.js";import{IconArrowRight as s,IconCalendar as c,IconChevronDown as l}from"@tabler/icons-react";import{Fragment as u,jsx as d,jsxs as f}from"react/jsx-runtime";import*as p from"react";const m=p.createContext(null),h=[{label:`Hoje`,getRange:()=>{let e=startOfDay(new Date);return{from:e,to:e}}},{label:`Ontem`,getRange:()=>{let e=addDays(startOfDay(new Date),-1);return{from:e,to:e}}},{label:`Últimos 7 dias`,getRange:()=>{let e=startOfDay(new Date);return{from:addDays(e,-7),to:e}}},{label:`Últimos 15 dias`,getRange:()=>{let e=startOfDay(new Date);return{from:addDays(e,-15),to:e}}},{label:`Últimos 30 dias`,getRange:()=>{let e=startOfDay(new Date);return{from:addDays(e,-30),to:e}}},{label:`Últimos 60 dias`,getRange:()=>{let e=startOfDay(new Date);return{from:addDays(e,-60),to:e}}},{label:`Últimos 90 dias`,getRange:()=>{let e=startOfDay(new Date);return{from:addDays(e,-90),to:e}}},{label:`Semana passada`,getRange:()=>{let e=addDays(startOfWeek(new Date),-7);return{from:e,to:addDays(e,6)}}},{label:`Este mês`,getRange:()=>{let e=startOfDay(new Date);return{from:startOfMonth(e),to:e}}},{label:`Mês passado`,getRange:()=>{let e=new Date(new Date().getFullYear(),new Date().getMonth()-1,1);return{from:startOfMonth(e),to:endOfMonth(e)}}}];function DateRangePicker({value:e,defaultValue:t=null,onValueChange:n,onApply:r,onReset:a,open:o,defaultOpen:s=!1,onOpenChange:c,locale:l,placeholder:h=`Selecione um período`,children:g,..._}){let[v,y]=p.useState(t),[b,x]=p.useState(s),S=e!==void 0,C=o!==void 0,w=S?e??null:v,T=C?o:b,[E,D]=p.useState(()=>toDraft(w)),[O,k]=p.useState(()=>getRangeMonth(toDraft(w))),A=p.useCallback(e=>{let t=normalizeDraft(e);D(t);let n=getRangeMonth(t);n&&k(n)},[]),j=p.useCallback(e=>{S||y(e),n?.(e)},[S,n]),M=p.useCallback(e=>{if(e){let e=toDraft(w);D(e),k(getRangeMonth(e))}C||x(e),c?.(e)},[C,c,w]),N=p.useCallback(()=>{let e=toValue(E);j(e),r?.(e),M(!1)},[j,E,r,M]),P=p.useCallback(()=>{D(void 0),j(null),a?.(),M(!1)},[j,a,M]),F=p.useMemo(()=>({value:w,draft:E,month:O,locale:l,placeholder:h,setDraft:A,setMonth:k,apply:N,reset:P}),[N,E,l,O,h,P,A,w]);return d(m.Provider,{value:F,children:d(i,{open:T,onOpenChange:M,..._,children:g??f(u,{children:[d(DateRangePickerTrigger,{}),f(DateRangePickerContent,{children:[d(DateRangePickerPresets,{}),d(DateRangePickerDateFields,{}),d(DateRangePickerCalendar,{}),d(DateRangePickerActions,{})]})]})})})}function DateRangePickerTrigger({className:n,children:r,asChild:i=!1,variant:a=`outline`,color:s=`zinc`,type:p=`button`,...m}){return i?d(o,{asChild:!0,children:r}):d(o,{asChild:!0,children:d(t,{type:p,variant:a,color:s,className:e(`min-w-64 justify-between font-normal`,n),...m,children:r??f(u,{children:[d(c,{"data-icon":`inline-start`,className:`size-4 text-muted-foreground`}),d(DateRangePickerValue,{className:`flex-1 text-left`}),d(l,{"data-icon":`inline-end`,className:`size-4 text-muted-foreground`})]})})})}function DateRangePickerValue({className:t,placeholder:n,...r}){let{value:i,locale:a,placeholder:o}=useDateRangePicker();return d(`span`,{"data-slot":`date-range-picker-value`,className:e(`truncate`,t),...r,children:formatRange(i,a,n??o)})}function DateRangePickerContent({className:t,align:n=`start`,sideOffset:r=8,children:i,...o}){let s=p.Children.toArray(i),c=s.filter(isDateRangePickerPresetsElement),l=s.filter(e=>!isDateRangePickerPresetsElement(e));return d(a,{align:n,sideOffset:r,className:e(`w-[calc(100vw-(--spacing(4)))] max-w-2xl p-2`,t),...o,children:f(`div`,{"data-slot":`date-range-picker-content`,className:`grid gap-3 md:grid-cols-[10rem_minmax(0,1fr)]`,children:[c,d(`div`,{className:`flex min-w-0 flex-col gap-3`,children:l})]})})}function DateRangePickerPresets({className:t,presets:n=h,...r}){let{draft:i,setDraft:a}=useDateRangePicker(),o=getRelativeDaysValue(i,`today`),s=getRelativeDaysValue(i,`yesterday`);return f(`div`,{"data-slot":`date-range-picker-presets`,className:e(`hidden flex-col border-border pr-3 md:flex md:border-r`,t),...r,children:[n.map(e=>{let t=e.getRange(),n=isSameRange(i,t);return d(DateRangePickerPreset,{type:`button`,selected:n,onClick:()=>a(t),children:e.label},e.label)}),f(`div`,{className:`my-3 flex flex-col gap-2`,children:[d(DateRangePickerRelativeField,{label:`Dias até hoje`,value:o,onValueChange:e=>a(getRelativeDaysRange(e,`today`))}),d(DateRangePickerRelativeField,{label:`Dias até ontem`,value:s,onValueChange:e=>a(getRelativeDaysRange(e,`yesterday`))})]})]})}function DateRangePickerPreset({className:t,selected:n=!1,...r}){return d(`button`,{"data-slot":`date-range-picker-preset`,"data-selected":n,className:e(`flex h-8.5 w-full items-center border-l-3 border-border bg-transparent px-2 text-left text-sm text-foreground transition-colors outline-none`,`hover:border-primary hover:bg-primary-50 hover:text-primary-700 dark:hover:bg-primary-950 dark:hover:text-primary-300`,`focus-visible:border-primary focus-visible:ring-3 focus-visible:ring-ring/50`,`data-[selected=true]:border-primary data-[selected=true]:bg-primary-50 data-[selected=true]:text-primary-700 dark:data-[selected=true]:bg-primary-950 dark:data-[selected=true]:text-primary-300`,t),"aria-pressed":n,...r})}function DateRangePickerRelativeField({label:e,value:t,onValueChange:n}){let i=p.useId(),[a,o]=p.useState(()=>formatRelativeInputValue(t));return p.useEffect(()=>{o(formatRelativeInputValue(t))},[t]),f(`div`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[d(r,{id:i,type:`number`,name:e,min:1,step:1,value:a,className:`h-7 w-9 rounded-md px-1 text-center [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none`,"aria-label":e,onChange:e=>{let t=e.target.value;if(o(t),t===``)return;let r=parsePositiveInteger(t);r&&n(r)}}),d(`label`,{htmlFor:i,children:e})]})}function DateRangePickerCalendar({className:t,showOutsideDays:r=!1,onMonthChange:i,...a}){let{draft:o,locale:s,month:c,setDraft:l,setMonth:u}=useDateRangePicker();return d(n,{mode:`range`,numberOfMonths:2,showOutsideDays:r,month:c,onMonthChange:e=>{u(e),i?.(e)},selected:o,onSelect:l,locale:s,className:e(`mx-auto bg-transparent p-0`,t),...a})}function DateRangePickerDateFields({className:t,...n}){let{draft:i,setDraft:a}=useDateRangePicker();return f(`div`,{"data-slot":`date-range-picker-date-fields`,className:e(`pb-2 border-b flex justify-between gap-2 flex-wrap flex-col sm:flex-row sm:items-center`,t),...n,children:[d(r,{type:`date`,value:formatInputDate(i?.from),className:`sm:w-max`,onChange:e=>{if(e.target.value===``){a(void 0);return}let t=parseInputDate(e.target.value);t&&a(normalizeDraft({from:t,to:i?.to}))}}),d(s,{className:`size-4 text-primary hidden sm:block`}),d(r,{type:`date`,value:formatInputDate(i?.to),className:`sm:w-max`,onChange:e=>{if(e.target.value===``){a(void 0);return}let t=parseInputDate(e.target.value);t&&a(normalizeDraft({from:i?.from,to:t}))}})]})}function DateRangePickerActions({className:t,children:n,...r}){return d(`div`,{"data-slot":`date-range-picker-actions`,className:e(`flex items-center gap-2 mt-auto`,t),...r,children:n??f(u,{children:[d(DateRangePickerReset,{}),d(DateRangePickerApply,{})]})})}function DateRangePickerApply({children:n=`Aplicar`,onClick:r,className:i,...a}){let{apply:o}=useDateRangePicker();return d(t,{size:`sm`,className:e(`flex-1`,i),onClick:e=>{r?.(e),e.defaultPrevented||o()},...a,children:n})}function DateRangePickerReset({children:n=`Resetar`,onClick:r,variant:i=`outline`,color:a=`zinc`,className:o,...s}){let{reset:c}=useDateRangePicker();return d(t,{size:`sm`,className:e(`flex-1`,o),variant:i,color:a,onClick:e=>{r?.(e),e.defaultPrevented||c()},...s,children:n})}function useDateRangePicker(){let e=p.useContext(m);if(!e)throw Error(`DateRangePicker components must be used within DateRangePicker.`);return e}function isDateRangePickerPresetsElement(e){return p.isValidElement(e)&&e.type===DateRangePickerPresets}function toDraft(e){return normalizeDraft(e??void 0)}function toValue(e){return normalizeDraft(e)??null}function getRangeMonth(e){return startOfDay(e?.from??e?.to??new Date)}function normalizeDraft(e){if(e?.from||e?.to)return e.from&&e.to&&e.from>e.to?{from:startOfDay(e.to),to:startOfDay(e.from)}:{from:e.from?startOfDay(e.from):void 0,to:e.to?startOfDay(e.to):void 0}}function formatRange(e,t,n){return!e?.from&&!e?.to?n:e.from&&e.to?`${formatDisplayDate(e.from,t)} - ${formatDisplayDate(e.to,t)}`:formatDisplayDate(e.from??e.to,t)}function formatDisplayDate(e,t){return e?new Intl.DateTimeFormat(t?.code??`pt-BR`,{day:`2-digit`,month:`2-digit`,year:`numeric`}).format(e):``}function formatInputDate(e){return e?`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`:``}function parseInputDate(e){if(!e)return;let t=/^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})$/.exec(e);if(!t?.groups)return;let n=Number(t.groups.year),r=Number(t.groups.month),i=Number(t.groups.day),a=new Date(n,r-1,i);if(a.getFullYear()===n&&a.getMonth()===r-1&&a.getDate()===i)return a}function parsePositiveInteger(e){if(!e)return;let t=Number(e);if(!(!Number.isInteger(t)||t<1))return t}function formatRelativeInputValue(e){return e?String(e):``}function getRelativeDaysRange(e,t){let n=startOfDay(new Date),r=t===`today`?addDays(n,-1):addDays(n,-2);return{from:addDays(r,-e+1),to:r}}function getRelativeDaysValue(e,t){if(!e?.from||!e.to)return;let n=startOfDay(new Date),r=t===`today`?addDays(n,-1):addDays(n,-2);if(!isSameDay(e.to,r))return;let i=differenceInCalendarDays(r,startOfDay(e.from))+1;return i>0?i:void 0}function isSameRange(e,t){return isSameDay(e?.from,t?.from)&&isSameDay(e?.to,t?.to)}function isSameDay(e,t){return!e||!t?e===t:e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function startOfDay(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function startOfWeek(e){let t=startOfDay(e);return addDays(t,-t.getDay())}function startOfMonth(e){return new Date(e.getFullYear(),e.getMonth(),1)}function endOfMonth(e){return new Date(e.getFullYear(),e.getMonth()+1,0)}function differenceInCalendarDays(e,t){return Math.round((startOfDay(e).getTime()-startOfDay(t).getTime())/864e5)}function addDays(e,t){let n=startOfDay(e);return n.setDate(n.getDate()+t),n}export{DateRangePicker,DateRangePickerActions,DateRangePickerApply,DateRangePickerCalendar,DateRangePickerContent,DateRangePickerDateFields,DateRangePickerPreset,DateRangePickerPresets,DateRangePickerReset,DateRangePickerTrigger,DateRangePickerValue};
1
+ import"../rolldown-runtime-BhWHdk3m.js";import{cn as e}from"../lib/utils.js";import{t}from"../resolve-class-name-BurP8ngI.js";import{Button as n}from"./button.js";import{Calendar as r}from"./calendar.js";import{Input as i}from"./input.js";import{Popover as a,PopoverContent as o,PopoverTrigger as s}from"./popover.js";import{IconArrowRight as c,IconCalendar as l,IconChevronDown as u}from"@tabler/icons-react";import*as d from"react";import{Fragment as f,jsx as p,jsxs as m}from"react/jsx-runtime";const h=d.createContext(null),g=[{label:`Hoje`,getRange:()=>{let e=startOfDay(/* @__PURE__ */ new Date);return{from:e,to:e}}},{label:`Ontem`,getRange:()=>{let e=addDays(startOfDay(/* @__PURE__ */ new Date),-1);return{from:e,to:e}}},{label:`Últimos 7 dias`,getRange:()=>{let e=startOfDay(/* @__PURE__ */ new Date);return{from:addDays(e,-7),to:e}}},{label:`Últimos 15 dias`,getRange:()=>{let e=startOfDay(/* @__PURE__ */ new Date);return{from:addDays(e,-15),to:e}}},{label:`Últimos 30 dias`,getRange:()=>{let e=startOfDay(/* @__PURE__ */ new Date);return{from:addDays(e,-30),to:e}}},{label:`Últimos 60 dias`,getRange:()=>{let e=startOfDay(/* @__PURE__ */ new Date);return{from:addDays(e,-60),to:e}}},{label:`Últimos 90 dias`,getRange:()=>{let e=startOfDay(/* @__PURE__ */ new Date);return{from:addDays(e,-90),to:e}}},{label:`Semana passada`,getRange:()=>{let e=addDays(startOfWeek(/* @__PURE__ */ new Date),-7);return{from:e,to:addDays(e,6)}}},{label:`Este mês`,getRange:()=>{let e=startOfDay(/* @__PURE__ */ new Date);return{from:startOfMonth(e),to:e}}},{label:`Mês passado`,getRange:()=>{let e=new Date((/* @__PURE__ */ new Date()).getFullYear(),(/* @__PURE__ */ new Date()).getMonth()-1,1);return{from:startOfMonth(e),to:endOfMonth(e)}}}];function DateRangePicker({value:e,defaultValue:t=null,onValueChange:n,onApply:r,onReset:i,open:o,defaultOpen:s=!1,onOpenChange:c,locale:l,placeholder:u=`Selecione um período`,children:g,..._}){let[v,y]=d.useState(t),[b,x]=d.useState(s),S=e!==void 0,C=o!==void 0,w=S?e??null:v,T=C?o:b,[E,D]=d.useState(()=>toDraft(w)),[O,k]=d.useState(()=>getRangeMonth(toDraft(w))),A=d.useCallback(e=>{let t=normalizeDraft(e);D(t);let n=getRangeMonth(t);n&&k(n)},[]),j=d.useCallback(e=>{S||y(e),n?.(e)},[S,n]),M=d.useCallback(e=>{if(e){let e=toDraft(w);D(e),k(getRangeMonth(e))}C||x(e),c?.(e)},[C,c,w]),N=d.useCallback(()=>{let e=toValue(E);j(e),r?.(e),M(!1)},[j,E,r,M]),P=d.useCallback(()=>{D(void 0),j(null),i?.(),M(!1)},[j,i,M]),F=d.useMemo(()=>({value:w,draft:E,month:O,locale:l,placeholder:u,setDraft:A,setMonth:k,apply:N,reset:P}),[N,E,l,O,u,P,A,w]);return/* @__PURE__ */ p(h.Provider,{value:F,children:/* @__PURE__ */ p(a,{open:T,onOpenChange:M,..._,children:g??/* @__PURE__ */ m(f,{children:[/* @__PURE__ */ p(DateRangePickerTrigger,{}),/* @__PURE__ */ m(DateRangePickerContent,{children:[/* @__PURE__ */ p(DateRangePickerPresets,{}),/* @__PURE__ */ p(DateRangePickerDateFields,{}),/* @__PURE__ */ p(DateRangePickerCalendar,{}),/* @__PURE__ */ p(DateRangePickerActions,{})]})]})})})}function DateRangePickerTrigger({className:t,children:r,asChild:i=!1,variant:a=`secondary`,type:o,...c}){return i?/* @__PURE__ */ p(s,{asChild:!0,className:t,type:o,...c,children:r}):/* @__PURE__ */ p(s,{asChild:!0,children:/* @__PURE__ */ p(n,{type:o??`button`,variant:a,className:e(`min-w-64 justify-between font-normal`,t),...c,children:r??/* @__PURE__ */ m(f,{children:[/* @__PURE__ */ p(l,{"data-icon":`inline-start`,className:`size-4 text-muted-foreground`}),/* @__PURE__ */ p(DateRangePickerValue,{className:`flex-1 text-left`}),/* @__PURE__ */ p(u,{"data-icon":`inline-end`,className:`size-4 text-muted-foreground`})]})})})}function DateRangePickerValue({className:t,placeholder:n,...r}){let{value:i,locale:a,placeholder:o}=useDateRangePicker();return/* @__PURE__ */ p(`span`,{"data-slot":`date-range-picker-value`,className:e(`truncate`,t),...r,children:formatRange(i,a,n??o)})}function DateRangePickerContent({className:n,align:r=`start`,sideOffset:i=8,children:a,...s}){let c=d.Children.toArray(a),l=c.filter(isDateRangePickerPresetsElement),u=c.filter(e=>!isDateRangePickerPresetsElement(e));return/* @__PURE__ */ p(o,{align:r,sideOffset:i,className:r=>e(`w-[calc(100vw-(--spacing(4)))] max-w-2xl p-2`,t(n,r)),...s,children:/* @__PURE__ */ m(`div`,{"data-slot":`date-range-picker-content`,className:`grid gap-3 md:grid-cols-[10rem_minmax(0,1fr)]`,children:[l,/* @__PURE__ */ p(`div`,{className:`flex min-w-0 flex-col gap-3`,children:u})]})})}function DateRangePickerPresets({className:t,presets:n=g,...r}){let{draft:i,setDraft:a}=useDateRangePicker(),o=getRelativeDaysValue(i,`today`),s=getRelativeDaysValue(i,`yesterday`);return/* @__PURE__ */ m(`div`,{"data-slot":`date-range-picker-presets`,className:e(`hidden flex-col border-border pr-3 md:flex md:border-r`,t),...r,children:[n.map(e=>{let t=e.getRange(),n=isSameRange(i,t);return/* @__PURE__ */ p(DateRangePickerPreset,{type:`button`,selected:n,onClick:()=>a(t),children:e.label},e.label)}),/* @__PURE__ */ m(`div`,{className:`my-3 flex flex-col gap-2`,children:[/* @__PURE__ */ p(DateRangePickerRelativeField,{label:`Dias até hoje`,value:o,onValueChange:e=>a(getRelativeDaysRange(e,`today`))}),/* @__PURE__ */ p(DateRangePickerRelativeField,{label:`Dias até ontem`,value:s,onValueChange:e=>a(getRelativeDaysRange(e,`yesterday`))})]})]})}function DateRangePickerPreset({className:t,selected:n=!1,...r}){return/* @__PURE__ */ p(`button`,{"data-slot":`date-range-picker-preset`,"data-selected":n,className:e(`flex h-8.5 w-full items-center border-l-3 border-border bg-transparent px-2 text-left text-sm text-foreground transition-colors outline-none`,`hover:border-primary hover:bg-primary-50 hover:text-primary-700 dark:hover:bg-primary-950 dark:hover:text-primary-300`,`focus-visible:border-primary focus-visible:ring-3 focus-visible:ring-ring/50`,`data-[selected=true]:border-primary data-[selected=true]:bg-primary-50 data-[selected=true]:text-primary-700 dark:data-[selected=true]:bg-primary-950 dark:data-[selected=true]:text-primary-300`,t),"aria-pressed":n,...r})}function DateRangePickerRelativeField({label:e,value:t,onValueChange:n}){let r=d.useId(),[a,o]=d.useState(()=>formatRelativeInputValue(t));return d.useEffect(()=>{o(formatRelativeInputValue(t))},[t]),/* @__PURE__ */ m(`div`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[/* @__PURE__ */ p(i,{id:r,type:`number`,name:e,min:1,step:1,value:a,className:`h-7 w-9 rounded-md px-1 text-center [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none`,"aria-label":e,onChange:e=>{let t=e.target.value;if(o(t),t===``)return;let r=parsePositiveInteger(t);r&&n(r)}}),/* @__PURE__ */ p(`label`,{htmlFor:r,children:e})]})}function DateRangePickerCalendar({className:t,showOutsideDays:n=!1,onMonthChange:i,...a}){let{draft:o,locale:s,month:c,setDraft:l,setMonth:u}=useDateRangePicker();return/* @__PURE__ */ p(r,{mode:`range`,numberOfMonths:2,showOutsideDays:n,month:c,onMonthChange:e=>{u(e),i?.(e)},selected:o,onSelect:l,locale:s,className:e(`mx-auto bg-transparent p-0`,t),...a})}function DateRangePickerDateFields({className:t,...n}){let{draft:r,setDraft:a}=useDateRangePicker();return/* @__PURE__ */ m(`div`,{"data-slot":`date-range-picker-date-fields`,className:e(`pb-2 border-b flex justify-between gap-2 flex-wrap flex-col sm:flex-row sm:items-center`,t),...n,children:[/* @__PURE__ */ p(i,{type:`date`,value:formatInputDate(r?.from),className:`sm:w-max`,onChange:e=>{if(e.target.value===``){a(void 0);return}let t=parseInputDate(e.target.value);t&&a(normalizeDraft({from:t,to:r?.to}))}}),/* @__PURE__ */ p(c,{className:`size-4 text-primary hidden sm:block`}),/* @__PURE__ */ p(i,{type:`date`,value:formatInputDate(r?.to),className:`sm:w-max`,onChange:e=>{if(e.target.value===``){a(void 0);return}let t=parseInputDate(e.target.value);t&&a(normalizeDraft({from:r?.from,to:t}))}})]})}function DateRangePickerActions({className:t,children:n,...r}){return/* @__PURE__ */ p(`div`,{"data-slot":`date-range-picker-actions`,className:e(`flex items-center gap-2 mt-auto`,t),...r,children:n??/* @__PURE__ */ m(f,{children:[/* @__PURE__ */ p(DateRangePickerReset,{}),/* @__PURE__ */ p(DateRangePickerApply,{})]})})}function DateRangePickerApply({children:t=`Aplicar`,onClick:r,className:i,...a}){let{apply:o}=useDateRangePicker();return/* @__PURE__ */ p(n,{size:`sm`,className:e(`flex-1`,i),onClick:e=>{r?.(e),e.defaultPrevented||o()},...a,children:t})}function DateRangePickerReset({children:t=`Resetar`,onClick:r,variant:i=`secondary`,className:a,...o}){let{reset:s}=useDateRangePicker();return/* @__PURE__ */ p(n,{size:`sm`,className:e(`flex-1`,a),variant:i,onClick:e=>{r?.(e),e.defaultPrevented||s()},...o,children:t})}function useDateRangePicker(){let e=d.useContext(h);if(!e)throw Error(`DateRangePicker components must be used within DateRangePicker.`);return e}function isDateRangePickerPresetsElement(e){return d.isValidElement(e)&&e.type===DateRangePickerPresets}function toDraft(e){return normalizeDraft(e??void 0)}function toValue(e){return normalizeDraft(e)??null}function getRangeMonth(e){return startOfDay(e?.from??e?.to??/* @__PURE__ */ new Date)}function normalizeDraft(e){if(e?.from||e?.to)return e.from&&e.to&&e.from>e.to?{from:startOfDay(e.to),to:startOfDay(e.from)}:{from:e.from?startOfDay(e.from):void 0,to:e.to?startOfDay(e.to):void 0}}function formatRange(e,t,n){return!e?.from&&!e?.to?n:e.from&&e.to?`${formatDisplayDate(e.from,t)} - ${formatDisplayDate(e.to,t)}`:formatDisplayDate(e.from??e.to,t)}function formatDisplayDate(e,t){return e?new Intl.DateTimeFormat(t?.code??`pt-BR`,{day:`2-digit`,month:`2-digit`,year:`numeric`}).format(e):``}function formatInputDate(e){return e?`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`:``}function parseInputDate(e){if(!e)return;let t=/^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})$/.exec(e);if(!t?.groups)return;let n=Number(t.groups.year),r=Number(t.groups.month),i=Number(t.groups.day),a=new Date(n,r-1,i);if(a.getFullYear()===n&&a.getMonth()===r-1&&a.getDate()===i)return a}function parsePositiveInteger(e){if(!e)return;let t=Number(e);if(!(!Number.isInteger(t)||t<1))return t}function formatRelativeInputValue(e){return e?String(e):``}function getRelativeDaysRange(e,t){let n=startOfDay(/* @__PURE__ */ new Date),r=t===`today`?addDays(n,-1):addDays(n,-2);return{from:addDays(r,-e+1),to:r}}function getRelativeDaysValue(e,t){if(!e?.from||!e.to)return;let n=startOfDay(/* @__PURE__ */ new Date),r=t===`today`?addDays(n,-1):addDays(n,-2);if(!isSameDay(e.to,r))return;let i=differenceInCalendarDays(r,startOfDay(e.from))+1;return i>0?i:void 0}function isSameRange(e,t){return isSameDay(e?.from,t?.from)&&isSameDay(e?.to,t?.to)}function isSameDay(e,t){return!e||!t?e===t:e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function startOfDay(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function startOfWeek(e){let t=startOfDay(e);return addDays(t,-t.getDay())}function startOfMonth(e){return new Date(e.getFullYear(),e.getMonth(),1)}function endOfMonth(e){return new Date(e.getFullYear(),e.getMonth()+1,0)}function differenceInCalendarDays(e,t){return Math.round((startOfDay(e).getTime()-startOfDay(t).getTime())/864e5)}function addDays(e,t){let n=startOfDay(e);return n.setDate(n.getDate()+t),n}export{DateRangePicker,DateRangePickerActions,DateRangePickerApply,DateRangePickerCalendar,DateRangePickerContent,DateRangePickerDateFields,DateRangePickerPreset,DateRangePickerPresets,DateRangePickerReset,DateRangePickerTrigger,DateRangePickerValue};
2
2
  //# sourceMappingURL=date-range-picker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"date-range-picker.js","names":[],"sources":["../../src/components/date-range-picker.tsx"],"sourcesContent":["import * as React from 'react'\nimport type { Locale } from 'react-day-picker'\n\nimport { IconArrowRight, IconCalendar, IconChevronDown } from '@tabler/icons-react'\n\nimport { cn } from '../lib/utils'\nimport { Button } from './button'\nimport { Calendar, type DateRange } from './calendar'\nimport { Input } from './input'\nimport { Popover, PopoverContent, PopoverTrigger } from './popover'\n\ntype DateRangePickerContextValue = {\n value: DateRange | null\n draft: DateRange | undefined\n month: Date\n locale?: Partial<Locale>\n placeholder: string\n setDraft: (range: DateRange | undefined) => void\n setMonth: (month: Date) => void\n apply: () => void\n reset: () => void\n}\n\nconst DateRangePickerContext = React.createContext<DateRangePickerContextValue | null>(null)\n\nconst defaultPlaceholder = 'Selecione um período'\n\nconst defaultPresetDefinitions = [\n {\n label: 'Hoje',\n getRange: () => {\n const today = startOfDay(new Date())\n return { from: today, to: today }\n }\n },\n {\n label: 'Ontem',\n getRange: () => {\n const yesterday = addDays(startOfDay(new Date()), -1)\n return { from: yesterday, to: yesterday }\n }\n },\n {\n label: 'Últimos 7 dias',\n getRange: () => {\n const today = startOfDay(new Date())\n return { from: addDays(today, -7), to: today }\n }\n },\n {\n label: 'Últimos 15 dias',\n getRange: () => {\n const today = startOfDay(new Date())\n return { from: addDays(today, -15), to: today }\n }\n },\n {\n label: 'Últimos 30 dias',\n getRange: () => {\n const today = startOfDay(new Date())\n return { from: addDays(today, -30), to: today }\n }\n },\n {\n label: 'Últimos 60 dias',\n getRange: () => {\n const today = startOfDay(new Date())\n return { from: addDays(today, -60), to: today }\n }\n },\n {\n label: 'Últimos 90 dias',\n getRange: () => {\n const today = startOfDay(new Date())\n return { from: addDays(today, -90), to: today }\n }\n },\n {\n label: 'Semana passada',\n getRange: () => {\n const previousWeekStart = addDays(startOfWeek(new Date()), -7)\n return { from: previousWeekStart, to: addDays(previousWeekStart, 6) }\n }\n },\n {\n label: 'Este mês',\n getRange: () => {\n const today = startOfDay(new Date())\n return { from: startOfMonth(today), to: today }\n }\n },\n {\n label: 'Mês passado',\n getRange: () => {\n const previousMonth = new Date(new Date().getFullYear(), new Date().getMonth() - 1, 1)\n return { from: startOfMonth(previousMonth), to: endOfMonth(previousMonth) }\n }\n }\n] satisfies DateRangePickerPresetOption[]\n\nexport type DateRangePickerPresetOption = {\n label: string\n getRange: () => DateRange\n}\n\nexport type DateRangePickerProps = Omit<\n React.ComponentProps<typeof Popover>,\n 'open' | 'defaultOpen' | 'onOpenChange'\n> & {\n value?: DateRange | null\n defaultValue?: DateRange | null\n onValueChange?: (range: DateRange | null) => void\n onApply?: (range: DateRange | null) => void\n onReset?: () => void\n open?: boolean\n defaultOpen?: boolean\n onOpenChange?: (open: boolean) => void\n locale?: Partial<Locale>\n placeholder?: string\n}\n\nexport type DateRangePickerTriggerProps = React.ComponentProps<typeof Button> & {\n asChild?: boolean\n}\n\nexport type DateRangePickerValueProps = React.ComponentProps<'span'> & {\n placeholder?: string\n}\n\nexport type DateRangePickerContentProps = React.ComponentProps<typeof PopoverContent>\n\nexport type DateRangePickerPresetsProps = React.ComponentProps<'div'> & {\n presets?: DateRangePickerPresetOption[]\n}\n\nexport type DateRangePickerPresetProps = React.ComponentProps<'button'> & {\n selected?: boolean\n}\n\nexport type DateRangePickerCalendarProps = Omit<\n React.ComponentProps<typeof Calendar>,\n 'mode' | 'numberOfMonths' | 'selected' | 'onSelect' | 'month' | 'defaultMonth'\n>\n\nexport type DateRangePickerDateFieldsProps = React.ComponentProps<'div'>\n\nexport type DateRangePickerActionsProps = React.ComponentProps<'div'>\n\nexport type DateRangePickerApplyProps = React.ComponentProps<typeof Button>\n\nexport type DateRangePickerResetProps = React.ComponentProps<typeof Button>\n\nfunction DateRangePicker({\n value: valueProp,\n defaultValue = null,\n onValueChange,\n onApply,\n onReset,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n locale,\n placeholder = defaultPlaceholder,\n children,\n ...props\n}: DateRangePickerProps) {\n const [uncontrolledValue, setUncontrolledValue] = React.useState<DateRange | null>(defaultValue)\n const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen)\n\n const isValueControlled = valueProp !== undefined\n const isOpenControlled = openProp !== undefined\n const value = isValueControlled ? (valueProp ?? null) : uncontrolledValue\n const open = isOpenControlled ? openProp : uncontrolledOpen\n\n const [draft, setDraft] = React.useState<DateRange | undefined>(() => toDraft(value))\n const [month, setMonth] = React.useState<Date>(() => getRangeMonth(toDraft(value)))\n\n const updateDraft = React.useCallback((nextDraft: DateRange | undefined) => {\n const normalizedDraft = normalizeDraft(nextDraft)\n setDraft(normalizedDraft)\n\n const nextMonth = getRangeMonth(normalizedDraft)\n if (nextMonth) {\n setMonth(nextMonth)\n }\n }, [])\n\n const commitValue = React.useCallback(\n (nextValue: DateRange | null) => {\n if (!isValueControlled) {\n setUncontrolledValue(nextValue)\n }\n\n onValueChange?.(nextValue)\n },\n [isValueControlled, onValueChange]\n )\n\n const setOpen = React.useCallback(\n (nextOpen: boolean) => {\n if (nextOpen) {\n const nextDraft = toDraft(value)\n setDraft(nextDraft)\n setMonth(getRangeMonth(nextDraft))\n }\n\n if (!isOpenControlled) {\n setUncontrolledOpen(nextOpen)\n }\n\n onOpenChange?.(nextOpen)\n },\n [isOpenControlled, onOpenChange, value]\n )\n\n const apply = React.useCallback(() => {\n const nextValue = toValue(draft)\n commitValue(nextValue)\n onApply?.(nextValue)\n setOpen(false)\n }, [commitValue, draft, onApply, setOpen])\n\n const reset = React.useCallback(() => {\n setDraft(undefined)\n commitValue(null)\n onReset?.()\n setOpen(false)\n }, [commitValue, onReset, setOpen])\n\n const context = React.useMemo<DateRangePickerContextValue>(\n () => ({\n value,\n draft,\n month,\n locale,\n placeholder,\n setDraft: updateDraft,\n setMonth,\n apply,\n reset\n }),\n [apply, draft, locale, month, placeholder, reset, updateDraft, value]\n )\n\n return (\n <DateRangePickerContext.Provider value={context}>\n <Popover open={open} onOpenChange={setOpen} {...props}>\n {children ?? (\n <>\n <DateRangePickerTrigger />\n <DateRangePickerContent>\n <DateRangePickerPresets />\n <DateRangePickerDateFields />\n <DateRangePickerCalendar />\n <DateRangePickerActions />\n </DateRangePickerContent>\n </>\n )}\n </Popover>\n </DateRangePickerContext.Provider>\n )\n}\n\nfunction DateRangePickerTrigger({\n className,\n children,\n asChild = false,\n variant = 'outline',\n color = 'zinc',\n type = 'button',\n ...props\n}: DateRangePickerTriggerProps) {\n if (asChild) {\n return <PopoverTrigger asChild>{children}</PopoverTrigger>\n }\n\n return (\n <PopoverTrigger asChild>\n <Button\n type={type}\n variant={variant}\n color={color}\n className={cn('min-w-64 justify-between font-normal', className)}\n {...props}\n >\n {children ?? (\n <>\n <IconCalendar data-icon=\"inline-start\" className=\"size-4 text-muted-foreground\" />\n <DateRangePickerValue className=\"flex-1 text-left\" />\n <IconChevronDown data-icon=\"inline-end\" className=\"size-4 text-muted-foreground\" />\n </>\n )}\n </Button>\n </PopoverTrigger>\n )\n}\n\nfunction DateRangePickerValue({ className, placeholder, ...props }: DateRangePickerValueProps) {\n const { value, locale, placeholder: contextPlaceholder } = useDateRangePicker()\n\n return (\n <span data-slot=\"date-range-picker-value\" className={cn('truncate', className)} {...props}>\n {formatRange(value, locale, placeholder ?? contextPlaceholder)}\n </span>\n )\n}\n\nfunction DateRangePickerContent({\n className,\n align = 'start',\n sideOffset = 8,\n children,\n ...props\n}: DateRangePickerContentProps) {\n const childArray = React.Children.toArray(children)\n const presets = childArray.filter(isDateRangePickerPresetsElement)\n const content = childArray.filter((child) => !isDateRangePickerPresetsElement(child))\n\n return (\n <PopoverContent\n align={align}\n sideOffset={sideOffset}\n className={cn('w-[calc(100vw-(--spacing(4)))] max-w-2xl p-2', className)}\n {...props}\n >\n <div data-slot=\"date-range-picker-content\" className=\"grid gap-3 md:grid-cols-[10rem_minmax(0,1fr)]\">\n {presets}\n <div className=\"flex min-w-0 flex-col gap-3\">{content}</div>\n </div>\n </PopoverContent>\n )\n}\n\nfunction DateRangePickerPresets({\n className,\n presets = defaultPresetDefinitions,\n ...props\n}: DateRangePickerPresetsProps) {\n const { draft, setDraft } = useDateRangePicker()\n const todayRelativeValue = getRelativeDaysValue(draft, 'today')\n const yesterdayRelativeValue = getRelativeDaysValue(draft, 'yesterday')\n\n return (\n <div\n data-slot=\"date-range-picker-presets\"\n className={cn('hidden flex-col border-border pr-3 md:flex md:border-r', className)}\n {...props}\n >\n {presets.map((preset) => {\n const range = preset.getRange()\n const selected = isSameRange(draft, range)\n\n return (\n <DateRangePickerPreset key={preset.label} type=\"button\" selected={selected} onClick={() => setDraft(range)}>\n {preset.label}\n </DateRangePickerPreset>\n )\n })}\n\n <div className=\"my-3 flex flex-col gap-2\">\n <DateRangePickerRelativeField\n label=\"Dias até hoje\"\n value={todayRelativeValue}\n onValueChange={(days) => setDraft(getRelativeDaysRange(days, 'today'))}\n />\n <DateRangePickerRelativeField\n label=\"Dias até ontem\"\n value={yesterdayRelativeValue}\n onValueChange={(days) => setDraft(getRelativeDaysRange(days, 'yesterday'))}\n />\n </div>\n </div>\n )\n}\n\nfunction DateRangePickerPreset({ className, selected = false, ...props }: DateRangePickerPresetProps) {\n return (\n <button\n data-slot=\"date-range-picker-preset\"\n data-selected={selected}\n className={cn(\n 'flex h-8.5 w-full items-center border-l-3 border-border bg-transparent px-2 text-left text-sm text-foreground transition-colors outline-none',\n 'hover:border-primary hover:bg-primary-50 hover:text-primary-700 dark:hover:bg-primary-950 dark:hover:text-primary-300',\n 'focus-visible:border-primary focus-visible:ring-3 focus-visible:ring-ring/50',\n 'data-[selected=true]:border-primary data-[selected=true]:bg-primary-50 data-[selected=true]:text-primary-700 dark:data-[selected=true]:bg-primary-950 dark:data-[selected=true]:text-primary-300',\n className\n )}\n aria-pressed={selected}\n {...props}\n />\n )\n}\n\nfunction DateRangePickerRelativeField({\n label,\n value,\n onValueChange\n}: {\n label: string\n value: number | undefined\n onValueChange: (days: number) => void\n}) {\n const id = React.useId()\n const [inputValue, setInputValue] = React.useState(() => formatRelativeInputValue(value))\n\n React.useEffect(() => {\n setInputValue(formatRelativeInputValue(value))\n }, [value])\n\n return (\n <div className=\"flex items-center gap-2 text-sm text-foreground\">\n <Input\n id={id}\n type=\"number\"\n name={label}\n min={1}\n step={1}\n value={inputValue}\n className=\"h-7 w-9 rounded-md px-1 text-center [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none\"\n aria-label={label}\n onChange={(event) => {\n const nextValue = event.target.value\n setInputValue(nextValue)\n\n if (nextValue === '') return\n\n const days = parsePositiveInteger(nextValue)\n if (!days) return\n onValueChange(days)\n }}\n />\n <label htmlFor={id}>{label}</label>\n </div>\n )\n}\n\nfunction DateRangePickerCalendar({\n className,\n showOutsideDays = false,\n onMonthChange,\n ...props\n}: DateRangePickerCalendarProps) {\n const { draft, locale, month, setDraft, setMonth } = useDateRangePicker()\n\n return (\n <Calendar\n mode=\"range\"\n numberOfMonths={2}\n showOutsideDays={showOutsideDays}\n month={month}\n onMonthChange={(nextMonth) => {\n setMonth(nextMonth)\n onMonthChange?.(nextMonth)\n }}\n selected={draft}\n onSelect={setDraft}\n locale={locale}\n className={cn('mx-auto bg-transparent p-0', className)}\n {...props}\n />\n )\n}\n\nfunction DateRangePickerDateFields({ className, ...props }: DateRangePickerDateFieldsProps) {\n const { draft, setDraft } = useDateRangePicker()\n\n return (\n <div\n data-slot=\"date-range-picker-date-fields\"\n className={cn(\n 'pb-2 border-b flex justify-between gap-2 flex-wrap flex-col sm:flex-row sm:items-center',\n className\n )}\n {...props}\n >\n <Input\n type=\"date\"\n value={formatInputDate(draft?.from)}\n className=\"sm:w-max\"\n onChange={(event) => {\n if (event.target.value === '') {\n setDraft(undefined)\n return\n }\n\n const date = parseInputDate(event.target.value)\n if (!date) return\n setDraft(normalizeDraft({ from: date, to: draft?.to }))\n }}\n />\n <IconArrowRight className=\"size-4 text-primary hidden sm:block\" />\n <Input\n type=\"date\"\n value={formatInputDate(draft?.to)}\n className=\"sm:w-max\"\n onChange={(event) => {\n if (event.target.value === '') {\n setDraft(undefined)\n return\n }\n\n const date = parseInputDate(event.target.value)\n if (!date) return\n setDraft(normalizeDraft({ from: draft?.from, to: date }))\n }}\n />\n </div>\n )\n}\n\nfunction DateRangePickerActions({ className, children, ...props }: DateRangePickerActionsProps) {\n return (\n <div data-slot=\"date-range-picker-actions\" className={cn('flex items-center gap-2 mt-auto', className)} {...props}>\n {children ?? (\n <>\n <DateRangePickerReset />\n <DateRangePickerApply />\n </>\n )}\n </div>\n )\n}\n\nfunction DateRangePickerApply({ children = 'Aplicar', onClick, className, ...props }: DateRangePickerApplyProps) {\n const { apply } = useDateRangePicker()\n\n return (\n <Button\n size=\"sm\"\n className={cn('flex-1', className)}\n onClick={(event) => {\n onClick?.(event)\n if (!event.defaultPrevented) {\n apply()\n }\n }}\n {...props}\n >\n {children}\n </Button>\n )\n}\n\nfunction DateRangePickerReset({\n children = 'Resetar',\n onClick,\n variant = 'outline',\n color = 'zinc',\n className,\n ...props\n}: DateRangePickerResetProps) {\n const { reset } = useDateRangePicker()\n\n return (\n <Button\n size=\"sm\"\n className={cn('flex-1', className)}\n variant={variant}\n color={color}\n onClick={(event) => {\n onClick?.(event)\n if (!event.defaultPrevented) {\n reset()\n }\n }}\n {...props}\n >\n {children}\n </Button>\n )\n}\n\nfunction useDateRangePicker() {\n const context = React.useContext(DateRangePickerContext)\n\n if (!context) {\n throw new Error('DateRangePicker components must be used within DateRangePicker.')\n }\n\n return context\n}\n\nfunction isDateRangePickerPresetsElement(child: React.ReactNode) {\n return React.isValidElement(child) && child.type === DateRangePickerPresets\n}\n\nfunction toDraft(range: DateRange | null | undefined) {\n return normalizeDraft(range ?? undefined)\n}\n\nfunction toValue(range: DateRange | undefined): DateRange | null {\n return normalizeDraft(range) ?? null\n}\n\nfunction getRangeMonth(range: DateRange | undefined) {\n return startOfDay(range?.from ?? range?.to ?? new Date())\n}\n\nfunction normalizeDraft(range: DateRange | undefined): DateRange | undefined {\n if (!range?.from && !range?.to) return undefined\n\n if (range.from && range.to && range.from > range.to) {\n return { from: startOfDay(range.to), to: startOfDay(range.from) }\n }\n\n return {\n from: range.from ? startOfDay(range.from) : undefined,\n to: range.to ? startOfDay(range.to) : undefined\n }\n}\n\nfunction formatRange(range: DateRange | null | undefined, locale: Partial<Locale> | undefined, placeholder: string) {\n if (!range?.from && !range?.to) return placeholder\n\n if (range.from && range.to) {\n return `${formatDisplayDate(range.from, locale)} - ${formatDisplayDate(range.to, locale)}`\n }\n\n return formatDisplayDate(range.from ?? range.to, locale)\n}\n\nfunction formatDisplayDate(date: Date | undefined, locale: Partial<Locale> | undefined) {\n if (!date) return ''\n\n return new Intl.DateTimeFormat(locale?.code ?? 'pt-BR', {\n day: '2-digit',\n month: '2-digit',\n year: 'numeric'\n }).format(date)\n}\n\nfunction formatInputDate(date: Date | undefined) {\n if (!date) return ''\n\n const year = date.getFullYear()\n const month = String(date.getMonth() + 1).padStart(2, '0')\n const day = String(date.getDate()).padStart(2, '0')\n\n return `${year}-${month}-${day}`\n}\n\nfunction parseInputDate(value: string) {\n if (!value) return undefined\n\n const match = /^(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})$/.exec(value)\n if (!match?.groups) return undefined\n\n const year = Number(match.groups.year)\n const month = Number(match.groups.month)\n const day = Number(match.groups.day)\n const date = new Date(year, month - 1, day)\n\n if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day) {\n return undefined\n }\n\n return date\n}\n\nfunction parsePositiveInteger(value: string) {\n if (!value) return undefined\n\n const days = Number(value)\n if (!Number.isInteger(days) || days < 1) return undefined\n\n return days\n}\n\nfunction formatRelativeInputValue(value: number | undefined) {\n return value ? String(value) : ''\n}\n\nfunction getRelativeDaysRange(days: number, target: 'today' | 'yesterday'): DateRange {\n const today = startOfDay(new Date())\n const targetDate = target === 'today' ? addDays(today, -1) : addDays(today, -2)\n\n return {\n from: addDays(targetDate, -days + 1),\n to: targetDate\n }\n}\n\nfunction getRelativeDaysValue(range: DateRange | undefined, target: 'today' | 'yesterday') {\n if (!range?.from || !range.to) return undefined\n\n const today = startOfDay(new Date())\n const targetDate = target === 'today' ? addDays(today, -1) : addDays(today, -2)\n if (!isSameDay(range.to, targetDate)) return undefined\n\n const days = differenceInCalendarDays(targetDate, startOfDay(range.from)) + 1\n return days > 0 ? days : undefined\n}\n\nfunction isSameRange(left: DateRange | undefined, right: DateRange | undefined) {\n return isSameDay(left?.from, right?.from) && isSameDay(left?.to, right?.to)\n}\n\nfunction isSameDay(left: Date | undefined, right: Date | undefined) {\n if (!left || !right) return left === right\n\n return (\n left.getFullYear() === right.getFullYear() &&\n left.getMonth() === right.getMonth() &&\n left.getDate() === right.getDate()\n )\n}\n\nfunction startOfDay(date: Date) {\n return new Date(date.getFullYear(), date.getMonth(), date.getDate())\n}\n\nfunction startOfWeek(date: Date) {\n const day = startOfDay(date)\n return addDays(day, -day.getDay())\n}\n\nfunction startOfMonth(date: Date) {\n return new Date(date.getFullYear(), date.getMonth(), 1)\n}\n\nfunction endOfMonth(date: Date) {\n return new Date(date.getFullYear(), date.getMonth() + 1, 0)\n}\n\nfunction differenceInCalendarDays(left: Date, right: Date) {\n const millisecondsPerDay = 24 * 60 * 60 * 1000\n return Math.round((startOfDay(left).getTime() - startOfDay(right).getTime()) / millisecondsPerDay)\n}\n\nfunction addDays(date: Date, amount: number) {\n const nextDate = startOfDay(date)\n nextDate.setDate(nextDate.getDate() + amount)\n return nextDate\n}\n\nexport {\n type DateRange,\n DateRangePicker,\n DateRangePickerActions,\n DateRangePickerApply,\n DateRangePickerCalendar,\n DateRangePickerContent,\n DateRangePickerDateFields,\n DateRangePickerPreset,\n DateRangePickerPresets,\n DateRangePickerReset,\n DateRangePickerTrigger,\n DateRangePickerValue\n}\n"],"mappings":"icAuBA,MAAM,EAAyB,EAAM,cAAkD,IAAI,EAIrF,EAA2B,CAC/B,CACE,MAAO,OACP,aAAgB,CACd,IAAM,EAAQ,WAAW,IAAI,IAAM,EACnC,MAAO,CAAE,KAAM,EAAO,GAAI,CAAM,CAClC,CACF,EACA,CACE,MAAO,QACP,aAAgB,CACd,IAAM,EAAY,QAAQ,WAAW,IAAI,IAAM,EAAG,EAAE,EACpD,MAAO,CAAE,KAAM,EAAW,GAAI,CAAU,CAC1C,CACF,EACA,CACE,MAAO,iBACP,aAAgB,CACd,IAAM,EAAQ,WAAW,IAAI,IAAM,EACnC,MAAO,CAAE,KAAM,QAAQ,EAAO,EAAE,EAAG,GAAI,CAAM,CAC/C,CACF,EACA,CACE,MAAO,kBACP,aAAgB,CACd,IAAM,EAAQ,WAAW,IAAI,IAAM,EACnC,MAAO,CAAE,KAAM,QAAQ,EAAO,GAAG,EAAG,GAAI,CAAM,CAChD,CACF,EACA,CACE,MAAO,kBACP,aAAgB,CACd,IAAM,EAAQ,WAAW,IAAI,IAAM,EACnC,MAAO,CAAE,KAAM,QAAQ,EAAO,GAAG,EAAG,GAAI,CAAM,CAChD,CACF,EACA,CACE,MAAO,kBACP,aAAgB,CACd,IAAM,EAAQ,WAAW,IAAI,IAAM,EACnC,MAAO,CAAE,KAAM,QAAQ,EAAO,GAAG,EAAG,GAAI,CAAM,CAChD,CACF,EACA,CACE,MAAO,kBACP,aAAgB,C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Ac,IAAS,EAGnC,EAAK,YAAY,IAAM,EAAM,YAAY,GACzC,EAAK,SAAS,IAAM,EAAM,SAAS,GACnC,EAAK,QAAQ,IAAM,EAAM,QAAQ,CAErC,CAEA,SAAS,WAAW,EAAY,CAC9B,OAAO,IAAI,KAAK,EAAK,YAAY,EAAG,EAAK,SAAS,EAAG,EAAK,QAAQ,CAAC,CACrE,CAEA,SAAS,YAAY,EAAY,CAC/B,IAAM,EAAM,WAAW,CAAI,EAC3B,OAAO,QAAQ,EAAK,CAAC,EAAI,OAAO,CAAC,CACnC,CAEA,SAAS,aAAa,EAAY,CAChC,OAAO,IAAI,KAAK,EAAK,YAAY,EAAG,EAAK,SAAS,EAAG,CAAC,CACxD,CAEA,SAAS,WAAW,EAAY,CAC9B,OAAO,IAAI,KAAK,EAAK,YAAY,EAAG,EAAK,SAAS,EAAI,EAAG,CAAC,CAC5D,CAEA,SAAS,yBAAyB,EAAY,EAAa,CAEzD,OAAO,KAAK,OAAO,WAAW,CAAI,CAAC,CAAC,QAAQ,EAAI,WAAW,CAAK,CAAC,CAAC,QAAQ,GAAK,KAAkB,CACnG,CAEA,SAAS,QAAQ,EAAY,EAAgB,CAC3C,IAAM,EAAW,WAAW,CAAI,EAEhC,OADA,EAAS,QAAQ,EAAS,QAAQ,EAAI,CAAM,EACrC,CACT"}
1
+ {"version":3,"file":"date-range-picker.js","names":["React","DateRangePickerContext","defaultPresetDefinitions","today","yesterday","previousWeekStart","previousMonth","valueProp","openProp","props","uncontrolledValue","setUncontrolledValue","defaultValue","uncontrolledOpen","setUncontrolledOpen","defaultOpen","isValueControlled","isOpenControlled","value","open","draft","setDraft","month","setMonth","updateDraft","normalizedDraft","nextDraft","nextMonth","commitValue","nextValue","onValueChange","setOpen","nextOpen","onOpenChange","apply","onApply","reset","onReset","context","locale","placeholder","Popover","children","Fragment","asChild","PopoverTrigger","Button","type","cn","className","IconCalendar","IconChevronDown","contextPlaceholder","childArray","presets","content","child","PopoverContent","resolveClassName","state","todayRelativeValue","yesterdayRelativeValue","range","preset","selected","days","id","inputValue","setInputValue","Input","label","event","Calendar","onMonthChange","date","IconArrowRight","onClick","match","year","day","targetDate","target","left","right","nextDate","amount"],"sources":["../../src/components/date-range-picker.tsx"],"sourcesContent":["import * as React from 'react'\nimport type { Locale } from 'react-day-picker'\n\nimport { IconArrowRight, IconCalendar, IconChevronDown } from '@tabler/icons-react'\n\nimport { cn } from '../lib/utils'\nimport { resolveClassName } from '../utils/resolve-class-name'\nimport { Button } from './button'\nimport { Calendar, type DateRange } from './calendar'\nimport { Input } from './input'\nimport { Popover, PopoverContent, PopoverTrigger } from './popover'\n\ntype DateRangePickerContextValue = {\n value: DateRange | null\n draft: DateRange | undefined\n month: Date\n locale?: Partial<Locale>\n placeholder: string\n setDraft: (range: DateRange | undefined) => void\n setMonth: (month: Date) => void\n apply: () => void\n reset: () => void\n}\n\nconst DateRangePickerContext = React.createContext<DateRangePickerContextValue | null>(null)\n\nconst defaultPlaceholder = 'Selecione um período'\n\nconst defaultPresetDefinitions = [\n {\n label: 'Hoje',\n getRange: () => {\n const today = startOfDay(new Date())\n return { from: today, to: today }\n }\n },\n {\n label: 'Ontem',\n getRange: () => {\n const yesterday = addDays(startOfDay(new Date()), -1)\n return { from: yesterday, to: yesterday }\n }\n },\n {\n label: 'Últimos 7 dias',\n getRange: () => {\n const today = startOfDay(new Date())\n return { from: addDays(today, -7), to: today }\n }\n },\n {\n label: 'Últimos 15 dias',\n getRange: () => {\n const today = startOfDay(new Date())\n return { from: addDays(today, -15), to: today }\n }\n },\n {\n label: 'Últimos 30 dias',\n getRange: () => {\n const today = startOfDay(new Date())\n return { from: addDays(today, -30), to: today }\n }\n },\n {\n label: 'Últimos 60 dias',\n getRange: () => {\n const today = startOfDay(new Date())\n return { from: addDays(today, -60), to: today }\n }\n },\n {\n label: 'Últimos 90 dias',\n getRange: () => {\n const today = startOfDay(new Date())\n return { from: addDays(today, -90), to: today }\n }\n },\n {\n label: 'Semana passada',\n getRange: () => {\n const previousWeekStart = addDays(startOfWeek(new Date()), -7)\n return { from: previousWeekStart, to: addDays(previousWeekStart, 6) }\n }\n },\n {\n label: 'Este mês',\n getRange: () => {\n const today = startOfDay(new Date())\n return { from: startOfMonth(today), to: today }\n }\n },\n {\n label: 'Mês passado',\n getRange: () => {\n const previousMonth = new Date(new Date().getFullYear(), new Date().getMonth() - 1, 1)\n return { from: startOfMonth(previousMonth), to: endOfMonth(previousMonth) }\n }\n }\n] satisfies DateRangePickerPresetOption[]\n\nexport type DateRangePickerPresetOption = {\n label: string\n getRange: () => DateRange\n}\n\nexport type DateRangePickerProps = Omit<\n React.ComponentProps<typeof Popover>,\n 'open' | 'defaultOpen' | 'onOpenChange'\n> & {\n /** Selected range (controlled). `null` when empty. */\n value?: DateRange | null\n /**\n * Initial range (uncontrolled).\n * @default null\n */\n defaultValue?: DateRange | null\n /** Called when a range is applied, or with `null` when it is reset. */\n onValueChange?: (range: DateRange | null) => void\n /** Called after `DateRangePickerApply` commits the draft. */\n onApply?: (range: DateRange | null) => void\n /** Called after `DateRangePickerReset` clears the value. */\n onReset?: () => void\n /** Whether the popover is open (controlled). */\n open?: boolean\n /**\n * Whether the popover starts open (uncontrolled).\n * @default false\n */\n defaultOpen?: boolean\n /** Called when the popover opens or closes. */\n onOpenChange?: (open: boolean) => void\n /** `react-day-picker` locale used by the calendar and the formatted dates. */\n locale?: Partial<Locale>\n /** Trigger text when no range is selected. */\n placeholder?: string\n}\n\nexport type DateRangePickerTriggerProps = React.ComponentProps<typeof Button> & {\n asChild?: boolean\n}\n\nexport type DateRangePickerValueProps = React.ComponentProps<'span'> & {\n /** Text shown when no range is selected. Defaults to the picker `placeholder`. */\n placeholder?: string\n}\n\nexport type DateRangePickerContentProps = React.ComponentProps<typeof PopoverContent>\n\nexport type DateRangePickerPresetsProps = React.ComponentProps<'div'> & {\n /** Presets to show, as `{ label, getRange }`. Defaults to the pt-BR presets. */\n presets?: DateRangePickerPresetOption[]\n}\n\nexport type DateRangePickerPresetProps = React.ComponentProps<'button'> & {\n /**\n * Highlights the preset as the current selection.\n * @default false\n */\n selected?: boolean\n}\n\nexport type DateRangePickerCalendarProps = Omit<\n React.ComponentProps<typeof Calendar>,\n 'mode' | 'numberOfMonths' | 'selected' | 'onSelect' | 'month' | 'defaultMonth'\n>\n\nexport type DateRangePickerDateFieldsProps = React.ComponentProps<'div'>\n\nexport type DateRangePickerActionsProps = React.ComponentProps<'div'>\n\nexport type DateRangePickerApplyProps = React.ComponentProps<typeof Button>\n\nexport type DateRangePickerResetProps = React.ComponentProps<typeof Button>\n\nfunction DateRangePicker({\n value: valueProp,\n defaultValue = null,\n onValueChange,\n onApply,\n onReset,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n locale,\n placeholder = defaultPlaceholder,\n children,\n ...props\n}: DateRangePickerProps) {\n const [uncontrolledValue, setUncontrolledValue] = React.useState<DateRange | null>(defaultValue)\n const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen)\n\n const isValueControlled = valueProp !== undefined\n const isOpenControlled = openProp !== undefined\n const value = isValueControlled ? (valueProp ?? null) : uncontrolledValue\n const open = isOpenControlled ? openProp : uncontrolledOpen\n\n const [draft, setDraft] = React.useState<DateRange | undefined>(() => toDraft(value))\n const [month, setMonth] = React.useState<Date>(() => getRangeMonth(toDraft(value)))\n\n const updateDraft = React.useCallback((nextDraft: DateRange | undefined) => {\n const normalizedDraft = normalizeDraft(nextDraft)\n setDraft(normalizedDraft)\n\n const nextMonth = getRangeMonth(normalizedDraft)\n if (nextMonth) {\n setMonth(nextMonth)\n }\n }, [])\n\n const commitValue = React.useCallback(\n (nextValue: DateRange | null) => {\n if (!isValueControlled) {\n setUncontrolledValue(nextValue)\n }\n\n onValueChange?.(nextValue)\n },\n [isValueControlled, onValueChange]\n )\n\n const setOpen = React.useCallback(\n (nextOpen: boolean) => {\n if (nextOpen) {\n const nextDraft = toDraft(value)\n setDraft(nextDraft)\n setMonth(getRangeMonth(nextDraft))\n }\n\n if (!isOpenControlled) {\n setUncontrolledOpen(nextOpen)\n }\n\n onOpenChange?.(nextOpen)\n },\n [isOpenControlled, onOpenChange, value]\n )\n\n const apply = React.useCallback(() => {\n const nextValue = toValue(draft)\n commitValue(nextValue)\n onApply?.(nextValue)\n setOpen(false)\n }, [commitValue, draft, onApply, setOpen])\n\n const reset = React.useCallback(() => {\n setDraft(undefined)\n commitValue(null)\n onReset?.()\n setOpen(false)\n }, [commitValue, onReset, setOpen])\n\n const context = React.useMemo<DateRangePickerContextValue>(\n () => ({\n value,\n draft,\n month,\n locale,\n placeholder,\n setDraft: updateDraft,\n setMonth,\n apply,\n reset\n }),\n [apply, draft, locale, month, placeholder, reset, updateDraft, value]\n )\n\n return (\n <DateRangePickerContext.Provider value={context}>\n <Popover open={open} onOpenChange={setOpen} {...props}>\n {children ?? (\n <>\n <DateRangePickerTrigger />\n <DateRangePickerContent>\n <DateRangePickerPresets />\n <DateRangePickerDateFields />\n <DateRangePickerCalendar />\n <DateRangePickerActions />\n </DateRangePickerContent>\n </>\n )}\n </Popover>\n </DateRangePickerContext.Provider>\n )\n}\n\nfunction DateRangePickerTrigger({\n className,\n children,\n asChild = false,\n variant = 'secondary',\n type,\n ...props\n}: DateRangePickerTriggerProps) {\n if (asChild) {\n return (\n <PopoverTrigger asChild className={className} type={type} {...props}>\n {children}\n </PopoverTrigger>\n )\n }\n\n return (\n <PopoverTrigger asChild>\n <Button\n type={type ?? 'button'}\n variant={variant}\n className={cn('min-w-64 justify-between font-normal', className)}\n {...props}\n >\n {children ?? (\n <>\n <IconCalendar data-icon=\"inline-start\" className=\"size-4 text-muted-foreground\" />\n <DateRangePickerValue className=\"flex-1 text-left\" />\n <IconChevronDown data-icon=\"inline-end\" className=\"size-4 text-muted-foreground\" />\n </>\n )}\n </Button>\n </PopoverTrigger>\n )\n}\n\nfunction DateRangePickerValue({ className, placeholder, ...props }: DateRangePickerValueProps) {\n const { value, locale, placeholder: contextPlaceholder } = useDateRangePicker()\n\n return (\n <span data-slot=\"date-range-picker-value\" className={cn('truncate', className)} {...props}>\n {formatRange(value, locale, placeholder ?? contextPlaceholder)}\n </span>\n )\n}\n\nfunction DateRangePickerContent({\n className,\n align = 'start',\n sideOffset = 8,\n children,\n ...props\n}: DateRangePickerContentProps) {\n const childArray = React.Children.toArray(children)\n const presets = childArray.filter(isDateRangePickerPresetsElement)\n const content = childArray.filter((child) => !isDateRangePickerPresetsElement(child))\n\n return (\n <PopoverContent\n align={align}\n sideOffset={sideOffset}\n className={(state) => cn('w-[calc(100vw-(--spacing(4)))] max-w-2xl p-2', resolveClassName(className, state))}\n {...props}\n >\n <div data-slot=\"date-range-picker-content\" className=\"grid gap-3 md:grid-cols-[10rem_minmax(0,1fr)]\">\n {presets}\n <div className=\"flex min-w-0 flex-col gap-3\">{content}</div>\n </div>\n </PopoverContent>\n )\n}\n\nfunction DateRangePickerPresets({\n className,\n presets = defaultPresetDefinitions,\n ...props\n}: DateRangePickerPresetsProps) {\n const { draft, setDraft } = useDateRangePicker()\n const todayRelativeValue = getRelativeDaysValue(draft, 'today')\n const yesterdayRelativeValue = getRelativeDaysValue(draft, 'yesterday')\n\n return (\n <div\n data-slot=\"date-range-picker-presets\"\n className={cn('hidden flex-col border-border pr-3 md:flex md:border-r', className)}\n {...props}\n >\n {presets.map((preset) => {\n const range = preset.getRange()\n const selected = isSameRange(draft, range)\n\n return (\n <DateRangePickerPreset key={preset.label} type=\"button\" selected={selected} onClick={() => setDraft(range)}>\n {preset.label}\n </DateRangePickerPreset>\n )\n })}\n\n <div className=\"my-3 flex flex-col gap-2\">\n <DateRangePickerRelativeField\n label=\"Dias até hoje\"\n value={todayRelativeValue}\n onValueChange={(days) => setDraft(getRelativeDaysRange(days, 'today'))}\n />\n <DateRangePickerRelativeField\n label=\"Dias até ontem\"\n value={yesterdayRelativeValue}\n onValueChange={(days) => setDraft(getRelativeDaysRange(days, 'yesterday'))}\n />\n </div>\n </div>\n )\n}\n\nfunction DateRangePickerPreset({ className, selected = false, ...props }: DateRangePickerPresetProps) {\n return (\n <button\n data-slot=\"date-range-picker-preset\"\n data-selected={selected}\n className={cn(\n 'flex h-8.5 w-full items-center border-l-3 border-border bg-transparent px-2 text-left text-sm text-foreground transition-colors outline-none',\n 'hover:border-primary hover:bg-primary-50 hover:text-primary-700 dark:hover:bg-primary-950 dark:hover:text-primary-300',\n 'focus-visible:border-primary focus-visible:ring-3 focus-visible:ring-ring/50',\n 'data-[selected=true]:border-primary data-[selected=true]:bg-primary-50 data-[selected=true]:text-primary-700 dark:data-[selected=true]:bg-primary-950 dark:data-[selected=true]:text-primary-300',\n className\n )}\n aria-pressed={selected}\n {...props}\n />\n )\n}\n\nfunction DateRangePickerRelativeField({\n label,\n value,\n onValueChange\n}: {\n label: string\n value: number | undefined\n onValueChange: (days: number) => void\n}) {\n const id = React.useId()\n const [inputValue, setInputValue] = React.useState(() => formatRelativeInputValue(value))\n\n React.useEffect(() => {\n setInputValue(formatRelativeInputValue(value))\n }, [value])\n\n return (\n <div className=\"flex items-center gap-2 text-sm text-foreground\">\n <Input\n id={id}\n type=\"number\"\n name={label}\n min={1}\n step={1}\n value={inputValue}\n className=\"h-7 w-9 rounded-md px-1 text-center [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none\"\n aria-label={label}\n onChange={(event) => {\n const nextValue = event.target.value\n setInputValue(nextValue)\n\n if (nextValue === '') return\n\n const days = parsePositiveInteger(nextValue)\n if (!days) return\n onValueChange(days)\n }}\n />\n <label htmlFor={id}>{label}</label>\n </div>\n )\n}\n\nfunction DateRangePickerCalendar({\n className,\n showOutsideDays = false,\n onMonthChange,\n ...props\n}: DateRangePickerCalendarProps) {\n const { draft, locale, month, setDraft, setMonth } = useDateRangePicker()\n\n return (\n <Calendar\n mode=\"range\"\n numberOfMonths={2}\n showOutsideDays={showOutsideDays}\n month={month}\n onMonthChange={(nextMonth) => {\n setMonth(nextMonth)\n onMonthChange?.(nextMonth)\n }}\n selected={draft}\n onSelect={setDraft}\n locale={locale}\n className={cn('mx-auto bg-transparent p-0', className)}\n {...props}\n />\n )\n}\n\nfunction DateRangePickerDateFields({ className, ...props }: DateRangePickerDateFieldsProps) {\n const { draft, setDraft } = useDateRangePicker()\n\n return (\n <div\n data-slot=\"date-range-picker-date-fields\"\n className={cn(\n 'pb-2 border-b flex justify-between gap-2 flex-wrap flex-col sm:flex-row sm:items-center',\n className\n )}\n {...props}\n >\n <Input\n type=\"date\"\n value={formatInputDate(draft?.from)}\n className=\"sm:w-max\"\n onChange={(event) => {\n if (event.target.value === '') {\n setDraft(undefined)\n return\n }\n\n const date = parseInputDate(event.target.value)\n if (!date) return\n setDraft(normalizeDraft({ from: date, to: draft?.to }))\n }}\n />\n <IconArrowRight className=\"size-4 text-primary hidden sm:block\" />\n <Input\n type=\"date\"\n value={formatInputDate(draft?.to)}\n className=\"sm:w-max\"\n onChange={(event) => {\n if (event.target.value === '') {\n setDraft(undefined)\n return\n }\n\n const date = parseInputDate(event.target.value)\n if (!date) return\n setDraft(normalizeDraft({ from: draft?.from, to: date }))\n }}\n />\n </div>\n )\n}\n\nfunction DateRangePickerActions({ className, children, ...props }: DateRangePickerActionsProps) {\n return (\n <div data-slot=\"date-range-picker-actions\" className={cn('flex items-center gap-2 mt-auto', className)} {...props}>\n {children ?? (\n <>\n <DateRangePickerReset />\n <DateRangePickerApply />\n </>\n )}\n </div>\n )\n}\n\nfunction DateRangePickerApply({ children = 'Aplicar', onClick, className, ...props }: DateRangePickerApplyProps) {\n const { apply } = useDateRangePicker()\n\n return (\n <Button\n size=\"sm\"\n className={cn('flex-1', className)}\n onClick={(event) => {\n onClick?.(event)\n if (!event.defaultPrevented) {\n apply()\n }\n }}\n {...props}\n >\n {children}\n </Button>\n )\n}\n\nfunction DateRangePickerReset({\n children = 'Resetar',\n onClick,\n variant = 'secondary',\n className,\n ...props\n}: DateRangePickerResetProps) {\n const { reset } = useDateRangePicker()\n\n return (\n <Button\n size=\"sm\"\n className={cn('flex-1', className)}\n variant={variant}\n onClick={(event) => {\n onClick?.(event)\n if (!event.defaultPrevented) {\n reset()\n }\n }}\n {...props}\n >\n {children}\n </Button>\n )\n}\n\nfunction useDateRangePicker() {\n const context = React.useContext(DateRangePickerContext)\n\n if (!context) {\n throw new Error('DateRangePicker components must be used within DateRangePicker.')\n }\n\n return context\n}\n\nfunction isDateRangePickerPresetsElement(child: React.ReactNode) {\n return React.isValidElement(child) && child.type === DateRangePickerPresets\n}\n\nfunction toDraft(range: DateRange | null | undefined) {\n return normalizeDraft(range ?? undefined)\n}\n\nfunction toValue(range: DateRange | undefined): DateRange | null {\n return normalizeDraft(range) ?? null\n}\n\nfunction getRangeMonth(range: DateRange | undefined) {\n return startOfDay(range?.from ?? range?.to ?? new Date())\n}\n\nfunction normalizeDraft(range: DateRange | undefined): DateRange | undefined {\n if (!range?.from && !range?.to) return undefined\n\n if (range.from && range.to && range.from > range.to) {\n return { from: startOfDay(range.to), to: startOfDay(range.from) }\n }\n\n return {\n from: range.from ? startOfDay(range.from) : undefined,\n to: range.to ? startOfDay(range.to) : undefined\n }\n}\n\nfunction formatRange(range: DateRange | null | undefined, locale: Partial<Locale> | undefined, placeholder: string) {\n if (!range?.from && !range?.to) return placeholder\n\n if (range.from && range.to) {\n return `${formatDisplayDate(range.from, locale)} - ${formatDisplayDate(range.to, locale)}`\n }\n\n return formatDisplayDate(range.from ?? range.to, locale)\n}\n\nfunction formatDisplayDate(date: Date | undefined, locale: Partial<Locale> | undefined) {\n if (!date) return ''\n\n return new Intl.DateTimeFormat(locale?.code ?? 'pt-BR', {\n day: '2-digit',\n month: '2-digit',\n year: 'numeric'\n }).format(date)\n}\n\nfunction formatInputDate(date: Date | undefined) {\n if (!date) return ''\n\n const year = date.getFullYear()\n const month = String(date.getMonth() + 1).padStart(2, '0')\n const day = String(date.getDate()).padStart(2, '0')\n\n return `${year}-${month}-${day}`\n}\n\nfunction parseInputDate(value: string) {\n if (!value) return undefined\n\n const match = /^(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})$/.exec(value)\n if (!match?.groups) return undefined\n\n const year = Number(match.groups.year)\n const month = Number(match.groups.month)\n const day = Number(match.groups.day)\n const date = new Date(year, month - 1, day)\n\n if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day) {\n return undefined\n }\n\n return date\n}\n\nfunction parsePositiveInteger(value: string) {\n if (!value) return undefined\n\n const days = Number(value)\n if (!Number.isInteger(days) || days < 1) return undefined\n\n return days\n}\n\nfunction formatRelativeInputValue(value: number | undefined) {\n return value ? String(value) : ''\n}\n\nfunction getRelativeDaysRange(days: number, target: 'today' | 'yesterday'): DateRange {\n const today = startOfDay(new Date())\n const targetDate = target === 'today' ? addDays(today, -1) : addDays(today, -2)\n\n return {\n from: addDays(targetDate, -days + 1),\n to: targetDate\n }\n}\n\nfunction getRelativeDaysValue(range: DateRange | undefined, target: 'today' | 'yesterday') {\n if (!range?.from || !range.to) return undefined\n\n const today = startOfDay(new Date())\n const targetDate = target === 'today' ? addDays(today, -1) : addDays(today, -2)\n if (!isSameDay(range.to, targetDate)) return undefined\n\n const days = differenceInCalendarDays(targetDate, startOfDay(range.from)) + 1\n return days > 0 ? days : undefined\n}\n\nfunction isSameRange(left: DateRange | undefined, right: DateRange | undefined) {\n return isSameDay(left?.from, right?.from) && isSameDay(left?.to, right?.to)\n}\n\nfunction isSameDay(left: Date | undefined, right: Date | undefined) {\n if (!left || !right) return left === right\n\n return (\n left.getFullYear() === right.getFullYear() &&\n left.getMonth() === right.getMonth() &&\n left.getDate() === right.getDate()\n )\n}\n\nfunction startOfDay(date: Date) {\n return new Date(date.getFullYear(), date.getMonth(), date.getDate())\n}\n\nfunction startOfWeek(date: Date) {\n const day = startOfDay(date)\n return addDays(day, -day.getDay())\n}\n\nfunction startOfMonth(date: Date) {\n return new Date(date.getFullYear(), date.getMonth(), 1)\n}\n\nfunction endOfMonth(date: Date) {\n return new Date(date.getFullYear(), date.getMonth() + 1, 0)\n}\n\nfunction differenceInCalendarDays(left: Date, right: Date) {\n const millisecondsPerDay = 24 * 60 * 60 * 1000\n return Math.round((startOfDay(left).getTime() - startOfDay(right).getTime()) / millisecondsPerDay)\n}\n\nfunction addDays(date: Date, amount: number) {\n const nextDate = startOfDay(date)\n nextDate.setDate(nextDate.getDate() + amount)\n return nextDate\n}\n\nexport {\n type DateRange,\n DateRangePicker,\n DateRangePickerActions,\n DateRangePickerApply,\n DateRangePickerCalendar,\n DateRangePickerContent,\n DateRangePickerDateFields,\n DateRangePickerPreset,\n DateRangePickerPresets,\n DateRangePickerReset,\n DateRangePickerTrigger,\n DateRangePickerValue\n}\n"],"mappings":"kfAwBA,MAAMC,EAAyBD,EAAM,cAAkD,IAAI,EAIrFE,EAA2B,CAC/B,CACE,MAAO,OACP,aAAgB,CACd,IAAMC,EAAQ,2BAAW,IAAI,IAAM,EACnC,MAAO,CAAE,KAAMA,EAAO,GAAIA,CAAM,CAClC,CACF,EACA,CACE,MAAO,QACP,aAAgB,CACd,IAAMC,EAAY,QAAQ,2BAAW,IAAI,IAAM,EAAG,EAAE,EACpD,MAAO,CAAE,KAAMA,EAAW,GAAIA,CAAU,CAC1C,CACF,EACA,CACE,MAAO,iBACP,aAAgB,CACd,IAAMD,EAAQ,2BAAW,IAAI,IAAM,EACnC,MAAO,CAAE,KAAM,QAAQA,EAAO,EAAE,EAAG,GAAIA,CAAM,CAC/C,CACF,EACA,CACE,MAAO,kBACP,aAAgB,CACd,IAAMA,EAAQ,2BAAW,IAAI,IAAM,EACnC,MAAO,CAAE,KAAM,QAAQA,EAAO,GAAG,EAAG,GAAIA,CAAM,CAChD,CACF,EACA,CACE,MAAO,kBACP,aAAgB,CACd,IAAMA,EAAQ,2BAAW,IAAI,IAAM,EACnC,MAAO,CAAE,KAAM,QAAQA,EAAO,GAAG,EAAG,GAAIA,CAAM,CAChD,CACF,EACA,CACE,MAAO,kBACP,aAAgB,CACd,IAAMA,EAAQ,2BAAW,IAAI,IAAM,EACnC,MA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AAY,CAC9B,OAAO,IAAI,KAAKA,EAAK,YAAY,EAAGA,EAAK,SAAS,EAAI,EAAG,CAAC,CAC5D,CAEA,SAAS,yBAAyB,EAAY,EAAa,CAEzD,OAAO,KAAK,OAAO,WAAWQ,CAAI,CAAC,CAAC,QAAQ,EAAI,WAAWC,CAAK,CAAC,CAAC,QAAQ,GAAK,KAAkB,CACnG,CAEA,SAAS,QAAQ,EAAY,EAAgB,CAC3C,IAAMC,EAAW,WAAWV,CAAI,EAEhC,OADAU,EAAS,QAAQA,EAAS,QAAQ,EAAIC,CAAM,EACrCD,CACT"}
@@ -1,42 +1,60 @@
1
1
  import { t as __name } from "../rolldown-runtime-BhWHdk3m.js";
2
- import { Dialog as Dialog$1 } from "radix-ui";
3
- import { VariantProps } from "class-variance-authority";
2
+ import { t as AsChildPrimitiveProps } from "../as-child-Dxg3Xo1G.js";
4
3
  import * as React from "react";
4
+ import { VariantProps } from "class-variance-authority";
5
+ import { Dialog as Dialog$1 } from "@base-ui/react/dialog";
5
6
  //#region src/components/dialog.d.ts
6
7
  declare const dialogContentVariants: (props?: ({
7
8
  size?: "2xl" | "3xl" | "full" | "lg" | "md" | "sm" | "xl" | null | undefined;
8
9
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
9
10
  type DialogSize = NonNullable<VariantProps<typeof dialogContentVariants>['size']>;
10
11
  export type DialogProps = React.ComponentProps<typeof Dialog$1.Root> & {
12
+ /**
13
+ * Dialog width. `full` fills the whole viewport.
14
+ * @default 'md'
15
+ */
11
16
  size?: DialogSize;
17
+ /**
18
+ * When `false`, clicking outside and pressing Esc no longer close the dialog. The close button and `DialogClose` still work.
19
+ * @default true
20
+ */
12
21
  dismissible?: boolean;
13
22
  };
14
- export type DialogTriggerProps = React.ComponentProps<typeof Dialog$1.Trigger>;
23
+ export type DialogTriggerProps = AsChildPrimitiveProps<typeof Dialog$1.Trigger>;
15
24
  export type DialogPortalProps = React.ComponentProps<typeof Dialog$1.Portal>;
16
- export type DialogCloseProps = React.ComponentProps<typeof Dialog$1.Close>;
17
- export type DialogOverlayProps = React.ComponentProps<typeof Dialog$1.Overlay>;
18
- export type DialogContentProps = React.ComponentProps<typeof Dialog$1.Content> & {
25
+ export type DialogCloseProps = AsChildPrimitiveProps<typeof Dialog$1.Close>;
26
+ export type DialogOverlayProps = AsChildPrimitiveProps<typeof Dialog$1.Backdrop>;
27
+ export type DialogContentProps = AsChildPrimitiveProps<typeof Dialog$1.Popup> & Pick<DialogPortalProps, 'keepMounted'> & {
28
+ /**
29
+ * Shows the X button in the top-right corner.
30
+ * @default true
31
+ */
19
32
  showCloseButton?: boolean;
33
+ /** Ref to the overlay element rendered behind the dialog. */
20
34
  overlayRef?: React.Ref<HTMLDivElement>;
21
35
  };
22
36
  export type DialogHeaderProps = React.ComponentProps<'div'>;
23
37
  export type DialogBodyProps = React.ComponentProps<'div'>;
24
38
  export type DialogFooterProps = React.ComponentProps<'div'> & {
39
+ /**
40
+ * Adds an outline "Close" button after the footer actions.
41
+ * @default false
42
+ */
25
43
  showCloseButton?: boolean;
26
44
  };
27
- export type DialogTitleProps = React.ComponentProps<typeof Dialog$1.Title>;
28
- export type DialogDescriptionProps = React.ComponentProps<typeof Dialog$1.Description>;
29
- declare function Dialog({ size, dismissible, ...props }: DialogProps): React.JSX.Element;
30
- declare function DialogTrigger({ ...props }: React.ComponentProps<typeof Dialog$1.Trigger>): React.JSX.Element;
45
+ export type DialogTitleProps = AsChildPrimitiveProps<typeof Dialog$1.Title>;
46
+ export type DialogDescriptionProps = AsChildPrimitiveProps<typeof Dialog$1.Description>;
47
+ declare function Dialog({ size, dismissible, disablePointerDismissal, onOpenChange, ...props }: DialogProps): React.JSX.Element;
48
+ declare function DialogTrigger({ asChild, children, ...props }: DialogTriggerProps): React.JSX.Element;
31
49
  declare function DialogPortal({ ...props }: DialogPortalProps): React.JSX.Element;
32
- declare function DialogClose({ ...props }: React.ComponentProps<typeof Dialog$1.Close>): React.JSX.Element;
33
- declare function DialogOverlay({ className, onClick, ...props }: DialogOverlayProps): React.JSX.Element;
34
- declare function DialogContent({ className, children, showCloseButton, overlayRef, ...props }: DialogContentProps): React.JSX.Element;
50
+ declare function DialogClose({ asChild, children, ...props }: DialogCloseProps): React.JSX.Element;
51
+ declare function DialogOverlay({ className, onClick, asChild, children, ...props }: DialogOverlayProps): React.JSX.Element;
52
+ declare function DialogContent({ className, children, showCloseButton, overlayRef, keepMounted, asChild, ...props }: DialogContentProps): React.JSX.Element;
35
53
  declare function DialogHeader({ className, ...props }: DialogHeaderProps): React.JSX.Element;
36
54
  declare function DialogBody({ className, ...props }: DialogBodyProps): React.JSX.Element;
37
55
  declare function DialogFooter({ className, showCloseButton, children, ...props }: DialogFooterProps): React.JSX.Element;
38
- declare function DialogTitle({ className, ...props }: DialogTitleProps): React.JSX.Element;
39
- declare function DialogDescription({ className, ...props }: DialogDescriptionProps): React.JSX.Element;
56
+ declare function DialogTitle({ className, asChild, children, ...props }: DialogTitleProps): React.JSX.Element;
57
+ declare function DialogDescription({ className, asChild, children, ...props }: DialogDescriptionProps): React.JSX.Element;
40
58
  //#endregion
41
59
  export { Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger };
42
60
  //# sourceMappingURL=dialog.d.ts.map
@@ -1,2 +1,2 @@
1
- import"../rolldown-runtime-BhWHdk3m.js";import{cn as e,stopPropagationHandler as t}from"../lib/utils.js";import{Button as n}from"./button.js";import{IconX as r}from"@tabler/icons-react";import{Dialog as i}from"radix-ui";import{jsx as a,jsxs as o}from"react/jsx-runtime";import{cva as s}from"class-variance-authority";import*as c from"react";const l=s([`bg-background ring-foreground/10 fixed top-1/2 left-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2 outline-none`,`flex flex-col gap-4 rounded-xl p-4 text-sm ring-1 duration-100`,`max-w-[calc(100%-2rem)] max-h-[calc(100dvh-2rem)] overflow-hidden`,`data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95`],{variants:{size:{sm:`sm:max-w-sm`,md:`sm:max-w-md`,lg:`sm:max-w-lg`,xl:`sm:max-w-xl`,"2xl":`sm:max-w-2xl`,"3xl":`sm:max-w-3xl`,full:`w-screen h-screen max-w-none max-h-screen rounded-none sm:max-w-none`}},defaultVariants:{size:`md`}}),u=c.createContext({size:`sm`,dismissible:!0});function Dialog({size:e=`sm`,dismissible:t=!0,...n}){let r=c.useMemo(()=>({size:e,dismissible:t}),[e,t]);return a(u.Provider,{value:r,children:a(i.Root,{"data-slot":`dialog`,...n})})}function DialogTrigger({...e}){return a(i.Trigger,{"data-slot":`dialog-trigger`,...e})}function DialogPortal({...e}){return a(i.Portal,{"data-slot":`dialog-portal`,...e})}function DialogClose({...e}){return a(i.Close,{"data-slot":`dialog-close`,...e})}function DialogOverlay({className:n,onClick:r,...o}){return a(i.Overlay,{"data-slot":`dialog-overlay`,className:e(`bg-black/10 fixed inset-0 isolate z-50`,`data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0`,`duration-100 supports-backdrop-filter:backdrop-blur-xs`,n),onClick:t(r),...o})}function DialogContent({className:s,children:d,showCloseButton:f=!0,overlayRef:p,...m}){let{size:h,dismissible:g}=c.useContext(u);return o(DialogPortal,{children:[a(DialogOverlay,{ref:p}),o(i.Content,{"data-slot":`dialog-content`,className:e(l({size:h}),s),...m,onEscapeKeyDown:e=>{g||e.preventDefault(),m.onEscapeKeyDown?.(e)},onInteractOutside:e=>{g||e.preventDefault(),m.onInteractOutside?.(e)},onClick:t(m.onClick),onSubmit:t(m.onSubmit),children:[d,f&&a(i.Close,{"data-slot":`dialog-close`,asChild:!0,children:o(n,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`,children:[a(r,{}),a(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function DialogHeader({className:t,...n}){return a(`div`,{"data-slot":`dialog-header`,className:e(`gap-2 flex flex-col shrink-0`,t),...n})}function DialogBody({className:t,...n}){return a(`div`,{"data-slot":`dialog-body`,className:e(`-mx-4 px-4 flex-1 overflow-y-auto`,t),...n})}function DialogFooter({className:t,showCloseButton:r=!1,children:s,...c}){return o(`div`,{"data-slot":`dialog-footer`,className:e(`bg-muted/50 -mx-4 -mb-4 rounded-b-xl border-t p-4 shrink-0`,`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,t),...c,children:[s,r&&a(i.Close,{asChild:!0,children:a(n,{variant:`outline`,children:`Close`})})]})}function DialogTitle({className:t,...n}){return a(i.Title,{"data-slot":`dialog-title`,className:e(`text-base leading-none font-medium`,t),...n})}function DialogDescription({className:t,...n}){return a(i.Description,{"data-slot":`dialog-description`,className:e(`text-muted-foreground text-sm`,`*:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,t),...n})}export{Dialog,DialogBody,DialogClose,DialogContent,DialogDescription,DialogFooter,DialogHeader,DialogOverlay,DialogPortal,DialogTitle,DialogTrigger};
1
+ import"../rolldown-runtime-BhWHdk3m.js";import{toAsChildRenderProps as e}from"../lib/as-child.js";import{cn as t,stopPropagationHandler as n}from"../lib/utils.js";import{t as r}from"../resolve-class-name-BurP8ngI.js";import{Button as i}from"./button.js";import{IconX as a}from"@tabler/icons-react";import*as o from"react";import{jsx as s,jsxs as c}from"react/jsx-runtime";import{cva as l}from"class-variance-authority";import{Dialog as u}from"@base-ui/react/dialog";const d=l([`bg-background ring-foreground/10 fixed top-1/2 left-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2 outline-none`,`flex flex-col gap-4 rounded-xl p-4 text-sm ring-1 duration-100`,`max-w-[calc(100%-2rem)] max-h-[calc(100dvh-2rem)] overflow-hidden`,`data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95`],{variants:{size:{sm:`sm:max-w-sm`,md:`sm:max-w-md`,lg:`sm:max-w-lg`,xl:`sm:max-w-xl`,"2xl":`sm:max-w-2xl`,"3xl":`sm:max-w-3xl`,full:`w-screen h-screen max-w-none max-h-screen rounded-none sm:max-w-none`}},defaultVariants:{size:`md`}}),f=o.createContext({size:`md`});function Dialog({size:e=`md`,dismissible:t=!0,disablePointerDismissal:n,onOpenChange:r,...i}){let a=o.useMemo(()=>({size:e}),[e]);return/* @__PURE__ */ s(f.Provider,{value:a,children:/* @__PURE__ */ s(u.Root,{"data-slot":`dialog`,disablePointerDismissal:!t||n,onOpenChange:(e,n)=>{!t&&n.reason===`escape-key`?n.cancel():r?.(e,n)},...i})})}function DialogTrigger({asChild:t,children:n,...r}){return/* @__PURE__ */ s(u.Trigger,{"data-slot":`dialog-trigger`,...r,...e(t,n)})}function DialogPortal({...e}){return/* @__PURE__ */ s(u.Portal,{"data-slot":`dialog-portal`,...e})}function DialogClose({asChild:t,children:n,...r}){return/* @__PURE__ */ s(u.Close,{"data-slot":`dialog-close`,...r,...e(t,n)})}function DialogOverlay({className:i,onClick:a,asChild:o,children:c,...l}){return/* @__PURE__ */ s(u.Backdrop,{"data-slot":`dialog-overlay`,className:e=>t(`bg-black/10 fixed inset-0 isolate z-50`,`data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0`,`duration-100 supports-backdrop-filter:backdrop-blur-xs`,r(i,e)),onClick:n(a),...l,...e(o,c)})}function DialogContent({className:l,children:p,showCloseButton:m=!0,overlayRef:h,keepMounted:g,asChild:_,...v}){let{size:y}=o.useContext(f);return/* @__PURE__ */ c(DialogPortal,{keepMounted:g,children:[/* @__PURE__ */ s(DialogOverlay,{ref:h}),/* @__PURE__ */ c(u.Popup,{"data-slot":`dialog-content`,className:e=>t(d({size:y}),r(l,e)),...v,...e(_,p),onClick:n(v.onClick),onSubmit:n(v.onSubmit),children:[!_&&p,m&&!_&&/* @__PURE__ */ c(u.Close,{"data-slot":`dialog-close`,render:/* @__PURE__ */ s(i,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`}),children:[/* @__PURE__ */ s(a,{}),/* @__PURE__ */ s(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function DialogHeader({className:e,...n}){return/* @__PURE__ */ s(`div`,{"data-slot":`dialog-header`,className:t(`gap-2 flex flex-col shrink-0`,e),...n})}function DialogBody({className:e,...n}){return/* @__PURE__ */ s(`div`,{"data-slot":`dialog-body`,className:t(`-mx-4 px-4 flex-1 overflow-y-auto`,e),...n})}function DialogFooter({className:e,showCloseButton:n=!1,children:r,...a}){return/* @__PURE__ */ c(`div`,{"data-slot":`dialog-footer`,className:t(`bg-muted/50 -mx-4 -mb-4 rounded-b-xl border-t p-4 shrink-0`,`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...a,children:[r,n&&/* @__PURE__ */ s(u.Close,{render:/* @__PURE__ */ s(i,{variant:`outline`}),children:`Close`})]})}function DialogTitle({className:n,asChild:i,children:a,...o}){return/* @__PURE__ */ s(u.Title,{"data-slot":`dialog-title`,className:e=>t(`text-base leading-none font-medium`,r(n,e)),...o,...e(i,a)})}function DialogDescription({className:n,asChild:i,children:a,...o}){return/* @__PURE__ */ s(u.Description,{"data-slot":`dialog-description`,className:e=>t(`text-muted-foreground text-sm`,`*:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,r(n,e)),...o,...e(i,a)})}export{Dialog,DialogBody,DialogClose,DialogContent,DialogDescription,DialogFooter,DialogHeader,DialogOverlay,DialogPortal,DialogTitle,DialogTrigger};
2
2
  //# sourceMappingURL=dialog.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dialog.js","names":["DialogPrimitive"],"sources":["../../src/components/dialog.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { IconX } from '@tabler/icons-react'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { Dialog as DialogPrimitive } from 'radix-ui'\n\nimport { cn, stopPropagationHandler } from '../lib/utils'\nimport { Button } from './button'\n\nconst dialogContentVariants = cva(\n [\n 'bg-background ring-foreground/10 fixed top-1/2 left-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2 outline-none',\n 'flex flex-col gap-4 rounded-xl p-4 text-sm ring-1 duration-100',\n 'max-w-[calc(100%-2rem)] max-h-[calc(100dvh-2rem)] overflow-hidden',\n 'data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95'\n ],\n {\n variants: {\n size: {\n sm: 'sm:max-w-sm',\n md: 'sm:max-w-md',\n lg: 'sm:max-w-lg',\n xl: 'sm:max-w-xl',\n '2xl': 'sm:max-w-2xl',\n '3xl': 'sm:max-w-3xl',\n full: 'w-screen h-screen max-w-none max-h-screen rounded-none sm:max-w-none'\n }\n },\n defaultVariants: {\n size: 'md'\n }\n }\n)\n\ntype DialogSize = NonNullable<VariantProps<typeof dialogContentVariants>['size']>\ntype DialogContextValue = { size: DialogSize; dismissible: boolean }\nconst DialogContext = React.createContext<DialogContextValue>({ size: 'sm', dismissible: true })\n\nexport type DialogProps = React.ComponentProps<typeof DialogPrimitive.Root> & {\n size?: DialogSize\n dismissible?: boolean\n}\nexport type DialogTriggerProps = React.ComponentProps<typeof DialogPrimitive.Trigger>\nexport type DialogPortalProps = React.ComponentProps<typeof DialogPrimitive.Portal>\nexport type DialogCloseProps = React.ComponentProps<typeof DialogPrimitive.Close>\nexport type DialogOverlayProps = React.ComponentProps<typeof DialogPrimitive.Overlay>\nexport type DialogContentProps = React.ComponentProps<typeof DialogPrimitive.Content> & {\n showCloseButton?: boolean\n overlayRef?: React.Ref<HTMLDivElement>\n}\nexport type DialogHeaderProps = React.ComponentProps<'div'>\nexport type DialogBodyProps = React.ComponentProps<'div'>\nexport type DialogFooterProps = React.ComponentProps<'div'> & { showCloseButton?: boolean }\nexport type DialogTitleProps = React.ComponentProps<typeof DialogPrimitive.Title>\nexport type DialogDescriptionProps = React.ComponentProps<typeof DialogPrimitive.Description>\n\nfunction Dialog({ size = 'sm', dismissible = true, ...props }: DialogProps) {\n const contextValue = React.useMemo<DialogContextValue>(() => ({ size, dismissible }), [size, dismissible])\n\n return (\n <DialogContext.Provider value={contextValue}>\n <DialogPrimitive.Root data-slot=\"dialog\" {...props} />\n </DialogContext.Provider>\n )\n}\n\nfunction DialogTrigger({ ...props }: React.ComponentProps<typeof DialogPrimitive.Trigger>) {\n return <DialogPrimitive.Trigger data-slot=\"dialog-trigger\" {...props} />\n}\n\nfunction DialogPortal({ ...props }: DialogPortalProps) {\n return <DialogPrimitive.Portal data-slot=\"dialog-portal\" {...props} />\n}\n\nfunction DialogClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Close>) {\n return <DialogPrimitive.Close data-slot=\"dialog-close\" {...props} />\n}\n\nfunction DialogOverlay({ className, onClick, ...props }: DialogOverlayProps) {\n return (\n <DialogPrimitive.Overlay\n data-slot=\"dialog-overlay\"\n className={cn(\n 'bg-black/10 fixed inset-0 isolate z-50',\n 'data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0',\n 'duration-100 supports-backdrop-filter:backdrop-blur-xs',\n className\n )}\n onClick={stopPropagationHandler(onClick)}\n {...props}\n />\n )\n}\n\nfunction DialogContent({ className, children, showCloseButton = true, overlayRef, ...props }: DialogContentProps) {\n const { size, dismissible } = React.useContext(DialogContext)\n\n return (\n <DialogPortal>\n <DialogOverlay ref={overlayRef} />\n <DialogPrimitive.Content\n data-slot=\"dialog-content\"\n className={cn(dialogContentVariants({ size }), className)}\n {...props}\n onEscapeKeyDown={(event) => {\n if (!dismissible) event.preventDefault()\n props.onEscapeKeyDown?.(event)\n }}\n onInteractOutside={(event) => {\n if (!dismissible) event.preventDefault()\n props.onInteractOutside?.(event)\n }}\n // React events bubble through the fiber tree, not the DOM, so a portaled Radix Content still\n // reaches any ancestor's onClick/onSubmit even though it renders outside it in the DOM.\n onClick={stopPropagationHandler(props.onClick)}\n onSubmit={stopPropagationHandler(props.onSubmit)}\n >\n {children}\n {showCloseButton && (\n <DialogPrimitive.Close data-slot=\"dialog-close\" asChild>\n <Button variant=\"ghost\" className=\"absolute top-2 right-2\" size=\"icon-sm\">\n <IconX />\n <span className=\"sr-only\">Close</span>\n </Button>\n </DialogPrimitive.Close>\n )}\n </DialogPrimitive.Content>\n </DialogPortal>\n )\n}\n\nfunction DialogHeader({ className, ...props }: DialogHeaderProps) {\n return <div data-slot=\"dialog-header\" className={cn('gap-2 flex flex-col shrink-0', className)} {...props} />\n}\n\nfunction DialogBody({ className, ...props }: DialogBodyProps) {\n return <div data-slot=\"dialog-body\" className={cn('-mx-4 px-4 flex-1 overflow-y-auto', className)} {...props} />\n}\n\nfunction DialogFooter({ className, showCloseButton = false, children, ...props }: DialogFooterProps) {\n return (\n <div\n data-slot=\"dialog-footer\"\n className={cn(\n 'bg-muted/50 -mx-4 -mb-4 rounded-b-xl border-t p-4 shrink-0',\n 'flex flex-col-reverse gap-2 sm:flex-row sm:justify-end',\n className\n )}\n {...props}\n >\n {children}\n {showCloseButton && (\n <DialogPrimitive.Close asChild>\n <Button variant=\"outline\">Close</Button>\n </DialogPrimitive.Close>\n )}\n </div>\n )\n}\n\nfunction DialogTitle({ className, ...props }: DialogTitleProps) {\n return (\n <DialogPrimitive.Title\n data-slot=\"dialog-title\"\n className={cn('text-base leading-none font-medium', className)}\n {...props}\n />\n )\n}\n\nfunction DialogDescription({ className, ...props }: DialogDescriptionProps) {\n return (\n <DialogPrimitive.Description\n data-slot=\"dialog-description\"\n className={cn(\n 'text-muted-foreground text-sm',\n '*:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground',\n className\n )}\n {...props}\n />\n )\n}\n\nexport {\n Dialog,\n DialogBody,\n DialogClose,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogOverlay,\n DialogPortal,\n DialogTitle,\n DialogTrigger\n}\n"],"mappings":"qVASA,MAAM,EAAwB,EAC5B,CACE,qHACA,iEACA,oEACA,sIACF,EACA,CACE,SAAU,CACR,KAAM,CACJ,GAAI,cACJ,GAAI,cACJ,GAAI,cACJ,GAAI,c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sC,CAAS,EAC7D,GAAI,CACL,CAAA,CAEL,CAEA,SAAS,kBAAkB,CAAE,YAAW,GAAG,GAAiC,CAC1E,OACE,EAACA,EAAgB,YAAjB,CACE,YAAU,qBACV,UAAW,EACT,gCACA,uEACA,CACF,EACA,GAAI,CACL,CAAA,CAEL"}
1
+ {"version":3,"file":"dialog.js","names":["DialogPrimitive","resolveClassName","React","Dialog$1","dialogContentVariants","cva","DialogContext","props","contextValue","size","dismissible","disablePointerDismissal","eventDetails","onOpenChange","open","toAsChildRenderProps","asChild","children","cn","className","state","stopPropagationHandler","onClick","overlayRef","showCloseButton","Button","IconX"],"sources":["../../src/components/dialog.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { Dialog as DialogPrimitive } from '@base-ui/react/dialog'\nimport { IconX } from '@tabler/icons-react'\nimport { cva, type VariantProps } from 'class-variance-authority'\n\nimport { type AsChildPrimitiveProps, toAsChildRenderProps } from '../lib/as-child'\nimport { cn, stopPropagationHandler } from '../lib/utils'\nimport { resolveClassName } from '../utils/resolve-class-name'\nimport { Button } from './button'\n\nconst dialogContentVariants = cva(\n [\n 'bg-background ring-foreground/10 fixed top-1/2 left-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2 outline-none',\n 'flex flex-col gap-4 rounded-xl p-4 text-sm ring-1 duration-100',\n 'max-w-[calc(100%-2rem)] max-h-[calc(100dvh-2rem)] overflow-hidden',\n 'data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95'\n ],\n {\n variants: {\n size: {\n sm: 'sm:max-w-sm',\n md: 'sm:max-w-md',\n lg: 'sm:max-w-lg',\n xl: 'sm:max-w-xl',\n '2xl': 'sm:max-w-2xl',\n '3xl': 'sm:max-w-3xl',\n full: 'w-screen h-screen max-w-none max-h-screen rounded-none sm:max-w-none'\n }\n },\n defaultVariants: {\n size: 'md'\n }\n }\n)\n\ntype DialogSize = NonNullable<VariantProps<typeof dialogContentVariants>['size']>\ntype DialogContextValue = { size: DialogSize }\nconst DialogContext = React.createContext<DialogContextValue>({ size: 'md' })\n\nexport type DialogProps = React.ComponentProps<typeof DialogPrimitive.Root> & {\n /**\n * Dialog width. `full` fills the whole viewport.\n * @default 'md'\n */\n size?: DialogSize\n /**\n * When `false`, clicking outside and pressing Esc no longer close the dialog. The close button and `DialogClose` still work.\n * @default true\n */\n dismissible?: boolean\n}\nexport type DialogTriggerProps = AsChildPrimitiveProps<typeof DialogPrimitive.Trigger>\nexport type DialogPortalProps = React.ComponentProps<typeof DialogPrimitive.Portal>\nexport type DialogCloseProps = AsChildPrimitiveProps<typeof DialogPrimitive.Close>\nexport type DialogOverlayProps = AsChildPrimitiveProps<typeof DialogPrimitive.Backdrop>\nexport type DialogContentProps = AsChildPrimitiveProps<typeof DialogPrimitive.Popup> &\n Pick<DialogPortalProps, 'keepMounted'> & {\n /**\n * Shows the X button in the top-right corner.\n * @default true\n */\n showCloseButton?: boolean\n /** Ref to the overlay element rendered behind the dialog. */\n overlayRef?: React.Ref<HTMLDivElement>\n }\nexport type DialogHeaderProps = React.ComponentProps<'div'>\nexport type DialogBodyProps = React.ComponentProps<'div'>\nexport type DialogFooterProps = React.ComponentProps<'div'> & {\n /**\n * Adds an outline \"Close\" button after the footer actions.\n * @default false\n */\n showCloseButton?: boolean\n}\nexport type DialogTitleProps = AsChildPrimitiveProps<typeof DialogPrimitive.Title>\nexport type DialogDescriptionProps = AsChildPrimitiveProps<typeof DialogPrimitive.Description>\n\nfunction Dialog({ size = 'md', dismissible = true, disablePointerDismissal, onOpenChange, ...props }: DialogProps) {\n const contextValue = React.useMemo<DialogContextValue>(() => ({ size }), [size])\n\n return (\n <DialogContext.Provider value={contextValue}>\n <DialogPrimitive.Root\n data-slot=\"dialog\"\n disablePointerDismissal={!dismissible || disablePointerDismissal}\n onOpenChange={(open, eventDetails) => {\n if (!dismissible && eventDetails.reason === 'escape-key') {\n eventDetails.cancel()\n return\n }\n onOpenChange?.(open, eventDetails)\n }}\n {...props}\n />\n </DialogContext.Provider>\n )\n}\n\nfunction DialogTrigger({ asChild, children, ...props }: DialogTriggerProps) {\n return <DialogPrimitive.Trigger data-slot=\"dialog-trigger\" {...props} {...toAsChildRenderProps(asChild, children)} />\n}\n\nfunction DialogPortal({ ...props }: DialogPortalProps) {\n return <DialogPrimitive.Portal data-slot=\"dialog-portal\" {...props} />\n}\n\nfunction DialogClose({ asChild, children, ...props }: DialogCloseProps) {\n return <DialogPrimitive.Close data-slot=\"dialog-close\" {...props} {...toAsChildRenderProps(asChild, children)} />\n}\n\nfunction DialogOverlay({ className, onClick, asChild, children, ...props }: DialogOverlayProps) {\n return (\n <DialogPrimitive.Backdrop\n data-slot=\"dialog-overlay\"\n className={(state) =>\n cn(\n 'bg-black/10 fixed inset-0 isolate z-50',\n 'data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0',\n 'duration-100 supports-backdrop-filter:backdrop-blur-xs',\n resolveClassName(className, state)\n )\n }\n onClick={stopPropagationHandler(onClick)}\n {...props}\n {...toAsChildRenderProps(asChild, children)}\n />\n )\n}\n\nfunction DialogContent({\n className,\n children,\n showCloseButton = true,\n overlayRef,\n keepMounted,\n asChild,\n ...props\n}: DialogContentProps) {\n const { size } = React.useContext(DialogContext)\n\n return (\n <DialogPortal keepMounted={keepMounted}>\n <DialogOverlay ref={overlayRef} />\n <DialogPrimitive.Popup\n data-slot=\"dialog-content\"\n className={(state) => cn(dialogContentVariants({ size }), resolveClassName(className, state))}\n {...props}\n {...toAsChildRenderProps(asChild, children)}\n // React events bubble through the fiber tree, not the DOM, so a portaled Popup still\n // reaches any ancestor's onClick/onSubmit even though it renders outside it in the DOM.\n onClick={stopPropagationHandler(props.onClick)}\n onSubmit={stopPropagationHandler(props.onSubmit)}\n >\n {!asChild && children}\n {showCloseButton && !asChild && (\n <DialogPrimitive.Close\n data-slot=\"dialog-close\"\n render={<Button variant=\"ghost\" className=\"absolute top-2 right-2\" size=\"icon-sm\" />}\n >\n <IconX />\n <span className=\"sr-only\">Close</span>\n </DialogPrimitive.Close>\n )}\n </DialogPrimitive.Popup>\n </DialogPortal>\n )\n}\n\nfunction DialogHeader({ className, ...props }: DialogHeaderProps) {\n return <div data-slot=\"dialog-header\" className={cn('gap-2 flex flex-col shrink-0', className)} {...props} />\n}\n\nfunction DialogBody({ className, ...props }: DialogBodyProps) {\n return <div data-slot=\"dialog-body\" className={cn('-mx-4 px-4 flex-1 overflow-y-auto', className)} {...props} />\n}\n\nfunction DialogFooter({ className, showCloseButton = false, children, ...props }: DialogFooterProps) {\n return (\n <div\n data-slot=\"dialog-footer\"\n className={cn(\n 'bg-muted/50 -mx-4 -mb-4 rounded-b-xl border-t p-4 shrink-0',\n 'flex flex-col-reverse gap-2 sm:flex-row sm:justify-end',\n className\n )}\n {...props}\n >\n {children}\n {showCloseButton && <DialogPrimitive.Close render={<Button variant=\"outline\" />}>Close</DialogPrimitive.Close>}\n </div>\n )\n}\n\nfunction DialogTitle({ className, asChild, children, ...props }: DialogTitleProps) {\n return (\n <DialogPrimitive.Title\n data-slot=\"dialog-title\"\n className={(state) => cn('text-base leading-none font-medium', resolveClassName(className, state))}\n {...props}\n {...toAsChildRenderProps(asChild, children)}\n />\n )\n}\n\nfunction DialogDescription({ className, asChild, children, ...props }: DialogDescriptionProps) {\n return (\n <DialogPrimitive.Description\n data-slot=\"dialog-description\"\n className={(state) =>\n cn(\n 'text-muted-foreground text-sm',\n '*:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground',\n resolveClassName(className, state)\n )\n }\n {...props}\n {...toAsChildRenderProps(asChild, children)}\n />\n )\n}\n\nexport {\n Dialog,\n DialogBody,\n DialogClose,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogOverlay,\n DialogPortal,\n DialogTitle,\n DialogTrigger\n}\n"],"mappings":"kdAWA,MAAMI,EAAwBC,EAC5B,CACE,qHACA,iEACA,oEACA,sIACF,EACA,CACE,SAAU,CACR,KAA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O,WAAU,GAAGA,GAA4B,CACnG,MACE,kBAAC,MAAD,CACE,YAAU,gBACV,UAAWW,EACT,6DACA,yDACAC,CACF,EACA,GAAIZ,EAPN,SAAA,CASGU,EACAO,GAAmB,kBAACxB,EAAgB,MAAjB,CAAuB,OAAQ,kBAACyB,EAAD,CAAQ,QAAQ,SAAW,CAAA,EAAG,SAAA,OAA4B,CAAA,CAC1G,GAET,CAEA,SAAS,YAAY,CAAE,YAAW,UAAS,WAAU,GAAGlB,GAA2B,CACjF,MACE,kBAACP,EAAgB,MAAjB,CACE,YAAU,eACV,UAAY,GAAUkB,EAAG,qCAAsCjB,EAAiBkB,EAAWC,CAAK,CAAC,EACjG,GAAIb,EACJ,GAAIQ,EAAqBC,EAASC,CAAQ,CAC3C,CAAA,CAEL,CAEA,SAAS,kBAAkB,CAAE,YAAW,UAAS,WAAU,GAAGV,GAAiC,CAC7F,MACE,kBAACP,EAAgB,YAAjB,CACE,YAAU,qBACV,UAAY,GACVkB,EACE,gCACA,uEACAjB,EAAiBkB,EAAWC,CAAK,CACnC,EAEF,GAAIb,EACJ,GAAIQ,EAAqBC,EAASC,CAAQ,CAC3C,CAAA,CAEL"}
@@ -0,0 +1,7 @@
1
+ import { t as __name } from "../rolldown-runtime-BhWHdk3m.js";
2
+ import { DirectionProvider, TextDirection, useDirection } from "@base-ui/react/direction-provider";
3
+ //#region src/components/direction.d.ts
4
+ export type DirectionProviderProps = DirectionProvider.Props;
5
+ //#endregion
6
+ export { DirectionProvider, type TextDirection, useDirection };
7
+ //# sourceMappingURL=direction.d.ts.map
@@ -0,0 +1 @@
1
+ export{DirectionProvider,useDirection}from"@base-ui/react/direction-provider";
@@ -3,8 +3,20 @@ import { PieChartProps } from "./pie-chart.js";
3
3
  import * as React from "react";
4
4
  //#region src/components/donut-chart.d.ts
5
5
  export type DonutChartProps = PieChartProps & {
6
+ /**
7
+ * Ring width as a fraction of the radius.
8
+ * @default 0.35
9
+ */
6
10
  thickness?: number;
11
+ /**
12
+ * Shows the sum of the values in the center.
13
+ * @default false
14
+ */
7
15
  withTotal?: boolean;
16
+ /**
17
+ * Label below the total.
18
+ * @default 'Total'
19
+ */
8
20
  totalLabel?: React.ReactNode;
9
21
  };
10
22
  declare function DonutChart({ className, thickness, outerRadius, withTotal, totalLabel, data, ...props }: DonutChartProps): React.JSX.Element;
@@ -1,2 +1,2 @@
1
- import"../rolldown-runtime-BhWHdk3m.js";import{cn as e}from"../lib/utils.js";import{PieChartBase as t}from"./pie-chart.js";import{jsx as n,jsxs as r}from"react/jsx-runtime";import*as i from"react";import{Label as a}from"recharts";function DonutChart({className:o,thickness:s=.35,outerRadius:c=`80%`,withTotal:l=!1,totalLabel:u=`Total`,data:d,...f}){let p=i.useMemo(()=>{let e=Math.min(Math.max(1-s,0),1);if(typeof c==`number`)return c*e;let t=/^(\d+(?:\.\d+)?)%$/.exec(c);return t?`${Number(t[1])*e}%`:c},[c,s]),m=i.useMemo(()=>d.reduce((e,t)=>e+t.value,0),[d]);return n(t,{dataSlot:`donut-chart`,className:e(o),data:d,outerRadius:c,innerRadius:p,centerSlot:l?n(a,{position:`center`,content:({viewBox:e})=>!e||!(`cx`in e)||!(`cy`in e)?null:r(`text`,{x:e.cx,y:e.cy,textAnchor:`middle`,dominantBaseline:`middle`,children:[n(`tspan`,{x:e.cx,y:e.cy,className:`fill-foreground font-medium text-2xl tabular-nums`,children:m.toLocaleString()}),n(`tspan`,{x:e.cx,y:(e.cy??0)+20,className:`fill-muted-foreground text-xs`,children:u})]})}):null,...f})}export{DonutChart};
1
+ import"../rolldown-runtime-BhWHdk3m.js";import{cn as e}from"../lib/utils.js";import{PieChartBase as t}from"./pie-chart.js";import*as n from"react";import{jsx as r,jsxs as i}from"react/jsx-runtime";import{Label as a}from"recharts";function DonutChart({className:o,thickness:s=.35,outerRadius:c=`80%`,withTotal:l=!1,totalLabel:u=`Total`,data:d,...f}){let p=n.useMemo(()=>{let e=Math.min(Math.max(1-s,0),1);if(typeof c==`number`)return c*e;let t=/^(\d+(?:\.\d+)?)%$/.exec(c);return t?`${Number(t[1])*e}%`:c},[c,s]),m=n.useMemo(()=>d.reduce((e,t)=>e+t.value,0),[d]);return/* @__PURE__ */ r(t,{dataSlot:`donut-chart`,className:e(o),data:d,outerRadius:c,innerRadius:p,centerSlot:l?/* @__PURE__ */ r(a,{content:({viewBox:e})=>!e||!(`cx`in e)||!(`cy`in e)?null:/* @__PURE__ */ i(`text`,{x:e.cx,y:e.cy,textAnchor:`middle`,dominantBaseline:`middle`,children:[/* @__PURE__ */ r(`tspan`,{x:e.cx,y:e.cy,className:`fill-foreground font-medium text-2xl tabular-nums`,children:m.toLocaleString()}),/* @__PURE__ */ r(`tspan`,{x:e.cx,y:(e.cy??0)+20,className:`fill-muted-foreground text-xs`,children:u})]})}):null,...f})}export{DonutChart};
2
2
  //# sourceMappingURL=donut-chart.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"donut-chart.js","names":[],"sources":["../../src/components/donut-chart.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { Label } from 'recharts'\n\nimport { cn } from '../lib/utils'\nimport { PieChartBase, type PieChartProps } from './pie-chart'\n\nexport type DonutChartProps = PieChartProps & {\n thickness?: number\n withTotal?: boolean\n totalLabel?: React.ReactNode\n}\n\nfunction DonutChart({\n className,\n thickness = 0.35,\n outerRadius = '80%',\n withTotal = false,\n totalLabel = 'Total',\n data,\n ...props\n}: DonutChartProps) {\n const innerRadius = React.useMemo(() => {\n const ratio = Math.min(Math.max(1 - thickness, 0), 1)\n if (typeof outerRadius === 'number') {\n return outerRadius * ratio\n }\n const match = /^(\\d+(?:\\.\\d+)?)%$/.exec(outerRadius)\n if (match) {\n return `${Number(match[1]) * ratio}%`\n }\n return outerRadius\n }, [outerRadius, thickness])\n\n const total = React.useMemo(() => data.reduce((sum, item) => sum + item.value, 0), [data])\n\n return (\n <PieChartBase\n dataSlot=\"donut-chart\"\n className={cn(className)}\n data={data}\n outerRadius={outerRadius}\n innerRadius={innerRadius}\n centerSlot={\n withTotal ? (\n <Label\n position=\"center\"\n content={({ viewBox }) => {\n if (!viewBox || !('cx' in viewBox) || !('cy' in viewBox)) {\n return null\n }\n return (\n <text x={viewBox.cx} y={viewBox.cy} textAnchor=\"middle\" dominantBaseline=\"middle\">\n <tspan x={viewBox.cx} y={viewBox.cy} className=\"fill-foreground font-medium text-2xl tabular-nums\">\n {total.toLocaleString()}\n </tspan>\n <tspan x={viewBox.cx} y={(viewBox.cy ?? 0) + 20} className=\"fill-muted-foreground text-xs\">\n {totalLabel}\n </tspan>\n </text>\n )\n }}\n />\n ) : null\n }\n {...props}\n />\n )\n}\n\nexport { DonutChart }\n"],"mappings":"sOAaA,SAAS,WAAW,CAClB,YACA,YAAY,IACZ,cAAc,MACd,YAAY,GACZ,aAAa,QACb,OACA,GAAG,GACe,CAClB,IAAM,EAAc,EAAM,YAAc,CACtC,IAAM,EAAQ,KAAK,IAAI,KAAK,IAAI,EAAI,EAAW,CAAC,EAAG,CAAC,EACpD,GAAI,OAAO,GAAgB,SACzB,OAAO,EAAc,EAEvB,IAAM,EAAQ,qBAAqB,KAAK,CAAW,EAInD,OAHI,EACK,GAAG,OAAO,EAAM,EAAE,EAAI,EAAM,GAE9B,CACT,EAAG,CAAC,EAAa,CAAS,CAAC,EAErB,EAAQ,EAAM,YAAc,EAAK,QAAQ,EAAK,IAAS,EAAM,EAAK,MAAO,CAAC,EAAG,CAAC,CAAI,CAAC,EAEzF,OACE,EAAC,EAAD,CACE,SAAS,cACT,UAAW,EAAG,CAAS,EACjB,OACO,cACA,cACb,WACE,EACE,EAAC,EAAD,CACE,SAAS,SACT,SAAU,CAAE,aACN,CAAC,GAAW,EAAE,OAAQ,IAAY,EAAE,OAAQ,GACvC,KAGP,EAAC,OAAD,CAAM,EAAG,EAAQ,GAAI,EAAG,EAAQ,GAAI,WAAW,SAAS,iBAAiB,SAAzE,SAAA,CACE,EAAC,QAAD,CAAO,EAAG,EAAQ,GAAI,EAAG,EAAQ,GAAI,UAAU,oDAC5C,SAAA,EAAM,eAAe,CACjB,CAAA,EACP,EAAC,QAAD,CAAO,EAAG,EAAQ,GAAI,GAAI,EAAQ,IAAM,GAAK,GAAI,UAAU,gCACxD,SAAA,CACI,CAAA,CACH,GAGX,CAAA,EACC,KAEN,GAAI,CACL,CAAA,CAEL"}
1
+ {"version":3,"file":"donut-chart.js","names":["React","props","innerRadius","ratio","thickness","outerRadius","match","total","data","sum","item","PieChartBase","cn","className","withTotal","Label","viewBox","totalLabel"],"sources":["../../src/components/donut-chart.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { Label } from 'recharts'\n\nimport { cn } from '../lib/utils'\nimport { PieChartBase, type PieChartProps } from './pie-chart'\n\nexport type DonutChartProps = PieChartProps & {\n /**\n * Ring width as a fraction of the radius.\n * @default 0.35\n */\n thickness?: number\n /**\n * Shows the sum of the values in the center.\n * @default false\n */\n withTotal?: boolean\n /**\n * Label below the total.\n * @default 'Total'\n */\n totalLabel?: React.ReactNode\n}\n\nfunction DonutChart({\n className,\n thickness = 0.35,\n outerRadius = '80%',\n withTotal = false,\n totalLabel = 'Total',\n data,\n ...props\n}: DonutChartProps) {\n const innerRadius = React.useMemo(() => {\n const ratio = Math.min(Math.max(1 - thickness, 0), 1)\n if (typeof outerRadius === 'number') {\n return outerRadius * ratio\n }\n const match = /^(\\d+(?:\\.\\d+)?)%$/.exec(outerRadius)\n if (match) {\n return `${Number(match[1]) * ratio}%`\n }\n return outerRadius\n }, [outerRadius, thickness])\n\n const total = React.useMemo(() => data.reduce((sum, item) => sum + item.value, 0), [data])\n\n return (\n <PieChartBase\n dataSlot=\"donut-chart\"\n className={cn(className)}\n data={data}\n outerRadius={outerRadius}\n innerRadius={innerRadius}\n centerSlot={\n withTotal ? (\n <Label\n content={({ viewBox }) => {\n if (!viewBox || !('cx' in viewBox) || !('cy' in viewBox)) {\n return null\n }\n return (\n <text x={viewBox.cx} y={viewBox.cy} textAnchor=\"middle\" dominantBaseline=\"middle\">\n <tspan x={viewBox.cx} y={viewBox.cy} className=\"fill-foreground font-medium text-2xl tabular-nums\">\n {total.toLocaleString()}\n </tspan>\n <tspan x={viewBox.cx} y={(viewBox.cy ?? 0) + 20} className=\"fill-muted-foreground text-xs\">\n {totalLabel}\n </tspan>\n </text>\n )\n }}\n />\n ) : null\n }\n {...props}\n />\n )\n}\n\nexport { DonutChart }\n"],"mappings":"sOAyBA,SAAS,WAAW,CAClB,YACA,YAAY,IACZ,cAAc,MACd,YAAY,GACZ,aAAa,QACb,OACA,GAAGC,GACe,CAClB,IAAMC,EAAcF,EAAM,YAAc,CACtC,IAAMG,EAAQ,KAAK,IAAI,KAAK,IAAI,EAAIC,EAAW,CAAC,EAAG,CAAC,EACpD,GAAI,OAAOC,GAAgB,SACzB,OAAOA,EAAcF,EAEvB,IAAMG,EAAQ,qBAAqB,KAAKD,CAAW,EAInD,OAHIC,EACK,GAAG,OAAOA,EAAM,EAAE,EAAIH,EAAM,GAE9BE,CACT,EAAG,CAACA,EAAaD,CAAS,CAAC,EAErBG,EAAQP,EAAM,YAAcQ,EAAK,QAAQ,EAAK,IAASC,EAAMC,EAAK,MAAO,CAAC,EAAG,CAACF,CAAI,CAAC,EAEzF,MACE,kBAACG,EAAD,CACE,SAAS,cACT,UAAWC,EAAGC,CAAS,EACjB,OACO,cACA,cACb,WACEC,EACE,kBAACC,EAAD,CACE,SAAU,CAAE,aACN,CAACC,GAAW,EAAE,OAAQA,IAAY,EAAE,OAAQA,GACvC,KAGP,kBAAC,OAAD,CAAM,EAAGA,EAAQ,GAAI,EAAGA,EAAQ,GAAI,WAAW,SAAS,iBAAiB,SAAzE,SAAA,CACE,kBAAC,QAAD,CAAO,EAAGA,EAAQ,GAAI,EAAGA,EAAQ,GAAI,UAAU,oDAC5C,SAAAT,EAAM,eAAe,CACjB,CAAA,EACP,kBAAC,QAAD,CAAO,EAAGS,EAAQ,GAAI,GAAIA,EAAQ,IAAM,GAAK,GAAI,UAAU,gCACxD,SAAAC,CACI,CAAA,CACH,GAGX,CAAA,EACC,KAEN,GAAIhB,CACL,CAAA,CAEL"}
@@ -1,7 +1,8 @@
1
1
  import { t as __name } from "../rolldown-runtime-BhWHdk3m.js";
2
- import { Dialog } from "radix-ui";
3
- import { VariantProps } from "class-variance-authority";
2
+ import { t as AsChildPrimitiveProps } from "../as-child-Dxg3Xo1G.js";
4
3
  import * as React from "react";
4
+ import { VariantProps } from "class-variance-authority";
5
+ import { Dialog } from "@base-ui/react/dialog";
5
6
  //#region src/components/drawer.d.ts
6
7
  declare const drawerContentVariants: (props?: ({
7
8
  direction?: "bottom" | "left" | "right" | "top" | null | undefined;
@@ -10,34 +11,51 @@ declare const drawerContentVariants: (props?: ({
10
11
  type DrawerDirection = NonNullable<VariantProps<typeof drawerContentVariants>['direction']>;
11
12
  type DrawerSize = NonNullable<VariantProps<typeof drawerContentVariants>['size']>;
12
13
  export type DrawerProps = React.ComponentProps<typeof Dialog.Root> & {
14
+ /**
15
+ * Panel width for `left`/`right`, or height for `top`/`bottom`. `full` fills the whole viewport.
16
+ * @default 'md'
17
+ */
13
18
  size?: DrawerSize;
19
+ /**
20
+ * Edge the drawer slides in from.
21
+ * @default 'right'
22
+ */
14
23
  direction?: DrawerDirection;
24
+ /**
25
+ * When `false`, clicking outside and pressing Esc no longer close the drawer. The close button and `DrawerClose` still work.
26
+ * @default true
27
+ */
15
28
  dismissible?: boolean;
16
29
  };
17
- export type DrawerTriggerProps = React.ComponentProps<typeof Dialog.Trigger>;
30
+ export type DrawerTriggerProps = AsChildPrimitiveProps<typeof Dialog.Trigger>;
18
31
  export type DrawerPortalProps = React.ComponentProps<typeof Dialog.Portal>;
19
- export type DrawerCloseProps = React.ComponentProps<typeof Dialog.Close>;
20
- export type DrawerOverlayProps = React.ComponentProps<typeof Dialog.Overlay>;
21
- export type DrawerContentProps = React.ComponentProps<typeof Dialog.Content> & {
32
+ export type DrawerCloseProps = AsChildPrimitiveProps<typeof Dialog.Close>;
33
+ export type DrawerOverlayProps = AsChildPrimitiveProps<typeof Dialog.Backdrop>;
34
+ export type DrawerContentProps = AsChildPrimitiveProps<typeof Dialog.Popup> & Pick<DrawerPortalProps, 'keepMounted'> & {
35
+ /**
36
+ * Shows the X button in the top-right corner.
37
+ * @default true
38
+ */
22
39
  showCloseButton?: boolean;
40
+ /** Props passed to the overlay rendered behind the drawer. */
23
41
  overlayProps?: DrawerOverlayProps;
24
42
  };
25
43
  export type DrawerHeaderProps = React.ComponentProps<'div'>;
26
44
  export type DrawerBodyProps = React.ComponentProps<'div'>;
27
45
  export type DrawerFooterProps = React.ComponentProps<'div'>;
28
- export type DrawerTitleProps = React.ComponentProps<typeof Dialog.Title>;
29
- export type DrawerDescriptionProps = React.ComponentProps<typeof Dialog.Description>;
30
- declare function Drawer({ size, direction, dismissible, ...props }: DrawerProps): React.JSX.Element;
31
- declare function DrawerTrigger({ ...props }: DrawerTriggerProps): React.JSX.Element;
46
+ export type DrawerTitleProps = AsChildPrimitiveProps<typeof Dialog.Title>;
47
+ export type DrawerDescriptionProps = AsChildPrimitiveProps<typeof Dialog.Description>;
48
+ declare function Drawer({ size, direction, dismissible, disablePointerDismissal, onOpenChange, ...props }: DrawerProps): React.JSX.Element;
49
+ declare function DrawerTrigger({ asChild, children, ...props }: DrawerTriggerProps): React.JSX.Element;
32
50
  declare function DrawerPortal({ ...props }: DrawerPortalProps): React.JSX.Element;
33
- declare function DrawerClose({ ...props }: DrawerCloseProps): React.JSX.Element;
34
- declare function DrawerOverlay({ className, onClick, ...props }: DrawerOverlayProps): React.JSX.Element;
35
- declare function DrawerContent({ className, children, showCloseButton, overlayProps, ...props }: DrawerContentProps): React.JSX.Element;
51
+ declare function DrawerClose({ asChild, children, ...props }: DrawerCloseProps): React.JSX.Element;
52
+ declare function DrawerOverlay({ className, onClick, asChild, children, ...props }: DrawerOverlayProps): React.JSX.Element;
53
+ declare function DrawerContent({ className, children, showCloseButton, overlayProps, keepMounted, asChild, ...props }: DrawerContentProps): React.JSX.Element;
36
54
  declare function DrawerHeader({ className, ...props }: DrawerHeaderProps): React.JSX.Element;
37
55
  declare function DrawerBody({ className, ...props }: DrawerBodyProps): React.JSX.Element;
38
56
  declare function DrawerFooter({ className, ...props }: DrawerFooterProps): React.JSX.Element;
39
- declare function DrawerTitle({ className, ...props }: DrawerTitleProps): React.JSX.Element;
40
- declare function DrawerDescription({ className, ...props }: DrawerDescriptionProps): React.JSX.Element;
57
+ declare function DrawerTitle({ className, asChild, children, ...props }: DrawerTitleProps): React.JSX.Element;
58
+ declare function DrawerDescription({ className, asChild, children, ...props }: DrawerDescriptionProps): React.JSX.Element;
41
59
  //#endregion
42
60
  export { Drawer, DrawerBody, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger };
43
61
  //# sourceMappingURL=drawer.d.ts.map
@@ -1,2 +1,2 @@
1
- import"../rolldown-runtime-BhWHdk3m.js";import{cn as e,stopPropagationHandler as t}from"../lib/utils.js";import{Button as n}from"./button.js";import{IconX as r}from"@tabler/icons-react";import{Dialog as i}from"radix-ui";import{jsx as a,jsxs as o}from"react/jsx-runtime";import{cva as s}from"class-variance-authority";import*as c from"react";const l=s([`bg-background flex h-auto flex-col text-sm fixed z-50 outline-none duration-200`,`data-open:animate-in data-closed:animate-out`],{variants:{direction:{top:`inset-x-0 top-0 rounded-b-xl border-b data-closed:slide-out-to-top data-open:slide-in-from-top-10`,right:`inset-y-0 right-0 rounded-l-xl border-l data-closed:slide-out-to-right data-open:slide-in-from-right-10`,bottom:`inset-x-0 bottom-0 rounded-t-xl border-t data-closed:slide-out-to-bottom data-open:slide-in-from-bottom-10`,left:`inset-y-0 left-0 rounded-r-xl border-r data-closed:slide-out-to-left data-open:slide-in-from-left-10`},size:{sm:``,md:``,lg:``,xl:``,"2xl":``,"3xl":``,full:``}},compoundVariants:[{direction:[`left`,`right`],size:`sm`,className:`w-3/4 sm:max-w-sm`},{direction:[`left`,`right`],size:`md`,className:`w-4/5 sm:max-w-md`},{direction:[`left`,`right`],size:`lg`,className:`w-[90%] sm:max-w-lg`},{direction:[`left`,`right`],size:`xl`,className:`w-[90%] sm:max-w-195`},{direction:[`left`,`right`],size:`2xl`,className:`w-[90%] sm:max-w-240`},{direction:[`left`,`right`],size:`3xl`,className:`w-[90%] sm:max-w-300`},{direction:[`left`,`right`],size:`full`,className:`w-full`},{direction:`top`,size:`sm`,className:`mb-24 h-full max-h-96`},{direction:`top`,size:`md`,className:`mb-20 h-full max-h-112`},{direction:`top`,size:`lg`,className:`mb-12 h-full max-h-128`},{direction:`top`,size:`xl`,className:`mb-12 h-full max-h-195`},{direction:`top`,size:`2xl`,className:`mb-12 h-full max-h-240`},{direction:`top`,size:`3xl`,className:`mb-12 h-full max-h-300`},{direction:`top`,size:`full`,className:`mb-0 h-full`},{direction:`bottom`,size:`sm`,className:`mt-24 h-full max-h-96`},{direction:`bottom`,size:`md`,className:`mt-20 h-full max-h-112`},{direction:`bottom`,size:`lg`,className:`mt-12 h-full max-h-128`},{direction:`bottom`,size:`xl`,className:`mt-12 h-full max-h-195`},{direction:`bottom`,size:`2xl`,className:`mt-12 h-full max-h-240`},{direction:`bottom`,size:`3xl`,className:`mt-12 h-full max-h-300`},{direction:`bottom`,size:`full`,className:`mt-0 h-full`}],defaultVariants:{direction:`right`,size:`md`}}),u=c.createContext({size:`md`,direction:`right`,dismissible:!0});function Drawer({size:e=`md`,direction:t=`right`,dismissible:n=!0,...r}){let o=c.useMemo(()=>({size:e,direction:t,dismissible:n}),[e,t,n]);return a(u.Provider,{value:o,children:a(i.Root,{"data-slot":`drawer`,...r})})}function DrawerTrigger({...e}){return a(i.Trigger,{"data-slot":`drawer-trigger`,...e})}function DrawerPortal({...e}){return a(i.Portal,{"data-slot":`drawer-portal`,...e})}function DrawerClose({...e}){return a(i.Close,{"data-slot":`drawer-close`,...e})}function DrawerOverlay({className:n,onClick:r,...o}){return a(i.Overlay,{"data-slot":`drawer-overlay`,className:e(`bg-black/10 fixed inset-0 z-50`,`data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0`,`supports-backdrop-filter:backdrop-blur-xs`,n),onClick:t(r),...o})}function DrawerContent({className:s,children:d,showCloseButton:f=!0,overlayProps:p,...m}){let{size:h,direction:g,dismissible:_}=c.useContext(u);return o(DrawerPortal,{children:[a(DrawerOverlay,{...p}),o(i.Content,{"data-slot":`drawer-content`,className:e(l({size:h,direction:g}),s),...m,onEscapeKeyDown:e=>{_||e.preventDefault(),m.onEscapeKeyDown?.(e)},onInteractOutside:e=>{_||e.preventDefault(),m.onInteractOutside?.(e)},onClick:t(m.onClick),onSubmit:t(m.onSubmit),children:[d,f&&a(DrawerClose,{asChild:!0,children:o(n,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`,children:[a(r,{}),a(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function DrawerHeader({className:t,...n}){let{direction:r}=c.useContext(u);return a(`div`,{"data-slot":`drawer-header`,className:e(`p-4 flex flex-col gap-0.5 md:gap-0.5`,(r===`top`||r===`bottom`)&&`text-center md:text-left`,t),...n})}function DrawerBody({className:t,...n}){return a(`div`,{"data-slot":`drawer-body`,className:e(`px-4 pb-4 flex-1 min-h-0 overflow-y-auto`,t),...n})}function DrawerFooter({className:t,...n}){return a(`div`,{"data-slot":`drawer-footer`,className:e(`gap-2 p-4 mt-auto flex flex-col sm:flex-row sm:justify-end`,t),...n})}function DrawerTitle({className:t,...n}){return a(i.Title,{"data-slot":`drawer-title`,className:e(`text-foreground text-base font-medium`,t),...n})}function DrawerDescription({className:t,...n}){return a(i.Description,{"data-slot":`drawer-description`,className:e(`text-muted-foreground text-sm`,t),...n})}export{Drawer,DrawerBody,DrawerClose,DrawerContent,DrawerDescription,DrawerFooter,DrawerHeader,DrawerOverlay,DrawerPortal,DrawerTitle,DrawerTrigger};
1
+ import"../rolldown-runtime-BhWHdk3m.js";import{toAsChildRenderProps as e}from"../lib/as-child.js";import{cn as t,stopPropagationHandler as n}from"../lib/utils.js";import{t as r}from"../resolve-class-name-BurP8ngI.js";import{Button as i}from"./button.js";import{IconX as a}from"@tabler/icons-react";import*as o from"react";import{jsx as s,jsxs as c}from"react/jsx-runtime";import{cva as l}from"class-variance-authority";import{Dialog as u}from"@base-ui/react/dialog";const d=l([`bg-background flex h-auto flex-col text-sm fixed z-50 outline-none duration-200`,`data-open:animate-in data-closed:animate-out`],{variants:{direction:{top:`inset-x-0 top-0 rounded-b-xl border-b data-closed:slide-out-to-top data-open:slide-in-from-top-10`,right:`inset-y-0 right-0 rounded-l-xl border-l data-closed:slide-out-to-right data-open:slide-in-from-right-10`,bottom:`inset-x-0 bottom-0 rounded-t-xl border-t data-closed:slide-out-to-bottom data-open:slide-in-from-bottom-10`,left:`inset-y-0 left-0 rounded-r-xl border-r data-closed:slide-out-to-left data-open:slide-in-from-left-10`},size:{sm:``,md:``,lg:``,xl:``,"2xl":``,"3xl":``,full:``}},compoundVariants:[{direction:[`left`,`right`],size:`sm`,className:`w-3/4 sm:max-w-sm`},{direction:[`left`,`right`],size:`md`,className:`w-4/5 sm:max-w-md`},{direction:[`left`,`right`],size:`lg`,className:`w-[90%] sm:max-w-lg`},{direction:[`left`,`right`],size:`xl`,className:`w-[90%] sm:max-w-195`},{direction:[`left`,`right`],size:`2xl`,className:`w-[90%] sm:max-w-240`},{direction:[`left`,`right`],size:`3xl`,className:`w-[90%] sm:max-w-300`},{direction:[`left`,`right`],size:`full`,className:`w-full`},{direction:`top`,size:`sm`,className:`mb-24 h-full max-h-96`},{direction:`top`,size:`md`,className:`mb-20 h-full max-h-112`},{direction:`top`,size:`lg`,className:`mb-12 h-full max-h-128`},{direction:`top`,size:`xl`,className:`mb-12 h-full max-h-195`},{direction:`top`,size:`2xl`,className:`mb-12 h-full max-h-240`},{direction:`top`,size:`3xl`,className:`mb-12 h-full max-h-300`},{direction:`top`,size:`full`,className:`mb-0 h-full`},{direction:`bottom`,size:`sm`,className:`mt-24 h-full max-h-96`},{direction:`bottom`,size:`md`,className:`mt-20 h-full max-h-112`},{direction:`bottom`,size:`lg`,className:`mt-12 h-full max-h-128`},{direction:`bottom`,size:`xl`,className:`mt-12 h-full max-h-195`},{direction:`bottom`,size:`2xl`,className:`mt-12 h-full max-h-240`},{direction:`bottom`,size:`3xl`,className:`mt-12 h-full max-h-300`},{direction:`bottom`,size:`full`,className:`mt-0 h-full`}],defaultVariants:{direction:`right`,size:`md`}}),f=o.createContext({size:`md`,direction:`right`});function Drawer({size:e=`md`,direction:t=`right`,dismissible:n=!0,disablePointerDismissal:r,onOpenChange:i,...a}){let c=o.useMemo(()=>({size:e,direction:t}),[e,t]);return/* @__PURE__ */ s(f.Provider,{value:c,children:/* @__PURE__ */ s(u.Root,{"data-slot":`drawer`,disablePointerDismissal:!n||r,onOpenChange:(e,t)=>{!n&&t.reason===`escape-key`?t.cancel():i?.(e,t)},...a})})}function DrawerTrigger({asChild:t,children:n,...r}){return/* @__PURE__ */ s(u.Trigger,{"data-slot":`drawer-trigger`,...r,...e(t,n)})}function DrawerPortal({...e}){return/* @__PURE__ */ s(u.Portal,{"data-slot":`drawer-portal`,...e})}function DrawerClose({asChild:t,children:n,...r}){return/* @__PURE__ */ s(u.Close,{"data-slot":`drawer-close`,...r,...e(t,n)})}function DrawerOverlay({className:i,onClick:a,asChild:o,children:c,...l}){return/* @__PURE__ */ s(u.Backdrop,{"data-slot":`drawer-overlay`,className:e=>t(`bg-black/10 fixed inset-0 z-50 duration-200`,`data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0`,`supports-backdrop-filter:backdrop-blur-xs`,r(i,e)),onClick:n(a),...l,...e(o,c)})}function DrawerContent({className:l,children:p,showCloseButton:m=!0,overlayProps:h,keepMounted:g,asChild:_,...v}){let{size:y,direction:b}=o.useContext(f);return/* @__PURE__ */ c(DrawerPortal,{keepMounted:g,children:[/* @__PURE__ */ s(DrawerOverlay,{...h}),/* @__PURE__ */ c(u.Popup,{"data-slot":`drawer-content`,className:e=>t(d({size:y,direction:b}),r(l,e)),...v,...e(_,p),onClick:n(v.onClick),onSubmit:n(v.onSubmit),children:[!_&&p,m&&!_&&/* @__PURE__ */ c(u.Close,{"data-slot":`drawer-close`,render:/* @__PURE__ */ s(i,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`}),children:[/* @__PURE__ */ s(a,{}),/* @__PURE__ */ s(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function DrawerHeader({className:e,...n}){let{direction:r}=o.useContext(f);return/* @__PURE__ */ s(`div`,{"data-slot":`drawer-header`,className:t(`p-4 flex flex-col gap-0.5 md:gap-0.5`,(r===`top`||r===`bottom`)&&`text-center md:text-left`,e),...n})}function DrawerBody({className:e,...n}){return/* @__PURE__ */ s(`div`,{"data-slot":`drawer-body`,className:t(`px-4 pb-4 flex-1 min-h-0 overflow-y-auto`,e),...n})}function DrawerFooter({className:e,...n}){return/* @__PURE__ */ s(`div`,{"data-slot":`drawer-footer`,className:t(`gap-2 p-4 mt-auto flex flex-col sm:flex-row sm:justify-end`,e),...n})}function DrawerTitle({className:n,asChild:i,children:a,...o}){return/* @__PURE__ */ s(u.Title,{"data-slot":`drawer-title`,className:e=>t(`text-foreground text-base font-medium`,r(n,e)),...o,...e(i,a)})}function DrawerDescription({className:n,asChild:i,children:a,...o}){return/* @__PURE__ */ s(u.Description,{"data-slot":`drawer-description`,className:e=>t(`text-muted-foreground text-sm`,r(n,e)),...o,...e(i,a)})}export{Drawer,DrawerBody,DrawerClose,DrawerContent,DrawerDescription,DrawerFooter,DrawerHeader,DrawerOverlay,DrawerPortal,DrawerTitle,DrawerTrigger};
2
2
  //# sourceMappingURL=drawer.js.map