neba 1.10.0 → 1.12.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 (288) hide show
  1. package/README.md +36 -6
  2. package/dist/components/accordion/Accordion.js +1 -1
  3. package/dist/components/alert/Alert.js +1 -1
  4. package/dist/components/anchor/Anchor.js +1 -1
  5. package/dist/components/animate-appear/AnimateAppear.d.ts +2 -13
  6. package/dist/components/animate-appear/AnimateAppear.js +1 -1
  7. package/dist/components/animate-blink/AnimateBlink.d.ts +2 -2
  8. package/dist/components/animate-blink/AnimateBlink.js +1 -1
  9. package/dist/components/animate-counter/AnimateCounter.d.ts +45 -0
  10. package/dist/components/animate-counter/AnimateCounter.js +1 -0
  11. package/dist/components/animate-counter/index.d.ts +1 -0
  12. package/dist/components/animate-counter/index.js +1 -0
  13. package/dist/components/animate-fade/AnimateFade.d.ts +2 -2
  14. package/dist/components/animate-fade/AnimateFade.js +1 -1
  15. package/dist/components/animate-float/AnimateFloat.d.ts +35 -0
  16. package/dist/components/animate-float/AnimateFloat.js +1 -0
  17. package/dist/components/animate-float/index.d.ts +1 -0
  18. package/dist/components/animate-float/index.js +1 -0
  19. package/dist/components/animate-grow/AnimateGrow.d.ts +2 -2
  20. package/dist/components/animate-grow/AnimateGrow.js +1 -1
  21. package/dist/components/animate-lighting/AnimateLighting.js +1 -1
  22. package/dist/components/animate-reveal/AnimateReveal.d.ts +41 -0
  23. package/dist/components/animate-reveal/AnimateReveal.js +1 -0
  24. package/dist/components/animate-reveal/index.d.ts +1 -0
  25. package/dist/components/animate-reveal/index.js +1 -0
  26. package/dist/components/animate-rotate/AnimateRotate.d.ts +2 -2
  27. package/dist/components/animate-rotate/AnimateRotate.js +1 -1
  28. package/dist/components/animate-scramble/AnimateScramble.d.ts +48 -0
  29. package/dist/components/animate-scramble/AnimateScramble.js +1 -0
  30. package/dist/components/animate-scramble/index.d.ts +1 -0
  31. package/dist/components/animate-scramble/index.js +1 -0
  32. package/dist/components/animate-shake/AnimateShake.d.ts +39 -0
  33. package/dist/components/animate-shake/AnimateShake.js +1 -0
  34. package/dist/components/animate-shake/index.d.ts +1 -0
  35. package/dist/components/animate-shake/index.js +1 -0
  36. package/dist/components/animate-slide/AnimateSlide.d.ts +2 -2
  37. package/dist/components/animate-slide/AnimateSlide.js +1 -1
  38. package/dist/components/animate-split/AnimateSplit.d.ts +61 -0
  39. package/dist/components/animate-split/AnimateSplit.js +1 -0
  40. package/dist/components/animate-split/index.d.ts +1 -0
  41. package/dist/components/animate-split/index.js +1 -0
  42. package/dist/components/animate-typing/AnimateTyping.js +1 -1
  43. package/dist/components/animate-zoom/AnimateZoom.d.ts +2 -2
  44. package/dist/components/animate-zoom/AnimateZoom.js +1 -1
  45. package/dist/components/app-logo/AppLogo.js +1 -1
  46. package/dist/components/aspect-ratio/AspectRatio.js +1 -1
  47. package/dist/components/avatar/Avatar.js +1 -1
  48. package/dist/components/badge/Badge.js +1 -1
  49. package/dist/components/bar-chart/BarChart.d.ts +1 -1
  50. package/dist/components/bar-chart/BarChart.js +1 -1
  51. package/dist/components/blockquote/Blockquote.js +1 -1
  52. package/dist/components/bottom-navigation/BottomNavigation.js +1 -1
  53. package/dist/components/box/Box.js +1 -1
  54. package/dist/components/breadcrumb/Breadcrumb.js +1 -1
  55. package/dist/components/button/Button.js +1 -1
  56. package/dist/components/button-group/ButtonGroup.js +1 -1
  57. package/dist/components/calendar/Calendar.d.ts +72 -0
  58. package/dist/components/calendar/Calendar.js +1 -0
  59. package/dist/components/calendar/index.d.ts +2 -0
  60. package/dist/components/calendar/index.js +1 -0
  61. package/dist/components/card/Card.js +1 -1
  62. package/dist/components/carousel/Carousel.js +1 -1
  63. package/dist/components/chat-bubble/ChatBubble.js +1 -1
  64. package/dist/components/checkbox/Checkbox.js +1 -1
  65. package/dist/components/chip/Chip.js +1 -1
  66. package/dist/components/code-block/CodeBlock.js +1 -1
  67. package/dist/components/collapsible/Collapsible.js +1 -1
  68. package/dist/components/color-picker/ColorPicker.js +1 -1
  69. package/dist/components/combobox/Combobox.d.ts +14 -2
  70. package/dist/components/combobox/Combobox.js +1 -1
  71. package/dist/components/command-palette/CommandPalette.d.ts +1 -1
  72. package/dist/components/command-palette/CommandPalette.js +1 -1
  73. package/dist/components/confirm/Confirm.d.ts +83 -0
  74. package/dist/components/confirm/Confirm.js +1 -0
  75. package/dist/components/confirm/index.d.ts +2 -0
  76. package/dist/components/confirm/index.js +1 -0
  77. package/dist/components/container/Container.d.ts +12 -4
  78. package/dist/components/container/Container.js +1 -1
  79. package/dist/components/data-list/DataList.js +1 -1
  80. package/dist/components/data-table/DataTable.d.ts +104 -1
  81. package/dist/components/data-table/DataTable.js +1 -1
  82. package/dist/components/date-picker/DatePicker.d.ts +40 -8
  83. package/dist/components/date-picker/DatePicker.js +1 -1
  84. package/dist/components/date-range-picker/DateRangePicker.js +1 -1
  85. package/dist/components/date-time-picker/DateTimePicker.js +1 -1
  86. package/dist/components/dialog/Dialog.d.ts +1 -1
  87. package/dist/components/dialog/Dialog.js +1 -1
  88. package/dist/components/divider/Divider.js +1 -1
  89. package/dist/components/drawer/Drawer.d.ts +1 -1
  90. package/dist/components/drawer/Drawer.js +1 -1
  91. package/dist/components/empty/Empty.js +1 -1
  92. package/dist/components/file-picker/FilePicker.js +1 -1
  93. package/dist/components/flex/Flex.d.ts +93 -0
  94. package/dist/components/flex/Flex.js +1 -0
  95. package/dist/components/flex/index.d.ts +2 -0
  96. package/dist/components/flex/index.js +1 -0
  97. package/dist/components/floating-action-button/FloatingActionButton.js +1 -1
  98. package/dist/components/floating-bottom-navigation/FloatingBottomNavigation.js +1 -1
  99. package/dist/components/footer/Footer.d.ts +4 -3
  100. package/dist/components/footer/Footer.js +1 -1
  101. package/dist/components/gallery/Gallery.d.ts +150 -0
  102. package/dist/components/gallery/Gallery.js +1 -0
  103. package/dist/components/gallery/GalleryViewer.d.ts +30 -0
  104. package/dist/components/gallery/GalleryViewer.js +1 -0
  105. package/dist/components/gallery/index.d.ts +2 -0
  106. package/dist/components/gallery/index.js +1 -0
  107. package/dist/components/gauge-chart/GaugeChart.d.ts +1 -1
  108. package/dist/components/gauge-chart/GaugeChart.js +1 -1
  109. package/dist/components/grid/Grid.js +1 -1
  110. package/dist/components/grid-container/GridContainer.js +1 -1
  111. package/dist/components/header/Header.d.ts +5 -4
  112. package/dist/components/header/Header.js +1 -1
  113. package/dist/components/heatmap-chart/HeatmapChart.d.ts +1 -1
  114. package/dist/components/heatmap-chart/HeatmapChart.js +1 -1
  115. package/dist/components/highlight/Highlight.js +1 -1
  116. package/dist/components/hover-card/HoverCard.d.ts +1 -1
  117. package/dist/components/hover-card/HoverCard.js +1 -1
  118. package/dist/components/how-to-steps/HowToSteps.js +1 -1
  119. package/dist/components/image/Image.d.ts +190 -0
  120. package/dist/components/image/Image.js +1 -0
  121. package/dist/components/image/index.d.ts +2 -0
  122. package/dist/components/image/index.js +1 -0
  123. package/dist/components/list/List.js +1 -1
  124. package/dist/components/menu/Menu.js +1 -1
  125. package/dist/components/menubar/Menubar.js +1 -1
  126. package/dist/components/meter/Meter.js +1 -1
  127. package/dist/components/mockup/Mockup.js +1 -1
  128. package/dist/components/navigation-menu/NavigationMenu.js +1 -1
  129. package/dist/components/number-field/NumberField.d.ts +12 -2
  130. package/dist/components/number-field/NumberField.js +1 -1
  131. package/dist/components/otp-field/OtpField.js +1 -1
  132. package/dist/components/overlay/Overlay.d.ts +1 -1
  133. package/dist/components/overlay/Overlay.js +1 -1
  134. package/dist/components/page-layout/PageLayout.js +1 -1
  135. package/dist/components/pagination/Pagination.js +1 -1
  136. package/dist/components/panes/Panes.js +1 -1
  137. package/dist/components/pie-chart/PieChart.d.ts +1 -1
  138. package/dist/components/pie-chart/PieChart.js +1 -1
  139. package/dist/components/pill/Pill.js +1 -1
  140. package/dist/components/popconfirm/Popconfirm.d.ts +71 -0
  141. package/dist/components/popconfirm/Popconfirm.js +1 -0
  142. package/dist/components/popconfirm/index.d.ts +2 -0
  143. package/dist/components/popconfirm/index.js +1 -0
  144. package/dist/components/popover/Popover.d.ts +1 -1
  145. package/dist/components/popover/Popover.js +1 -1
  146. package/dist/components/portal/Portal.d.ts +48 -0
  147. package/dist/components/portal/Portal.js +1 -0
  148. package/dist/components/portal/index.d.ts +2 -0
  149. package/dist/components/portal/index.js +1 -0
  150. package/dist/components/progress-box/ProgressBox.js +1 -1
  151. package/dist/components/progress-circular/ProgressCircular.js +1 -1
  152. package/dist/components/progress-linear/ProgressLinear.js +1 -1
  153. package/dist/components/provider/NebaProvider.d.ts +99 -0
  154. package/dist/components/provider/NebaProvider.js +1 -0
  155. package/dist/components/provider/index.d.ts +3 -0
  156. package/dist/components/provider/index.js +1 -0
  157. package/dist/components/radio-group/RadioGroup.js +1 -1
  158. package/dist/components/rating/Rating.js +1 -1
  159. package/dist/components/scatter-chart/ScatterChart.d.ts +1 -1
  160. package/dist/components/scatter-chart/ScatterChart.js +1 -1
  161. package/dist/components/scroll-area/ScrollArea.js +1 -1
  162. package/dist/components/scroll-zone/ScrollZone.d.ts +9 -4
  163. package/dist/components/scroll-zone/ScrollZone.js +1 -1
  164. package/dist/components/select/Select.js +1 -1
  165. package/dist/components/shortcut/Shortcut.d.ts +2 -1
  166. package/dist/components/shortcut/Shortcut.js +1 -1
  167. package/dist/components/show/Show.d.ts +60 -0
  168. package/dist/components/show/Show.js +1 -0
  169. package/dist/components/show/index.d.ts +2 -0
  170. package/dist/components/show/index.js +1 -0
  171. package/dist/components/sidebar/Sidebar.js +1 -1
  172. package/dist/components/sidebar/SidebarTrigger.js +1 -1
  173. package/dist/components/skeleton/Skeleton.js +1 -1
  174. package/dist/components/slider/Slider.js +1 -1
  175. package/dist/components/sparkline/Sparkline.js +1 -1
  176. package/dist/components/spoiler/Spoiler.js +1 -1
  177. package/dist/components/stack/Stack.d.ts +126 -0
  178. package/dist/components/stack/Stack.js +1 -0
  179. package/dist/components/stack/index.d.ts +1 -0
  180. package/dist/components/stack/index.js +1 -0
  181. package/dist/components/statistic/Statistic.d.ts +8 -3
  182. package/dist/components/statistic/Statistic.js +1 -1
  183. package/dist/components/switch/Switch.js +1 -1
  184. package/dist/components/table/Table.d.ts +1 -1
  185. package/dist/components/table/Table.js +1 -1
  186. package/dist/components/tabs/Tabs.d.ts +28 -0
  187. package/dist/components/tabs/Tabs.js +1 -1
  188. package/dist/components/text-field/TextField.d.ts +12 -1
  189. package/dist/components/text-field/TextField.js +1 -1
  190. package/dist/components/text-link/TextLink.js +1 -1
  191. package/dist/components/time-picker/TimePicker.js +1 -1
  192. package/dist/components/timeline-chart/TimelineChart.d.ts +1 -1
  193. package/dist/components/timeline-chart/TimelineChart.js +1 -1
  194. package/dist/components/toast/Toast.d.ts +1 -1
  195. package/dist/components/toast/Toast.js +1 -1
  196. package/dist/components/toggle/Toggle.js +1 -1
  197. package/dist/components/toggle-group/ToggleGroup.js +1 -1
  198. package/dist/components/toolbar/Toolbar.js +1 -1
  199. package/dist/components/tooltip/Tooltip.d.ts +1 -1
  200. package/dist/components/tooltip/Tooltip.js +1 -1
  201. package/dist/components/tour/Tour.d.ts +1 -1
  202. package/dist/components/tour/Tour.js +1 -1
  203. package/dist/components/transfer/Transfer.js +1 -1
  204. package/dist/components/tree-select/TreeSelect.d.ts +88 -0
  205. package/dist/components/tree-select/TreeSelect.js +1 -0
  206. package/dist/components/tree-select/index.d.ts +2 -0
  207. package/dist/components/tree-select/index.js +1 -0
  208. package/dist/components/tree-view/TreeView.js +1 -1
  209. package/dist/components/visually-hidden/VisuallyHidden.d.ts +37 -0
  210. package/dist/components/visually-hidden/VisuallyHidden.js +1 -0
  211. package/dist/components/visually-hidden/index.d.ts +2 -0
  212. package/dist/components/visually-hidden/index.js +1 -0
  213. package/dist/components/window-pane/WindowPane.js +1 -1
  214. package/dist/hooks/index.d.ts +10 -0
  215. package/dist/hooks/index.js +1 -0
  216. package/dist/hooks/useDisclosure.d.ts +21 -0
  217. package/dist/hooks/useDisclosure.js +1 -0
  218. package/dist/hooks/useElementSize.d.ts +23 -0
  219. package/dist/hooks/useElementSize.js +1 -0
  220. package/dist/hooks/useMediaQuery.d.ts +61 -0
  221. package/dist/hooks/useMediaQuery.js +1 -0
  222. package/dist/hooks/useOnScreen.d.ts +24 -0
  223. package/dist/hooks/useOnScreen.js +1 -0
  224. package/dist/hooks/useShortcut.d.ts +34 -0
  225. package/dist/hooks/useShortcut.js +1 -0
  226. package/dist/index.d.ts +19 -1
  227. package/dist/index.js +1 -1
  228. package/dist/internal/animate.d.ts +65 -2
  229. package/dist/internal/animate.js +1 -1
  230. package/dist/internal/calendar.d.ts +31 -5
  231. package/dist/internal/calendar.js +1 -1
  232. package/dist/internal/chart-frame.d.ts +32 -0
  233. package/dist/internal/chart-frame.js +1 -1
  234. package/dist/internal/chart-line.js +1 -1
  235. package/dist/internal/chart.d.ts +16 -0
  236. package/dist/internal/chart.js +1 -1
  237. package/dist/internal/csv.d.ts +40 -0
  238. package/dist/internal/csv.js +1 -0
  239. package/dist/internal/date.d.ts +39 -1
  240. package/dist/internal/date.js +1 -1
  241. package/dist/internal/defaults.d.ts +46 -0
  242. package/dist/internal/defaults.js +1 -0
  243. package/dist/internal/grid.d.ts +13 -27
  244. package/dist/internal/grid.js +1 -1
  245. package/dist/internal/i18n.d.ts +43 -0
  246. package/dist/internal/i18n.js +1 -1
  247. package/dist/internal/keys.d.ts +92 -0
  248. package/dist/internal/keys.js +1 -0
  249. package/dist/internal/media.d.ts +34 -0
  250. package/dist/internal/media.js +1 -1
  251. package/dist/internal/page-layout.d.ts +18 -9
  252. package/dist/internal/page-layout.js +1 -1
  253. package/dist/internal/picker.d.ts +7 -1
  254. package/dist/internal/picker.js +1 -1
  255. package/dist/internal/responsive.d.ts +97 -0
  256. package/dist/internal/responsive.js +1 -0
  257. package/dist/internal/styles.d.ts +68 -0
  258. package/dist/internal/styles.js +1 -1
  259. package/dist/internal/text.d.ts +42 -0
  260. package/dist/internal/text.js +1 -0
  261. package/dist/locales/ar.js +1 -1
  262. package/dist/locales/de.js +1 -1
  263. package/dist/locales/es.js +1 -1
  264. package/dist/locales/fr.js +1 -1
  265. package/dist/locales/hi.js +1 -1
  266. package/dist/locales/id.js +1 -1
  267. package/dist/locales/it.js +1 -1
  268. package/dist/locales/ja.js +1 -1
  269. package/dist/locales/ko.js +1 -1
  270. package/dist/locales/nl.js +1 -1
  271. package/dist/locales/pl.js +1 -1
  272. package/dist/locales/pt.js +1 -1
  273. package/dist/locales/ru.js +1 -1
  274. package/dist/locales/th.js +1 -1
  275. package/dist/locales/tr.js +1 -1
  276. package/dist/locales/vi.js +1 -1
  277. package/dist/locales/zh-hans.js +1 -1
  278. package/dist/locales/zh-hant.js +1 -1
  279. package/dist/styles.css +1 -1
  280. package/dist/tailwind.css +280 -24
  281. package/dist/types.d.ts +153 -6
  282. package/package.json +23 -17
  283. package/dist/components/avatar-group/AvatarGroup.d.ts +0 -47
  284. package/dist/components/avatar-group/AvatarGroup.js +0 -1
  285. package/dist/components/avatar-group/index.d.ts +0 -2
  286. package/dist/components/avatar-group/index.js +0 -1
  287. package/dist/internal/avatar-group.d.ts +0 -22
  288. package/dist/internal/avatar-group.js +0 -1
@@ -1 +1 @@
1
- "use client";import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import*as n from"react";import{Box as a}from"../box/Box.js";import{Checkbox as l}from"../checkbox/Checkbox.js";import{Pagination as o}from"../pagination/Pagination.js";import{Select as s}from"../select/Select.js";import{TextField as i}from"../text-field/TextField.js";import{compareValues as c,dataHeaderHeights as u,dataRowHeights as d,dataTickWidths as p,defaultColumnWidth as m,keysBetween as h,minColumnWidth as f,nextSort as g,pageBounds as y,sortRows as v,virtualWindow as b}from"../../internal/data-table.js";import{beginPointerDrag as k}from"../../internal/drag.js";import{emptyMessages as w,fillMessage as x,tableMessages as C,useMessages as S}from"../../internal/i18n.js";import{searchHaystack as M,searchText as N}from"../../internal/search.js";import{ChevronIcon as K}from"../../internal/icons.js";import{observeResize as z}from"../../internal/observe.js";import{controlTextLeadingClasses as j,cx as $,hasContent as _,metaTextClasses as R,paddingXValues as D,srOnlyClasses as E,toLength as A}from"../../internal/styles.js";const P=["[--n-row:transparent]","[transition:background-color_var(--neba-duration)_var(--neba-ease)]"].join(" "),T={"--n-stripe":"color-mix(in oklab, var(--neba-fg) 4%, transparent)"},L=["group/sort flex w-full min-w-0 cursor-pointer items-center gap-1","text-inherit [outline:none]","[transition:color_var(--neba-duration)_var(--neba-ease)]","hover:text-(--n-accent)","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-1","[&_svg]:pointer-events-none [&_svg]:size-[1.15em] [&_svg]:shrink-0"].join(" "),H=["absolute inset-y-0 z-10 w-2 cursor-col-resize select-none","end-0 translate-x-1/2 rtl:-translate-x-1/2","after:absolute after:inset-y-1 after:start-1/2 after:w-px","after:[background:transparent]","after:[transition:background_var(--neba-duration)_var(--neba-ease)]","hover:after:[background:var(--n-accent)] data-[dragging]:after:[background:var(--n-accent)]"].join(" ");function I(){return t("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[e("circle",{cx:"7.25",cy:"7.25",r:"4.75",stroke:"currentColor",strokeWidth:"1.5"}),e("path",{d:"m10.75 10.75 2.75 2.75",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}export function DataTable({headers:B,items:W,getRowKey:F,variant:O="outline",size:q="sm",color:U="primary",density:X="compact",elevation:Y=0,height:V,maxHeight:G,rowHeight:J,striped:Q=!1,hoverable:Z=!0,stickyHeader:ee=!0,caption:te,label:re,empty:ne,virtual:ae=!0,overscan:le=8,sortable:oe=!1,sortMode:se="single",sort:ie,defaultSort:ce,onSortChange:ue,resizable:de=!1,columnWidths:pe,defaultColumnWidths:me,onColumnWidthsChange:he,selectionMode:fe="none",selected:ge,defaultSelected:ye,onSelectedChange:ve,checkboxes:be=!1,onRowClick:ke,onRowActivate:we,paging:xe="scroll",page:Ce,defaultPage:Se=1,onPageChange:Me,pageSize:Ne,defaultPageSize:Ke=25,onPageSizeChange:ze,pageSizeOptions:je=[10,25,50,100],footer:$e,search:_e,defaultSearch:Re,onSearchChange:De,searchable:Ee=!1,searchPlaceholder:Ae,filter:Pe,toolbar:Te,manual:Le=!1,rowCount:He,locale:Ie,className:Be,style:We,...Fe}){const Oe=S(C,Ie),qe=S(w,Ie),Ue=n.useId(),Xe=J??d[X][q],Ye=u[X][q],Ve=D[X][q],Ge=n.useMemo(()=>new Set(!0===Le?["sort","filter","pages"]:Le||[]),[Le]),Je=n.useMemo(()=>B.filter(e=>!e.hidden),[B]),Qe=Je.some(e=>void 0!==e.group),Ze="none"!==fe,et="multiple"===fe,tt=Ze&&be,rt=n.useMemo(()=>W.map((e,t)=>{const r=F?F(e,t):t;return{row:e,identity:r,key:String(r),origin:t}}),[W,F]),[nt,at]=n.useState(Re??""),lt=(_e??nt).trim(),ot=""!==lt&&!Ge.has("filter"),st=n.useMemo(()=>Je.filter(e=>!1!==e.searchable),[Je]),it=n.useMemo(()=>ot&&0!==st.length?rt.map(e=>M(st.map(t=>t.value?t.value(e.row):e.row[t.key]))):null,[rt,st,ot]),ct=n.useMemo(()=>{if(Ge.has("filter"))return rt;const e=N(lt),t=""!==e&&it?rt.filter(t=>it[t.origin].includes(e)):rt;return Pe?t.filter(e=>Pe(e.row,e.origin)):t},[rt,lt,Pe,Ge,it]),ut=n.useMemo(()=>new Intl.Collator(Ie,{numeric:!0,sensitivity:"base"}),[Ie]),[dt,pt]=n.useState(ce??[]),mt=ie??dt,ht=n.useMemo(()=>Ge.has("sort")?ct:v(ct,mt,e=>{const t=Je.find(t=>t.key===e);if(!t)return null;if(t.compare)return(e,r)=>t.compare(e.row,r.row);const r=t.value?t.value:e=>e[t.key];return(e,t)=>c(r(e.row),r(t.row),ut)}),[ct,mt,Je,ut,Ge]),[ft,gt]=n.useState(Se),[yt,vt]=n.useState(Ke),bt=Ne??yt,kt=Ge.has("pages")?He??ht.length:ht.length,wt=y(kt,Ce??ft,bt),xt=n.useMemo(()=>"pages"!==xe||Ge.has("pages")?ht:ht.slice(wt.start,wt.end),[ht,xe,Ge,wt.start,wt.end]),Ct="pages"===xe?wt.start:0,St=n.useMemo(()=>xt.map(e=>e.key),[xt]),Mt=n.useMemo(()=>new Map(rt.map(e=>[e.key,e])),[rt]),[Nt,Kt]=n.useState(ye??[]),zt=ge??Nt,jt=n.useMemo(()=>new Set(zt.map(String)),[zt]),[$t,_t]=n.useState(null),Rt=n.useRef(null),Dt=n.useRef({paged:xt,pagedKeys:St,byKey:Mt,selectedKeys:jt,multiple:et});Dt.current={paged:xt,pagedKeys:St,byKey:Mt,selectedKeys:jt,multiple:et};const Et=n.useCallback(e=>{const t=[],r=[];for(const n of e){const e=Dt.current.byKey.get(n);e&&(t.push(e.identity),r.push(e.row))}void 0===ge&&Kt(t),ve?.(t,r)},[ge,ve]),At=n.useCallback(e=>{Rt.current=e,Et([e])},[Et]),Pt=n.useCallback(e=>{const t=Dt.current.selectedKeys,r=new Set(t);r.has(e)?r.delete(e):r.add(e),Rt.current=e,Et([...r])},[Et]),Tt=n.useCallback((e,t)=>{const r=Dt.current.pagedKeys,n=Rt.current??r[0];if(void 0===n)return;const a=h(r,n,e);0!==a.length&&Et(t?[...new Set([...Dt.current.selectedKeys,...a])]:a)},[Et]),Lt=n.useRef(null),Ht=n.useRef(null),It=n.useRef(null),[Bt,Wt]=n.useState(0),[Ft,Ot]=n.useState(0),qt=void 0!==V||void 0!==G,Ut=ae&&qt&&xt.length>0;n.useLayoutEffect(()=>{const e=Lt.current;if(e&&Ut)return Wt(e.clientHeight),z(e,e=>Wt(e.contentRect.height))},[Ut]);const Xt=n.useCallback(e=>{if(!Ut)return;const t=Math.floor(e.currentTarget.scrollTop/Xe)*Xe;Ot(e=>e===t?e:t)},[Ut,Xe]),Yt=Ut?b(Ft,Bt,Xe,xt.length,le):{start:0,end:xt.length,before:0,after:0},Vt=xt.slice(Yt.start,Yt.end),Gt=Ze&&null!==$t&&Vt.some(e=>e.key===$t),[Jt,Qt]=n.useState(me??{}),Zt=pe??Jt,er=n.useCallback(e=>{void 0===pe&&Qt(e),he?.(e)},[pe,he]),tr=n.useRef(new Map),rr=n.useRef(null);n.useEffect(()=>()=>rr.current?.(),[]);const nr=n.useCallback(e=>{const t=Lt.current;if(!t||!qt)return;const r=ee?Ye*(Qe?2:1):0,n=e*Xe;n<t.scrollTop+r?t.scrollTop=Math.max(0,n-r):n+Xe>t.scrollTop+t.clientHeight&&(t.scrollTop=n+Xe-t.clientHeight)},[qt,ee,Ye,Qe,Xe]),ar=(e,t)=>{const r=Dt.current.paged,n=Math.min(Math.max(e,0),r.length-1),a=r[n];a&&(t.preventDefault(),_t(a.key),nr(n),t.shiftKey&&Dt.current.multiple?Tt(a.key,!1):t.ctrlKey||t.metaKey||At(a.key))};const lr=n.useCallback(e=>{const t=Ht.current,r=Dt.current.paged;if(!t||0===r.length)return null;const n=t.getBoundingClientRect().top,a=Math.floor((e-n)/Xe);return Math.min(Math.max(a,0),r.length-1)},[Xe]),or=n.useRef(null),sr=n.useCallback(e=>{const t=lr(e),r=null===t?void 0:Dt.current.paged[t];r&&(_t(r.key),Tt(r.key,!1))},[lr,Tt]),ir=n.useRef(sr);ir.current=sr;function cr(e,t){if(Ze&&!t.target.closest('button, a, input, select, textarea, [role="button"]'))if(It.current?.focus({preventScroll:!0}),_t(e.key),2!==t.button){if(0===t.button)return t.shiftKey&&et?(t.preventDefault(),void Tt(e.key,t.ctrlKey||t.metaKey)):void((t.ctrlKey||t.metaKey)&&et?Pt(e.key):(At(e.key),et&&(e=>{if(or.current)return;const t=e=>{const t=or.current,n=Lt.current;if(!t)return;if(t.y=e.clientY,ir.current(t.y),!n||!qt)return;const a=n.getBoundingClientRect(),l=a.top+Xe-t.y,o=t.y-(a.bottom-Xe);t.speed=l>0?-Math.min(l,40):o>0?Math.min(o,40):0,0!==t.speed&&null===t.frame&&(t.frame=requestAnimationFrame(r))},r=()=>{const e=or.current,t=Lt.current;e&&t&&0!==e.speed?(t.scrollTop+=e.speed,ir.current(e.y),e.frame=requestAnimationFrame(r)):e&&(e.frame=null)},n=()=>{const e=or.current;null!=e?.frame&&cancelAnimationFrame(e.frame),or.current=null,window.removeEventListener("pointermove",t),window.removeEventListener("pointerup",n),window.removeEventListener("pointercancel",n)};or.current={y:e,speed:0,frame:null,stop:n},window.addEventListener("pointermove",t),window.addEventListener("pointerup",n),window.addEventListener("pointercancel",n)})(t.clientY)))}else Dt.current.selectedKeys.has(e.key)||At(e.key)}n.useEffect(()=>()=>or.current?.stop(),[]);const ur=n.useMemo(()=>St.reduce((e,t)=>jt.has(t)?e+1:e,0),[St,jt]),dr=St.length>0&&ur===St.length,pr=p[q],mr=e=>Zt[e.key]??e.width,hr=(tt?pr:0)+Je.reduce((e,t)=>e+(mr(t)??f),0),fr=Je.length>0&&Je.every(e=>void 0!==mr(e)),gr=Je.length+(tt?1:0)+(fr?1:0),yr=n.useMemo(()=>{const e=[];return Je.forEach((t,r)=>{const n=e[e.length-1];n&&void 0!==n.label&&n.label===t.group?n.span+=1:e.push({label:t.group,span:1,from:r})}),e},[Je]),vr={padding:`0 ${Ve}`,borderBottom:"1px solid var(--n-line)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},br={...vr,height:`${Ye}px`,backgroundColor:"var(--n-panel-press)"},kr="odd"===Q?0:1,wr=n.useMemo(()=>new Intl.NumberFormat(Ie),[Ie]),xr=$e??"pages"===xe,Cr=x(Oe.range,{start:wr.format(0===kt?0:("pages"===xe?wt.start:0)+1),end:wr.format("pages"===xe?wt.end:kt),total:wr.format(kt)}),Sr=e=>{void 0===Ce&&gt(e),Me?.(e)},Mr=(r,n,a)=>{const l=r.sortable??oe,o=r.resizable??de,s=(i=r.key,mt.find(e=>e.key===i));var i;const c=s?mt.findIndex(e=>e.key===r.key)+1:0,u=r.headerAlign??r.align??"start";return t("th",{ref:e=>{e?tr.current.set(r.key,e):tr.current.delete(r.key)},scope:"col",rowSpan:a,"aria-sort":s?"asc"===s.direction?"ascending":"descending":void 0,className:$("relative font-semibold select-none",s?"text-(--n-accent)":"text-(--neba-muted-fg)",ee?"sticky z-20 [backdrop-filter:var(--neba-blur)]":""),style:{...br,top:ee?2!==a&&Qe?Ye:0:void 0,textAlign:u},children:[l?t("button",{type:"button",className:$(L,"end"===u?"justify-end":"center"===u?"justify-center":"justify-start"),onClick:e=>((e,t)=>{const r=g(mt,e,t&&"multiple"===se);void 0===ie&&pt(r),ue?.(r)})(r.key,e.shiftKey),children:[e("span",{className:"min-w-0 truncate",children:r.label??r.key}),e("span",{"aria-hidden":"true",className:$("flex items-center","desc"===s?.direction?"rotate-0":"rotate-180",s?"":"text-transparent group-hover/sort:text-inherit group-focus-visible/sort:text-inherit"),children:e(K,{})}),c>1?e("span",{"aria-hidden":"true",className:"text-[0.85em] tabular-nums",children:c}):null]}):e("span",{className:"block truncate",children:r.label??r.key}),o&&n<Je.length-1?e("span",{"aria-hidden":"true",className:H,onPointerDown:e=>((e,t)=>{t.preventDefault(),t.stopPropagation();const r=t.currentTarget,n={...Zt};for(const e of Je){const t=tr.current.get(e.key);t&&void 0===n[e.key]&&(n[e.key]=Math.round(t.getBoundingClientRect().width))}const a="rtl"===getComputedStyle(r).direction,l=t.clientX,o=n[e]??m,s=Je.find(t=>t.key===e)?.minWidth??f;rr.current=k({target:r,pointerId:t.pointerId,onMove:t=>{const r=(t.clientX-l)*(a?-1:1);er({...n,[e]:Math.max(s,Math.round(o+r))})},onEnd:()=>{rr.current=null}})})(r.key,e),onDoubleClick:()=>(e=>{const t={...Zt};delete t[e],er(t)})(r.key)}):null]},r.key)},Nr=t=>e("span",{className:"flex items-center justify-center",children:t}),Kr=t=>e("td",{role:Ze?"gridcell":void 0,style:{...vr,padding:0,overflow:"visible"},children:Nr(e(l,{size:q,color:U,checked:jt.has(t.key),"aria-label":Oe.selectRow,onCheckedChange:()=>{et?Pt(t.key):At(t.key)}}))}),zr=et?Nr(e(l,{size:q,color:U,checked:dr,indeterminate:ur>0&&!dr,"aria-label":Oe.selectAll,onCheckedChange:()=>{if(dr){const e=new Set(St);Et([...jt].filter(t=>!e.has(t)))}else Et([...new Set([...jt,...St])])}})):null,jr=fr?e("th",{"aria-hidden":"true",className:$(ee?"sticky top-0 z-20 [backdrop-filter:var(--neba-blur)]":""),style:{...br,padding:0}}):null,$r=(t,r)=>r>0?e("tr",{"aria-hidden":"true",style:{height:`${r}px`},children:e("td",{colSpan:gr,style:{padding:0,border:0}})},t):null;return t(a,{variant:O,size:q,color:U,density:X,elevation:Y,padded:!1,className:$("flex flex-col overflow-hidden",Ze?"has-[:focus-visible]:[outline:2px_solid_var(--n-ring)] has-[:focus-visible]:outline-offset-2":"",Be),style:{...T,...We},...Fe,children:[Ee||_(Te)?t("div",{className:"flex items-center gap-2",style:{padding:`${Ve} ${Ve}`,borderBottom:"1px solid var(--n-line)"},children:[Ee?e(i,{size:q,color:U,density:X,variant:"outline",type:"search",className:"w-full max-w-64",startIcon:e(I,{}),placeholder:Ae??Oe.search,"aria-label":Ae??Oe.search,value:_e??nt,onChange:e=>{const t=e.target.value;void 0===_e&&at(t),Sr(1),De?.(t)}}):null,_(Te)?e("div",{className:"ms-auto flex items-center gap-2",children:Te}):null]}):null,e("div",{ref:Lt,className:"min-h-0 flex-auto overflow-auto overscroll-contain",style:{height:A(V),maxHeight:A(G)},onScroll:Xt,children:t("table",{ref:It,role:Ze?"grid":void 0,"aria-label":re,"aria-multiselectable":et||void 0,"aria-rowcount":Ut?xt.length+1:void 0,"aria-activedescendant":Gt?`${Ue}-${$t}`:void 0,tabIndex:Ze?0:void 0,className:$("w-full text-start [outline:none]",j[q],"text-(--neba-fg)",Ze?"select-none":""),style:{tableLayout:"fixed",borderCollapse:"separate",borderSpacing:0,minWidth:`${hr}px`},onKeyDown:function(e){if(!Ze||e.target!==e.currentTarget)return;const t=Dt.current.paged;if(0===t.length)return;const r=null===$t?-1:Dt.current.pagedKeys.indexOf($t),n=Math.max(1,Math.floor((Bt||10*Xe)/Xe)-1);switch(e.key){case"ArrowDown":ar(r+1,e);break;case"ArrowUp":ar(-1===r?0:r-1,e);break;case"Home":ar(0,e);break;case"End":ar(t.length-1,e);break;case"PageDown":ar(-1===r?0:r+n,e);break;case"PageUp":ar(-1===r?0:r-n,e);break;case" ":-1!==r&&(e.preventDefault(),(e.ctrlKey||e.metaKey)&&et?Pt(t[r].key):At(t[r].key));break;case"a":case"A":(e.ctrlKey||e.metaKey)&&et&&(e.preventDefault(),Et(Dt.current.pagedKeys));break;case"Escape":e.preventDefault(),Et([]);break;case"Enter":-1!==r&&we&&(e.preventDefault(),we(t[r].row,Ct+r))}},children:[te?e("caption",{className:$(R[q],"text-(--neba-muted-fg)"),style:{padding:`0.5rem ${Ve}`,textAlign:"start"},children:te}):null,t("colgroup",{children:[tt?e("col",{style:{width:`${pr}px`}}):null,Je.map(t=>{const r=mr(t);return e("col",{style:void 0===r?void 0:{width:`${r}px`}},t.key)}),fr?e("col",{}):null]}),t("thead",{children:[Qe?t("tr",{style:{height:`${Ye}px`},children:[tt?e("th",{scope:"col",rowSpan:2,className:$(ee?"sticky top-0 z-20 [backdrop-filter:var(--neba-blur)]":""),style:{...br,padding:0,overflow:"visible"},children:zr}):null,yr.map(t=>void 0===t.label?Mr(Je[t.from],t.from,2):e("th",{scope:"colgroup",colSpan:t.span,className:$("font-semibold text-(--neba-muted-fg) select-none",ee?"sticky top-0 z-20 [backdrop-filter:var(--neba-blur)]":""),style:{...br,textAlign:"center"},children:t.label},`group-${t.from}`)),fr?n.cloneElement(jr,{rowSpan:2}):null]}):null,t("tr",{style:{height:`${Ye}px`},children:[tt&&!Qe?e("th",{scope:"col",className:$(ee?"sticky top-0 z-20 [backdrop-filter:var(--neba-blur)]":""),style:{...br,padding:0,overflow:"visible"},children:zr}):null,Je.map((e,t)=>Qe&&void 0===e.group?null:Mr(e,t)),fr&&!Qe?jr:null]})]}),e("tbody",{ref:Ht,children:0===xt.length?e("tr",{children:e("td",{colSpan:gr,className:"text-(--neba-muted-fg)",style:{padding:`2rem ${Ve}`,textAlign:"center"},children:ne??qe.title})}):t(r,{children:[$r("before",Yt.before),Vt.map((r,n)=>{const a=Yt.start+n,l=jt.has(r.key),o=$t===r.key;return t("tr",{id:`${Ue}-${r.key}`,"aria-selected":Ze?l:void 0,"aria-rowindex":Ut?a+2:void 0,"data-neba-row":r.key,className:$(P,l?"[--n-row:var(--n-soft-press)]":!1!==Q&&a%2===kr?"[--n-row:var(--n-stripe)]":"",!l&&Z?"hover:[--n-row:var(--n-soft)]":"",o&&Ze?"[box-shadow:inset_0_0_0_1px_var(--n-ring)]":"",Ze||ke?"cursor-default":""),style:{height:`${Xe}px`,backgroundColor:"var(--n-row)"},onPointerDown:e=>cr(r,e),onClick:e=>ke?.(r.row,Ct+a,e),onDoubleClick:()=>we?.(r.row,Ct+a),children:[tt?Kr(r):null,Je.map(t=>e("td",{role:Ze?"gridcell":void 0,style:{...vr,textAlign:t.align??"start"},children:t.render?t.render(r.row,Ct+a):r.row[t.key]},t.key)),fr?e("td",{"aria-hidden":"true",style:{...vr,padding:0}}):null]},r.key)}),$r("after",Yt.after)]})})]})}),xr?t("div",{className:$("flex flex-wrap items-center gap-3",R[q]),style:{padding:`0.375rem ${Ve}`,borderTop:"1px solid var(--n-line)"},children:[e("span",{className:"text-(--neba-muted-fg) tabular-nums",children:Cr}),Ze&&jt.size>0?e("span",{className:"text-(--n-accent) tabular-nums",children:x(Oe.selected,{count:wr.format(jt.size)})}):null,t("div",{className:"ms-auto flex items-center gap-2",children:["pages"===xe&&je.length>0?e(r,{children:e(s,{size:q,color:U,density:X,variant:"outline",label:Oe.rowsPerPage,items:je.map(e=>({value:e})),value:bt,onValueChange:e=>{const t=Number(e);void 0===Ne&&vt(t),Sr(Math.floor(wt.start/t)+1),ze?.(t)}})}):null,"pages"===xe?e(o,{size:q,color:U,count:wt.pages,page:wt.page,siblingCount:0,onPageChange:Sr}):null]})]}):null,!xr&&Ut?e("span",{className:E,"aria-live":"polite",children:Cr}):null]})}
1
+ "use client";import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import*as r from"react";import{Box as a}from"../box/Box.js";import{Button as l}from"../button/Button.js";import{Checkbox as o}from"../checkbox/Checkbox.js";import{Pagination as s}from"../pagination/Pagination.js";import{Select as i}from"../select/Select.js";import{TextField as c}from"../text-field/TextField.js";import{compareValues as u,dataHeaderHeights as d,dataRowHeights as p,dataTickWidths as m,defaultColumnWidth as g,keysBetween as f,minColumnWidth as h,nextSort as y,pageBounds as b,sortRows as v,virtualWindow as k}from"../../internal/data-table.js";import{beginPointerDrag as x}from"../../internal/drag.js";import{emptyMessages as w,fillMessage as C,tableMessages as S,useMessages as M}from"../../internal/i18n.js";import{searchHaystack as N,searchText as K}from"../../internal/search.js";import{ChevronIcon as z}from"../../internal/icons.js";import{observeResize as _}from"../../internal/observe.js";import{downloadText as j,toCsv as $}from"../../internal/csv.js";import{controlTextLeadingClasses as D,cx as E,hasContent as P,metaTextClasses as T,paddingXValues as R,srOnlyClasses as A,toLength as I}from"../../internal/styles.js";import{useStyleDefaults as B}from"../../internal/defaults.js";const L=["[--n-row:transparent]","[transition:background-color_var(--neba-duration)_var(--neba-ease)]"].join(" "),H={"--n-stripe":"color-mix(in oklab, var(--neba-fg) 4%, transparent)"},F=["group/sort flex w-full min-w-0 cursor-pointer items-center gap-1","text-inherit [outline:none]","[transition:color_var(--neba-duration)_var(--neba-ease)]","hover:text-(--n-accent)","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-1","[&_svg]:pointer-events-none [&_svg]:size-[1.15em] [&_svg]:shrink-0"].join(" "),O=["absolute inset-y-0 z-10 w-2 cursor-col-resize select-none","end-0 translate-x-1/2 rtl:-translate-x-1/2","after:absolute after:inset-y-1 after:start-1/2 after:w-px","after:[background:transparent]","after:[transition:background_var(--neba-duration)_var(--neba-ease)]","hover:after:[background:var(--n-accent)] data-[dragging]:after:[background:var(--n-accent)]"].join(" ");function W(){return t("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[e("circle",{cx:"7.25",cy:"7.25",r:"4.75",stroke:"currentColor",strokeWidth:"1.5"}),e("path",{d:"m10.75 10.75 2.75 2.75",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}export function DataTable(X){const{headers:V,items:q,getRowKey:G,variant:U="outline",size:Y="sm",color:J="primary",density:Q="compact",elevation:Z=0,height:ee,maxHeight:te,rowHeight:ne,striped:re=!1,hoverable:ae=!0,stickyHeader:le=!0,caption:oe,label:se,empty:ie,virtual:ce=!0,overscan:ue=8,sortable:de=!1,sortMode:pe="single",sort:me,defaultSort:ge,onSortChange:fe,resizable:he=!1,columnWidths:ye,columnOrder:be,defaultColumnOrder:ve,onColumnOrderChange:ke,reorderable:xe=!1,defaultColumnWidths:we,onColumnWidthsChange:Ce,selectionMode:Se="none",selected:Me,defaultSelected:Ne,onSelectedChange:Ke,checkboxes:ze=!1,onRowClick:_e,onRowActivate:je,paging:$e="scroll",page:De,defaultPage:Ee=1,onPageChange:Pe,pageSize:Te,defaultPageSize:Re=25,onPageSizeChange:Ae,pageSizeOptions:Ie=[10,25,50,100],footer:Be,search:Le,defaultSearch:He,onSearchChange:Fe,searchable:Oe=!1,searchPlaceholder:We,filter:Xe,toolbar:Ve,exportable:qe=!1,exportFileName:Ge="table.csv",onExport:Ue,onCellEdit:Ye,groupBy:Je,collapsibleGroups:Qe=!0,defaultCollapsedGroups:Ze,manual:et=!1,rowCount:tt,locale:nt,className:rt,style:at,...lt}=B(X,["size","density","variant","locale"]),ot=M(S,nt),st=M(w,nt),it=r.useId(),ct=ne??p[Q][Y],ut=d[Q][Y],dt=R[Q][Y],pt=r.useMemo(()=>new Set(!0===et?["sort","filter","pages"]:et||[]),[et]),[mt,gt]=r.useState(()=>ve??[]),ft=be??mt,ht=r.useMemo(()=>{const e=V.filter(e=>!e.hidden),t=ft.map(t=>e.find(e=>e.key===t)).filter(e=>void 0!==e),n=e.filter(e=>!ft.includes(e.key)),r=0===ft.length?e:[...t,...n],a=e=>"start"===e.pinned?0:"end"===e.pinned?2:1;return r.map((e,t)=>({column:e,index:t})).sort((e,t)=>a(e.column)-a(t.column)||e.index-t.index).map(e=>e.column)},[V,ft]),yt=ht.some(e=>void 0!==e.group),bt="none"!==Se,vt="multiple"===Se,kt=bt&&ze,xt=r.useMemo(()=>q.map((e,t)=>{const n=G?G(e,t):t;return{row:e,identity:n,key:String(n),origin:t}}),[q,G]),[wt,Ct]=r.useState(He??""),St=(Le??wt).trim(),Mt=""!==St&&!pt.has("filter"),Nt=r.useMemo(()=>ht.filter(e=>!1!==e.searchable),[ht]),Kt=r.useMemo(()=>Mt&&0!==Nt.length?xt.map(e=>N(Nt.map(t=>t.value?t.value(e.row):e.row[t.key]))):null,[xt,Nt,Mt]),zt=r.useMemo(()=>{if(pt.has("filter"))return xt;const e=K(St),t=""!==e&&Kt?xt.filter(t=>Kt[t.origin].includes(e)):xt;return Xe?t.filter(e=>Xe(e.row,e.origin)):t},[xt,St,Xe,pt,Kt]),_t=r.useMemo(()=>new Intl.Collator(nt,{numeric:!0,sensitivity:"base"}),[nt]),[jt,$t]=r.useState(ge??[]),Dt=me??jt,Et=r.useMemo(()=>pt.has("sort")?zt:v(zt,Dt,e=>{const t=ht.find(t=>t.key===e);if(!t)return null;if(t.compare)return(e,n)=>t.compare(e.row,n.row);const n=t.value?t.value:e=>e[t.key];return(e,t)=>u(n(e.row),n(t.row),_t)}),[zt,Dt,ht,_t,pt]),[Pt,Tt]=r.useState(Ee),[Rt,At]=r.useState(Re),It=Te??Rt,[Bt,Lt]=r.useState(()=>new Set(Ze??[])),Ht=r.useMemo(()=>{if(!Je)return null;const e=[],t=new Map;for(const n of Et){const r=Je(n.row)??"";t.has(r)||(t.set(r,[]),e.push(r)),t.get(r).push(n)}return{order:[...e].sort((e,t)=>""===e?-1:""===t?1:0),byLabel:t}},[Et,Je]),Ft=r.useMemo(()=>Ht?Ht.order.flatMap(e=>Bt.has(e)?[]:Ht.byLabel.get(e)??[]):Et,[Ht,Bt,Et]),Ot=pt.has("pages")?tt??Ft.length:Ft.length,Wt=b(Ot,De??Pt,It),Xt=r.useMemo(()=>"pages"!==$e||pt.has("pages")?Ft:Ft.slice(Wt.start,Wt.end),[Ft,$e,pt,Wt.start,Wt.end]),Vt="pages"===$e?Wt.start:0,qt=r.useMemo(()=>Xt.map(e=>e.key),[Xt]),Gt=r.useMemo(()=>new Map(xt.map(e=>[e.key,e])),[xt]),[Ut,Yt]=r.useState(Ne??[]),Jt=Me??Ut,Qt=r.useMemo(()=>new Set(Jt.map(String)),[Jt]),[Zt,en]=r.useState(null),tn=r.useRef(null),nn=r.useRef({paged:Xt,pagedKeys:qt,byKey:Gt,selectedKeys:Qt,multiple:vt});nn.current={paged:Xt,pagedKeys:qt,byKey:Gt,selectedKeys:Qt,multiple:vt};const rn=r.useCallback(e=>{const t=[],n=[];for(const r of e){const e=nn.current.byKey.get(r);e&&(t.push(e.identity),n.push(e.row))}void 0===Me&&Yt(t),Ke?.(t,n)},[Me,Ke]),an=r.useCallback(e=>{tn.current=e,rn([e])},[rn]),ln=r.useCallback(e=>{const t=nn.current.selectedKeys,n=new Set(t);n.has(e)?n.delete(e):n.add(e),tn.current=e,rn([...n])},[rn]),on=r.useCallback((e,t)=>{const n=nn.current.pagedKeys,r=tn.current??n[0];if(void 0===r)return;const a=f(n,r,e);0!==a.length&&rn(t?[...new Set([...nn.current.selectedKeys,...a])]:a)},[rn]),sn=r.useRef(null),cn=r.useRef(null),un=r.useRef(null),[dn,pn]=r.useState(0),[mn,gn]=r.useState(0),fn=void 0!==ee||void 0!==te,hn=ce&&fn&&Xt.length>0&&!Je;r.useLayoutEffect(()=>{const e=sn.current;if(e&&hn)return pn(e.clientHeight),_(e,e=>pn(e.contentRect.height))},[hn]);const yn=r.useCallback(e=>{if(!hn)return;const t=Math.floor(e.currentTarget.scrollTop/ct)*ct;gn(e=>e===t?e:t)},[hn,ct]),bn=hn?k(mn,dn,ct,Xt.length,ue):{start:0,end:Xt.length,before:0,after:0},vn=Xt.slice(bn.start,bn.end),kn=bt&&null!==Zt&&vn.some(e=>e.key===Zt),[xn,wn]=r.useState(we??{}),Cn=ye??xn,Sn=r.useCallback(e=>{void 0===ye&&wn(e),Ce?.(e)},[ye,Ce]),Mn=r.useRef(new Map),Nn=r.useRef(null),Kn=r.useRef(null),[zn,_n]=r.useState(null),[jn,$n]=r.useState(null);r.useEffect(()=>()=>{Nn.current?.(),Kn.current?.()},[]);const Dn=(e,t)=>{if(0!==t.button)return;const n=t.currentTarget,r=t.clientX;let a=!1;Kn.current=x({target:n,pointerId:t.pointerId,onMove:t=>{if(!a){if(Math.abs(t.clientX-r)<6)return;a=!0,_n(e)}const n=ht.find(e=>{if(e.pinned)return!1;const n=Mn.current.get(e.key);if(!n)return!1;const r=n.getBoundingClientRect();return t.clientX>=r.left&&t.clientX<=r.right});$n(n&&n.key!==e?n.key:null)},onEnd:()=>{Kn.current=null,_n(e=>($n(t=>{if(e&&t&&e!==t){const r=ht.map(e=>e.key),a=r.indexOf(e),l=r.indexOf(t);r.splice(l,0,...r.splice(a,1)),n=r,void 0===be&&gt(n),ke?.(n)}var n;return null}),null))}})},En=r.useCallback(e=>{const t=sn.current;if(!t||!fn)return;const n=le?ut*(yt?2:1):0,r=e*ct;r<t.scrollTop+n?t.scrollTop=Math.max(0,r-n):r+ct>t.scrollTop+t.clientHeight&&(t.scrollTop=r+ct-t.clientHeight)},[fn,le,ut,yt,ct]),Pn=(e,t)=>{const n=nn.current.paged,r=Math.min(Math.max(e,0),n.length-1),a=n[r];a&&(t.preventDefault(),en(a.key),En(r),t.shiftKey&&nn.current.multiple?on(a.key,!1):t.ctrlKey||t.metaKey||an(a.key))},Tn=(e,t)=>{const n=sn.current;if(!n||!fn)return;t.preventDefault();const r=Math.max(0,n.scrollHeight-n.clientHeight),a="start"===e?0:"end"===e?r:n.scrollTop+e;n.scrollTop=Math.min(Math.max(a,0),r)};const Rn=r.useCallback(e=>{const t=cn.current,n=nn.current.paged;if(!t||0===n.length)return null;const r=t.getBoundingClientRect().top,a=Math.floor((e-r)/ct);return Math.min(Math.max(a,0),n.length-1)},[ct]),An=r.useRef(null),In=r.useCallback(e=>{const t=Rn(e),n=null===t?void 0:nn.current.paged[t];n&&(en(n.key),on(n.key,!1))},[Rn,on]),Bn=r.useRef(In);Bn.current=In;function Ln(e,t){if(bt&&!t.target.closest('button, a, input, select, textarea, [role="button"]'))if(un.current?.focus({preventScroll:!0}),en(e.key),2!==t.button){if(0===t.button)return t.shiftKey&&vt?(t.preventDefault(),void on(e.key,t.ctrlKey||t.metaKey)):void((t.ctrlKey||t.metaKey)&&vt?ln(e.key):(an(e.key),vt&&(e=>{if(An.current)return;const t=e=>{const t=An.current,r=sn.current;if(!t)return;if(t.y=e.clientY,Bn.current(t.y),!r||!fn)return;const a=r.getBoundingClientRect(),l=a.top+ct-t.y,o=t.y-(a.bottom-ct);t.speed=l>0?-Math.min(l,40):o>0?Math.min(o,40):0,0!==t.speed&&null===t.frame&&(t.frame=requestAnimationFrame(n))},n=()=>{const e=An.current,t=sn.current;e&&t&&0!==e.speed?(t.scrollTop+=e.speed,Bn.current(e.y),e.frame=requestAnimationFrame(n)):e&&(e.frame=null)},r=()=>{const e=An.current;null!=e?.frame&&cancelAnimationFrame(e.frame),An.current=null,window.removeEventListener("pointermove",t),window.removeEventListener("pointerup",r),window.removeEventListener("pointercancel",r)};An.current={y:e,speed:0,frame:null,stop:r},window.addEventListener("pointermove",t),window.addEventListener("pointerup",r),window.addEventListener("pointercancel",r)})(t.clientY)))}else nn.current.selectedKeys.has(e.key)||an(e.key)}r.useEffect(()=>()=>An.current?.stop(),[]);const Hn=r.useMemo(()=>qt.reduce((e,t)=>Qt.has(t)?e+1:e,0),[qt,Qt]),Fn=qt.length>0&&Hn===qt.length,On=m[Y],Wn=e=>Cn[e.key]??e.width,Xn=(kt?On:0)+ht.reduce((e,t)=>e+(Wn(t)??h),0),Vn=ht.length>0&&ht.every(e=>void 0!==Wn(e)),qn=ht.length+(kt?1:0)+(Vn?1:0),Gn=r.useMemo(()=>{const e=[];return ht.forEach((t,n)=>{const r=e[e.length-1];r&&void 0!==r.label&&r.label===t.group?r.span+=1:e.push({label:t.group,span:1,from:n})}),e},[ht]),Un=r.useMemo(()=>{const e=new Map,t=new Map;let n=kt?On:0;for(const t of ht)"start"===t.pinned&&(e.set(t.key,n),n+=Wn(t)??g);let r=0;for(let e=ht.length-1;e>=0;e-=1){const n=ht[e];"end"===n.pinned&&(t.set(n.key,r),r+=Wn(n)??g)}return{start:e,end:t}},[ht,Cn,kt,On]),Yn=(e,t)=>{if(!e.pinned)return{};const n="start"===e.pinned?Un.start.get(e.key):Un.end.get(e.key);return{position:"sticky",insetInlineStart:"start"===e.pinned?`${n??0}px`:void 0,insetInlineEnd:"end"===e.pinned?`${n??0}px`:void 0,zIndex:t?3:1,backgroundColor:"var(--n-panel-press)",backgroundImage:t?void 0:"linear-gradient(var(--n-row), var(--n-row))"}},Jn={padding:`0 ${dt}`,borderBottom:"1px solid var(--n-line)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},Qn={...Jn,height:`${ut}px`,backgroundColor:"var(--n-panel-press)"},Zn="odd"===re?0:1,er=r.useMemo(()=>new Intl.NumberFormat(nt),[nt]),tr=Be??"pages"===$e,nr=C(ot.range,{start:er.format(0===Ot?0:("pages"===$e?Wt.start:0)+1),end:er.format("pages"===$e?Wt.end:Ot),total:er.format(Ot)}),rr=e=>{void 0===De&&Tt(e),Pe?.(e)},ar=(n,r)=>{const a=Qt.has(n.key),l=Zt===n.key;return t("tr",{id:`${it}-${n.key}`,"aria-selected":bt?a:void 0,"aria-rowindex":hn?r+2:void 0,"data-neba-row":n.key,className:E(L,a?"[--n-row:var(--n-soft-press)]":!1!==re&&r%2===Zn?"[--n-row:var(--n-stripe)]":"",!a&&ae?"hover:[--n-row:var(--n-soft)]":"",l&&bt?"[box-shadow:inset_0_0_0_1px_var(--n-ring)]":"",bt||_e?"cursor-default":""),style:{height:`${ct}px`,backgroundColor:"var(--n-row)"},onPointerDown:e=>Ln(n,e),onClick:e=>_e?.(n.row,Vt+r,e),onDoubleClick:()=>je?.(n.row,Vt+r),children:[kt?pr(n):null,ht.map(t=>{const a=cr(t,n.row),l=sr?.key===n.key&&sr.column===t.key;return e("td",{role:bt?"gridcell":void 0,style:{...Jn,...Yn(t,!1),textAlign:t.align??"start",cursor:a&&!l?"cell":void 0},onDoubleClick:a?e=>{e.stopPropagation(),ir({key:n.key,column:t.key})}:void 0,children:l?ur(n,t):t.render?t.render(n.row,Vt+r):n.row[t.key]},t.key)}),Vn?e("td",{"aria-hidden":"true",style:{...Jn,padding:0}}):null]},n.key)},lr=(n,r,a)=>{const l=n.sortable??de,o=n.resizable??he,s=xe&&!n.pinned,i=(c=n.key,Dt.find(e=>e.key===c));var c;const u=i?Dt.findIndex(e=>e.key===n.key)+1:0,d=n.headerAlign??n.align??"start";return t("th",{ref:e=>{e?Mn.current.set(n.key,e):Mn.current.delete(n.key)},scope:"col",rowSpan:a,"aria-sort":i?"asc"===i.direction?"ascending":"descending":void 0,"data-column":n.key,"data-dragging":zn===n.key||void 0,className:E("relative font-semibold select-none",i?"text-(--n-accent)":"text-(--neba-muted-fg)",le?"sticky z-20 [backdrop-filter:var(--neba-blur)]":"",s?"cursor-grab":"",zn===n.key?"opacity-60":"",jn===n.key?"shadow-[inset_2px_0_0_var(--n-accent)]":""),style:{...Qn,...Yn(n,!0),top:le?2!==a&&yt?ut:0:void 0,textAlign:d},onPointerDown:s?e=>Dn(n.key,e):void 0,children:[l?t("button",{type:"button",className:E(F,"end"===d?"justify-end":"center"===d?"justify-center":"justify-start"),onClick:e=>((e,t)=>{const n=y(Dt,e,t&&"multiple"===pe);void 0===me&&$t(n),fe?.(n)})(n.key,e.shiftKey),children:[e("span",{className:"min-w-0 truncate",children:n.label??n.key}),e("span",{"aria-hidden":"true",className:E("flex items-center","desc"===i?.direction?"rotate-0":"rotate-180",i?"":"text-transparent group-hover/sort:text-inherit group-focus-visible/sort:text-inherit"),children:e(z,{})}),u>1?e("span",{"aria-hidden":"true",className:"text-[0.85em] tabular-nums",children:u}):null]}):e("span",{className:"block truncate",children:n.label??n.key}),o&&r<ht.length-1?e("span",{"aria-hidden":"true",className:O,onPointerDown:e=>((e,t)=>{t.preventDefault(),t.stopPropagation();const n=t.currentTarget,r={...Cn};for(const e of ht){const t=Mn.current.get(e.key);t&&void 0===r[e.key]&&(r[e.key]=Math.round(t.getBoundingClientRect().width))}const a="rtl"===getComputedStyle(n).direction,l=t.clientX,o=r[e]??g,s=ht.find(t=>t.key===e)?.minWidth??h;Nn.current=x({target:n,pointerId:t.pointerId,onMove:t=>{const n=(t.clientX-l)*(a?-1:1);Sn({...r,[e]:Math.max(s,Math.round(o+n))})},onEnd:()=>{Nn.current=null}})})(n.key,e),onDoubleClick:()=>(e=>{const t={...Cn};delete t[e],Sn(t)})(n.key)}):null]},n.key)},or=(n,r)=>{const a=Bt.has(n),l=Qe,o=r.map(e=>e.row),s=()=>Lt(e=>{const t=new Set(e);return t.has(n)?t.delete(n):t.add(n),t}),i=t("span",{className:"flex min-w-0 items-center gap-1.5",children:[l?e("span",{"aria-hidden":"true",className:E("flex items-center text-(--neba-muted-fg)","[transition:rotate_var(--neba-duration)_var(--neba-ease)]",a?"-rotate-90 rtl:rotate-90":""),children:e(z,{})}):null,e("span",{className:"truncate font-semibold",children:""===n?st.title:n}),e("span",{className:"shrink-0 text-(--neba-muted-fg) tabular-nums",children:er.format(r.length)})]});return t("tr",{"data-neba-group":n,style:{height:`${ct}px`,backgroundColor:"var(--n-soft)"},children:[kt?e("td",{style:{...Jn,padding:0}}):null,ht.map((t,n)=>e("td",{colSpan:1,style:{...Jn,...Yn(t,!1),textAlign:0===n?"start":t.align??"start"},children:0===n?l?e("button",{type:"button","aria-expanded":!a,className:"flex w-full min-w-0 items-center text-start [outline:none] focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:[outline-offset:-2px]",onClick:s,children:i}):i:t.aggregate?e("span",{className:"tabular-nums",children:t.aggregate(o)}):null},t.key)),Vn?e("td",{"aria-hidden":"true",style:{...Jn,padding:0}}):null]})},[sr,ir]=r.useState(null),cr=(e,t)=>void 0!==Ye&&("function"==typeof e.editable?e.editable(t):Boolean(e.editable)),ur=(t,n)=>{const r=n.value?n.value(t.row):t.row[n.key],a=e=>{ir(null);const a="number"===n.editType?Number(e):e;"number"===n.editType&&Number.isNaN(a)||String(a)!==String(r??"")&&Ye?.(t.row,n,a)};return e("input",{autoFocus:!0,type:"number"===n.editType?"number":"text",defaultValue:null==r?"":String(r),"aria-label":"string"==typeof n.label?n.label:n.key,className:"w-full bg-transparent [font:inherit] text-inherit [outline:none]",style:{textAlign:n.align??"start"},onPointerDown:e=>e.stopPropagation(),onBlur:e=>a(e.currentTarget.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),a(e.currentTarget.value)),"Escape"===e.key&&(e.stopPropagation(),ir(null))}})},dr=t=>e("span",{className:"flex items-center justify-center",children:t}),pr=t=>e("td",{role:bt?"gridcell":void 0,style:{...Jn,padding:0,overflow:"visible"},children:dr(e(o,{size:Y,color:J,checked:Qt.has(t.key),"aria-label":ot.selectRow,onCheckedChange:()=>{vt?ln(t.key):an(t.key)}}))}),mr=vt?dr(e(o,{size:Y,color:J,checked:Fn,indeterminate:Hn>0&&!Fn,"aria-label":ot.selectAll,onCheckedChange:()=>{if(Fn){const e=new Set(qt);rn([...Qt].filter(t=>!e.has(t)))}else rn([...new Set([...Qt,...qt])])}})):null,gr=Vn?e("th",{"aria-hidden":"true",className:E(le?"sticky top-0 z-20 [backdrop-filter:var(--neba-blur)]":""),style:{...Qn,padding:0}}):null,fr=(t,n)=>n>0?e("tr",{"aria-hidden":"true",style:{height:`${n}px`},children:e("td",{colSpan:qn,style:{padding:0,border:0}})},t):null;return t(a,{variant:U,size:Y,color:J,density:Q,elevation:Z,padded:!1,className:E("flex flex-col overflow-hidden",bt?"has-[:focus-visible]:[outline:2px_solid_var(--n-ring)] has-[:focus-visible]:outline-offset-2":"",rt),style:{...H,...at},...lt,children:[Oe||qe||P(Ve)?t("div",{className:"flex items-center gap-2",style:{padding:`${dt} ${dt}`,borderBottom:"1px solid var(--n-line)"},children:[Oe?e(c,{size:Y,color:J,density:Q,variant:"outline",type:"search",className:"w-full max-w-64",startIcon:e(W,{}),placeholder:We??ot.search,"aria-label":We??ot.search,value:Le??wt,onChange:e=>{const t=e.target.value;void 0===Le&&Ct(t),rr(1),Fe?.(t)}}):null,qe||P(Ve)?t("div",{className:"ms-auto flex items-center gap-2",children:[Ve,qe?e(l,{size:Y,color:J,density:Q,variant:"outline",onClick:()=>{const e=ht.filter(e=>!1!==e.exportable),t=e.map(e=>"string"==typeof e.label?e.label:e.key),n=Et.map(t=>e.map(e=>e.exportValue?e.exportValue(t.row):e.value?e.value(t.row):t.row[e.key])),r=$([t,...n]);Ue?Ue(r):j(r,Ge,"text/csv;charset=utf-8")},children:ot.exportCsv}):null]}):null]}):null,e("div",{ref:sn,className:"min-h-0 flex-auto overflow-auto overscroll-contain",style:{height:I(ee),maxHeight:I(te)},onScroll:yn,children:t("table",{ref:un,role:bt?"grid":void 0,"aria-label":se,"aria-multiselectable":vt||void 0,"aria-rowcount":hn?Xt.length+1:void 0,"aria-activedescendant":kn?`${it}-${Zt}`:void 0,tabIndex:bt?0:void 0,className:E("w-full text-start [outline:none]",D[Y],"text-(--neba-fg)",bt?"select-none":""),style:{tableLayout:"fixed",borderCollapse:"separate",borderSpacing:0,minWidth:`${Xn}px`},onKeyDown:function(e){if(!bt||e.target!==e.currentTarget)return;const t=nn.current.paged;if(0===t.length)return;const n=null===Zt?-1:nn.current.pagedKeys.indexOf(Zt),r=Math.max(1,Math.floor((dn||10*ct)/ct)-1);switch(e.key){case"ArrowDown":Pn(n+1,e);break;case"ArrowUp":Pn(-1===n?0:n-1,e);break;case"Home":Tn("start",e);break;case"End":Tn("end",e);break;case"PageDown":Tn(r*ct,e);break;case"PageUp":Tn(-r*ct,e);break;case" ":-1!==n&&(e.preventDefault(),(e.ctrlKey||e.metaKey)&&vt?ln(t[n].key):an(t[n].key));break;case"a":case"A":(e.ctrlKey||e.metaKey)&&vt&&(e.preventDefault(),rn(nn.current.pagedKeys));break;case"Escape":e.preventDefault(),rn([]);break;case"Enter":-1!==n&&je&&(e.preventDefault(),je(t[n].row,Vt+n))}},children:[oe?e("caption",{className:E(T[Y],"text-(--neba-muted-fg)"),style:{padding:`0.5rem ${dt}`,textAlign:"start"},children:oe}):null,t("colgroup",{children:[kt?e("col",{style:{width:`${On}px`}}):null,ht.map(t=>{const n=Wn(t);return e("col",{style:void 0===n?void 0:{width:`${n}px`}},t.key)}),Vn?e("col",{}):null]}),t("thead",{children:[yt?t("tr",{style:{height:`${ut}px`},children:[kt?e("th",{scope:"col",rowSpan:2,className:E(le?"sticky top-0 z-20 [backdrop-filter:var(--neba-blur)]":""),style:{...Qn,padding:0,overflow:"visible"},children:mr}):null,Gn.map(t=>void 0===t.label?lr(ht[t.from],t.from,2):e("th",{scope:"colgroup",colSpan:t.span,className:E("font-semibold text-(--neba-muted-fg) select-none",le?"sticky top-0 z-20 [backdrop-filter:var(--neba-blur)]":""),style:{...Qn,textAlign:"center"},children:t.label},`group-${t.from}`)),Vn?r.cloneElement(gr,{rowSpan:2}):null]}):null,t("tr",{style:{height:`${ut}px`},children:[kt&&!yt?e("th",{scope:"col",className:E(le?"sticky top-0 z-20 [backdrop-filter:var(--neba-blur)]":""),style:{...Qn,padding:0,overflow:"visible"},children:mr}):null,ht.map((e,t)=>yt&&void 0===e.group?null:lr(e,t)),Vn&&!yt?gr:null]})]}),e("tbody",{ref:cn,children:0===Xt.length?e("tr",{children:e("td",{colSpan:qn,className:"text-(--neba-muted-fg)",style:{padding:`2rem ${dt}`,textAlign:"center"},children:ie??st.title})}):t(n,{children:[fr("before",bn.before),Ht?Ht.order.map(e=>{const n=Ht.byLabel.get(e)??[],a=n.filter(e=>qt.includes(e.key));return t(r.Fragment,{children:[or(e,n),a.map(e=>ar(e,Xt.indexOf(e)))]},e||"\0")}):vn.map((e,t)=>ar(e,bn.start+t)),fr("after",bn.after)]})})]})}),tr?t("div",{className:E("flex flex-wrap items-center gap-3",T[Y]),style:{padding:`0.375rem ${dt}`,borderTop:"1px solid var(--n-line)"},children:[e("span",{className:"text-(--neba-muted-fg) tabular-nums",children:nr}),bt&&Qt.size>0?e("span",{className:"text-(--n-accent) tabular-nums",children:C(ot.selected,{count:er.format(Qt.size)})}):null,t("div",{className:"ms-auto flex items-center gap-2",children:["pages"===$e&&Ie.length>0?e(n,{children:e(i,{size:Y,color:J,density:Q,variant:"outline",label:ot.rowsPerPage,items:Ie.map(e=>({value:e})),value:It,onValueChange:e=>{const t=Number(e);void 0===Te&&At(t),rr(Math.floor(Wt.start/t)+1),Ae?.(t)}})}):null,"pages"===$e?e(s,{size:Y,color:J,count:Wt.pages,page:Wt.page,siblingCount:0,onPageChange:rr}):null]})]}):null,!tr&&hn?e("span",{className:A,"aria-live":"polite",children:nr}):null]})}
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { type PickerLabels } from '../../internal/calendar.js';
3
3
  import { type PickerShellProps } from '../../internal/picker.js';
4
- import type { NebaWeekday } from '../../types.js';
4
+ import type { NebaDateGranularity, NebaWeekday } from '../../types.js';
5
5
  /**
6
6
  * What the four pickers agree on, so a caller who has learned one has learned
7
7
  * the others. Spelled out here rather than in `internal/` because these are the
@@ -17,15 +17,34 @@ export interface DatePickerProps extends PickerShellProps {
17
17
  open?: boolean;
18
18
  defaultOpen?: boolean;
19
19
  onOpenChange?: (open: boolean) => void;
20
+ /**
21
+ * Which unit the picker asks for: a day, a whole month, or a whole year.
22
+ *
23
+ * At `month` and `year` the calendar opens on that grid and stops there, and
24
+ * the value is the first day of what was chosen — 1 March, 1 January. The
25
+ * grid above is still reachable, so a year picker is one control and a month
26
+ * picker is still two clicks from any month of any year.
27
+ *
28
+ * Everything else follows it: the trigger's default `format`, what the
29
+ * footer's shortcut says, how `name` submits, and the unit `minDate`,
30
+ * `maxDate` and `shouldDisableDate` are read at.
31
+ * @default 'day'
32
+ */
33
+ granularity?: NebaDateGranularity;
20
34
  /** Which month the calendar opens on when there is no value. @default this one */
21
35
  defaultMonth?: Date;
22
- /** The earliest day that may be chosen. Day-granular — the time is ignored. */
36
+ /**
37
+ * The earliest date that may be chosen, compared at `granularity`. A minimum
38
+ * of 15 March leaves the 14th out at `day` and leaves March in at `month`:
39
+ * the cell stands for the whole month, and part of that month is allowed.
40
+ */
23
41
  minDate?: Date | null;
24
- /** The latest day that may be chosen. */
42
+ /** The latest date that may be chosen, read the same way. */
25
43
  maxDate?: Date | null;
26
44
  /**
27
- * Blocks individual days that are inside the range but still not available —
28
- * weekends, holidays, a room that is already booked.
45
+ * Blocks individual cells that are inside the range but still not available —
46
+ * weekends, holidays, a room that is already booked. Called with the value
47
+ * that cell would produce, so at `month` it is handed the 1st.
29
48
  */
30
49
  shouldDisableDate?: (date: Date) => boolean;
31
50
  /**
@@ -38,20 +57,28 @@ export interface DatePickerProps extends PickerShellProps {
38
57
  /**
39
58
  * How the trigger writes the chosen date. Passed straight to `Intl`, so
40
59
  * `{ dateStyle: 'full' }` and `{ year: '2-digit', month: 'narrow' }` both work.
41
- * @default { dateStyle: 'medium' }
60
+ * Defaults to what `granularity` asked for — a medium date, a month and a
61
+ * year, or a bare year.
42
62
  */
43
63
  format?: Intl.DateTimeFormatOptions;
44
64
  /** Shown in the trigger while nothing is chosen. */
45
65
  placeholder?: React.ReactNode;
46
66
  /** Offers the × that empties the control. @default false */
47
67
  clearable?: boolean;
48
- /** Offers the shortcut to today in the footer. @default true */
68
+ /**
69
+ * Offers the shortcut to the current unit in the footer — today, this month
70
+ * or this year, whichever `granularity` is asking for. @default true
71
+ */
49
72
  showTodayButton?: boolean;
50
73
  /** Closes the popup as soon as a day is chosen. @default true */
51
74
  closeOnSelect?: boolean;
52
75
  /** The strings a screen reader hears. Every one has an English default. */
53
76
  labels?: Partial<PickerLabels>;
54
- /** Identifies the field when a form is submitted, as `YYYY-MM-DD`. */
77
+ /**
78
+ * Identifies the field when a form is submitted. The value is written at
79
+ * `granularity` — `YYYY-MM-DD`, `YYYY-MM` or `YYYY` — so a month is never
80
+ * submitted as a day nobody chose.
81
+ */
55
82
  name?: string;
56
83
  }
57
84
  /**
@@ -67,6 +94,11 @@ export interface DatePickerProps extends PickerShellProps {
67
94
  * its own — twelve months, then twelve years at a time. Any month of the year on
68
95
  * screen is two clicks; any year at all is three.
69
96
  *
97
+ * `granularity` turns that header into the answer. A month picker opens on the
98
+ * grid of twelve months and stops there; a year picker opens on the years. The
99
+ * value stays a `Date` — the 1st of what was chosen — because a second value
100
+ * type would mean a second set of props to compare it with.
101
+ *
70
102
  * There is no typing into the trigger. Parsing a date out of free text is
71
103
  * locale-dependent in a way that cannot be done honestly without a date library,
72
104
  * and a field that understands `27/7/26` in one browser and not in the next is
@@ -1 +1 @@
1
- "use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as t from"react";import{Button as l}from"../button/Button.js";import{Calendar as o,usePickerLabels as n}from"../../internal/calendar.js";import{CalendarIcon as r}from"../../internal/icons.js";import{PickerFooter as s,PickerShell as i}from"../../internal/picker.js";import{displaySamples as c,formatDate as d,isDayOutside as m,isValidDate as u,localeWeekStart as p,mergeDateAndTime as f,startOfDay as h,startOfMonth as b,toISODate as y,today as x,withPlaceholder as j}from"../../internal/date.js";import{cx as v}from"../../internal/styles.js";export const DatePicker=/*@__PURE__*/t.forwardRef(function({value:D,defaultValue:O,onValueChange:S,open:g,defaultOpen:C,onOpenChange:k,defaultMonth:z,minDate:w,maxDate:M,shouldDisableDate:V,locale:B,weekStartsOn:I,format:R={dateStyle:"medium"},placeholder:E,clearable:F=!1,showTodayButton:N=!0,closeOnSelect:P=!0,labels:T,name:q,size:A="md",color:G="primary",readOnly:H=!1,disabled:J=!1,startIcon:K,...L},Q){const U=n(T),W=I??p(B),[X,Y]=t.useState(O??null),Z=void 0!==D?D:X,[$,_]=t.useState(C??!1),ee=g??$,[ae,te]=t.useState(()=>b(u(Z)?Z:z??x()));t.useEffect(()=>{ee&&te(b(u(Z)?Z:z??x()))},[ee]);const le=e=>{e&&(H||J)||(void 0===g&&_(e),k?.(e))},oe=e=>{void 0===D&&Y(e),S?.(e)},ne=e=>{const a=u(Z)?f(e,Z):h(e);oe(a),te(b(a)),P&&le(!1)},re=x(),se=m(re,w,M)||(V?.(re)??!1),ie=N||F,ce=t.useMemo(()=>j(c(B,R),E),[B,R,E]);return e(i,{...L,size:A,color:G,readOnly:H,disabled:J,triggerRef:Q,startIcon:K??e(r,{}),display:u(Z)?d(Z,B,R):E??"",samples:ce,empty:!u(Z),clearable:F,onClear:()=>oe(null),open:ee,onOpenChange:le,labels:U,hiddenValues:q?[{name:q,value:u(Z)?y(Z):""}]:void 0,children:a("div",{className:v("flex flex-col",ie&&"gap-1.5"),children:[e(o,{size:A,color:G,locale:B,weekStartsOn:W,month:ae,onMonthChange:te,selected:[Z],onSelect:ne,minDate:w,maxDate:M,shouldDisableDate:V,labels:U,autoFocus:!0}),ie?a(s,{size:A,children:[F?e(l,{variant:"text",size:A,color:G,density:"compact",onClick:()=>{oe(null),le(!1)},children:U.clear}):null,N?e(l,{variant:"text",size:A,color:G,density:"compact",disabled:se,onClick:()=>ne(re),children:U.today}):null]}):null]})})});
1
+ "use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as t from"react";import{Button as l}from"../button/Button.js";import{Calendar as n,usePickerLabels as o}from"../../internal/calendar.js";import{CalendarIcon as r}from"../../internal/icons.js";import{PickerFooter as s,PickerShell as i}from"../../internal/picker.js";import{displaySamples as c,formatDate as m,isUnitOutside as d,isValidDate as u,localeWeekStart as h,mergeDateAndTime as p,startOfMonth as f,startOfUnit as y,toISODate as b,toISOMonth as g,toISOYear as j,today as x,withPlaceholder as v}from"../../internal/date.js";import{cx as D}from"../../internal/styles.js";import{useStyleDefaults as O}from"../../internal/defaults.js";const S={day:{dateStyle:"medium"},month:{year:"numeric",month:"long"},year:{year:"numeric"}},z={day:b,month:g,year:j};export const DatePicker=/*@__PURE__*/t.forwardRef(function(b,g){const{value:j,defaultValue:C,onValueChange:k,open:w,defaultOpen:M,onOpenChange:V,granularity:B="day",defaultMonth:I,minDate:R,maxDate:E,shouldDisableDate:F,locale:N,weekStartsOn:P,format:T,placeholder:Y,clearable:q=!1,showTodayButton:A=!0,closeOnSelect:G=!0,labels:H,name:J,size:K="md",color:L="primary",readOnly:Q=!1,disabled:U=!1,startIcon:W,...X}=O(b,["size","locale"]),Z=o(H),$=P??h(N),_=T??S[B],[ee,ae]=t.useState(C??null),te=void 0!==j?j:ee,[le,ne]=t.useState(M??!1),oe=w??le,[re,se]=t.useState(()=>f(u(te)?te:I??x()));t.useEffect(()=>{oe&&se(f(u(te)?te:I??x()))},[oe]);const ie=e=>{e&&(Q||U)||(void 0===w&&ne(e),V?.(e))},ce=e=>{void 0===j&&ae(e),k?.(e)},me=e=>{const a=y(e,B),t=u(te)?p(a,te):a;ce(t),se(f(t)),G&&ie(!1)},de=x(),ue=y(de,B),he=d(de,B,R,E)||(F?.(ue)??!1),pe="year"===B?Z.thisYear:"month"===B?Z.thisMonth:Z.today,fe=A||q,ye=t.useMemo(()=>v(c(N,_),Y),[N,_,Y]);return e(i,{...X,size:K,color:L,readOnly:Q,disabled:U,triggerRef:g,startIcon:W??e(r,{}),display:u(te)?m(te,N,_):Y??"",samples:ye,empty:!u(te),clearable:q,onClear:()=>ce(null),open:oe,onOpenChange:ie,labels:Z,hiddenValues:J?[{name:J,value:u(te)?z[B](te):""}]:void 0,children:a("div",{className:D("flex flex-col",fe&&"gap-1.5"),children:[e(n,{size:K,color:L,locale:N,weekStartsOn:$,month:re,onMonthChange:se,selected:[te],onSelect:me,granularity:B,minDate:R,maxDate:E,shouldDisableDate:F,labels:Z,autoFocus:!0}),fe?a(s,{size:K,children:[q?e(l,{variant:"text",size:K,color:L,density:"compact",onClick:()=>{ce(null),ie(!1)},children:Z.clear}):null,A?e(l,{variant:"text",size:K,color:L,density:"compact",disabled:he,onClick:()=>me(de),children:pe}):null]}):null]})})});
@@ -1 +1 @@
1
- "use client";import{jsx as e,jsxs as l}from"react/jsx-runtime";import*as n from"react";import{Button as a}from"../button/Button.js";import{Calendar as t,usePickerLabels as s}from"../../internal/calendar.js";import{ArrowRightIcon as r,CalendarIcon as o}from"../../internal/icons.js";import{PickerFooter as i,PickerShell as c}from"../../internal/picker.js";import{WidthSizer as u}from"../../internal/sizer.js";import{addMonths as d,compareDay as m,displaySamples as h,formatDate as p,isValidDate as f,localeWeekStart as x,startOfDay as v,startOfMonth as g,toISODate as b,today as w,withPlaceholder as y}from"../../internal/date.js";import{cx as N,gapClasses as j,metaTextClasses as S}from"../../internal/styles.js";const C={start:null,end:null};export const DateRangePicker=/*@__PURE__*/n.forwardRef(function({value:D,defaultValue:O,onValueChange:k,open:z,defaultOpen:P,onOpenChange:B,defaultMonth:M,minDate:R,maxDate:V,shouldDisableDate:E,locale:I,weekStartsOn:F,format:q={dateStyle:"medium"},monthCount:A=2,startPlaceholder:G,endPlaceholder:H,presets:J,clearable:K=!1,closeOnSelect:L=!0,labels:Q,name:T,size:U="md",color:W="primary",readOnly:X=!1,disabled:Y=!1,startIcon:Z,...$},_){const ee=s(Q),le=F??x(I),[ne,ae]=n.useState(O??C),te=void 0!==D?D??C:ne,se=f(te.start)?te.start:null,re=f(te.end)?te.end:null,[oe,ie]=n.useState(P??!1),ce=z??oe,[ue,de]=n.useState(null),[me,he]=n.useState(null),[pe,fe]=n.useState(()=>g(se??M??w()));n.useEffect(()=>{ce?fe(g(se??M??w())):(de(null),he(null))},[ce]);const xe=e=>{e&&(X||Y)||(void 0===z&&ie(e),B?.(e))},ve=e=>{void 0===D&&ae(e),k?.(e)},ge=ue??se,be=null!==ue?me:re,we=(l,n)=>f(l)?p(l,I,q):e("span",{className:"text-(--neba-muted-fg)",children:n??""}),ye=d(pe,1),Ne=2===A,je=h(I,q),Se=null!==ue?ee.end:null===se?ee.start:null,Ce={size:U,color:W,locale:I,weekStartsOn:le,selected:[se,re,ue],rangeStart:ge,rangeEnd:be,onSelect:e=>{const l=v(e);if(null===ue)return de(l),he(l),void ve({start:l,end:null});const[n,a]=m(l,ue)<0?[l,ue]:[ue,l];de(null),he(null),ve({start:n,end:a}),L&&xe(!1)},onPreviewChange:e=>{null!==ue&&he(e??ue)},minDate:R,maxDate:V,shouldDisableDate:E,showOutsideDays:!1,labels:ee};return e(c,{...$,size:U,color:W,readOnly:X,disabled:Y,triggerRef:_,startIcon:Z??e(o,{}),display:l("span",{className:"flex min-w-0 items-center gap-1.5",children:[l("span",{className:"flex min-w-0 flex-col",children:[e("span",{className:"truncate",children:we(se,G)}),e(u,{samples:y(je,G)})]}),e("span",{"aria-hidden":"true",className:"flex shrink-0 items-center text-(--neba-muted-fg) rtl:rotate-180",children:e(r,{})}),l("span",{className:"flex min-w-0 flex-col",children:[e("span",{className:"truncate",children:we(re,H)}),e(u,{samples:y(je,H)})]})]}),empty:null===se&&null===re,clearable:K,onClear:()=>ve(C),open:ce,onOpenChange:xe,labels:ee,hiddenValues:T?[{name:T,value:se?b(se):""},{name:T,value:re?b(re):""}]:void 0,children:l("div",{className:"flex flex-col gap-1.5",children:[l("div",{className:N("flex items-stretch",j[U]),children:[J&&J.length>0?e("div",{className:N("flex max-h-[calc(var(--n-cell,2rem)*8)] flex-col overflow-y-auto border-e pe-1.5","[border-color:var(--n-line)]"),children:J.map((l,n)=>e(a,{variant:"text",size:U,color:W,density:"compact",className:"justify-start whitespace-nowrap",onClick:()=>(e=>{const l="function"==typeof e.value?e.value():e.value;de(null),he(null),ve(l),f(l.start)&&fe(g(l.start)),L&&xe(!1)})(l),children:l.label},n))}):null,e(t,{...Ce,month:pe,onMonthChange:fe,showNextButton:!Ne,autoFocus:!0}),Ne?e(t,{...Ce,month:ye,onMonthChange:e=>fe(d(e,-1)),showPreviousButton:!1}):null]}),K||null!==Se?l(i,{size:U,children:[null!==Se?e("span",{className:N("me-auto text-(--neba-muted-fg)",S[U]),children:Se}):null,K?e(a,{variant:"text",size:U,color:W,density:"compact",onClick:()=>{de(null),he(null),ve(C),xe(!1)},children:ee.clear}):null]}):null]})})});
1
+ "use client";import{jsx as e,jsxs as l}from"react/jsx-runtime";import*as n from"react";import{Button as a}from"../button/Button.js";import{Calendar as t,usePickerLabels as s}from"../../internal/calendar.js";import{ArrowRightIcon as r,CalendarIcon as o}from"../../internal/icons.js";import{PickerFooter as i,PickerShell as c}from"../../internal/picker.js";import{WidthSizer as u}from"../../internal/sizer.js";import{addMonths as m,compareDay as d,displaySamples as h,formatDate as f,isValidDate as p,localeWeekStart as x,startOfDay as v,startOfMonth as g,toISODate as b,today as w,withPlaceholder as y}from"../../internal/date.js";import{cx as N,gapClasses as j,metaTextClasses as S}from"../../internal/styles.js";import{useStyleDefaults as C}from"../../internal/defaults.js";const D={start:null,end:null};export const DateRangePicker=/*@__PURE__*/n.forwardRef(function(O,z){const{value:k,defaultValue:P,onValueChange:B,open:M,defaultOpen:R,onOpenChange:V,defaultMonth:E,minDate:I,maxDate:F,shouldDisableDate:q,locale:A,weekStartsOn:G,format:H={dateStyle:"medium"},monthCount:J=2,startPlaceholder:K,endPlaceholder:L,presets:Q,clearable:T=!1,closeOnSelect:U=!0,labels:W,name:X,size:Y="md",color:Z="primary",readOnly:$=!1,disabled:_=!1,startIcon:ee,...le}=C(O,["size","locale"]),ne=s(W),ae=G??x(A),[te,se]=n.useState(P??D),re=void 0!==k?k??D:te,oe=p(re.start)?re.start:null,ie=p(re.end)?re.end:null,[ce,ue]=n.useState(R??!1),me=M??ce,[de,he]=n.useState(null),[fe,pe]=n.useState(null),[xe,ve]=n.useState(()=>g(oe??E??w()));n.useEffect(()=>{me?ve(g(oe??E??w())):(he(null),pe(null))},[me]);const ge=e=>{e&&($||_)||(void 0===M&&ue(e),V?.(e))},be=e=>{void 0===k&&se(e),B?.(e)},we=de??oe,ye=null!==de?fe:ie,Ne=(l,n)=>p(l)?f(l,A,H):e("span",{className:"text-(--neba-muted-fg)",children:n??""}),je=m(xe,1),Se=2===J,Ce=h(A,H),De=null!==de?ne.end:null===oe?ne.start:null,Oe={size:Y,color:Z,locale:A,weekStartsOn:ae,selected:[oe,ie,de],rangeStart:we,rangeEnd:ye,onSelect:e=>{const l=v(e);if(null===de)return he(l),pe(l),void be({start:l,end:null});const[n,a]=d(l,de)<0?[l,de]:[de,l];he(null),pe(null),be({start:n,end:a}),U&&ge(!1)},onPreviewChange:e=>{null!==de&&pe(e??de)},minDate:I,maxDate:F,shouldDisableDate:q,showOutsideDays:!1,labels:ne};return e(c,{...le,size:Y,color:Z,readOnly:$,disabled:_,triggerRef:z,startIcon:ee??e(o,{}),display:l("span",{className:"flex min-w-0 items-center gap-1.5",children:[l("span",{className:"flex min-w-0 flex-col",children:[e("span",{className:"truncate",children:Ne(oe,K)}),e(u,{samples:y(Ce,K)})]}),e("span",{"aria-hidden":"true",className:"flex shrink-0 items-center text-(--neba-muted-fg) rtl:rotate-180",children:e(r,{})}),l("span",{className:"flex min-w-0 flex-col",children:[e("span",{className:"truncate",children:Ne(ie,L)}),e(u,{samples:y(Ce,L)})]})]}),empty:null===oe&&null===ie,clearable:T,onClear:()=>be(D),open:me,onOpenChange:ge,labels:ne,hiddenValues:X?[{name:X,value:oe?b(oe):""},{name:X,value:ie?b(ie):""}]:void 0,children:l("div",{className:"flex flex-col gap-1.5",children:[l("div",{className:N("flex items-stretch",j[Y]),children:[Q&&Q.length>0?e("div",{className:N("flex max-h-[calc(var(--n-cell,2rem)*8)] flex-col overflow-y-auto border-e pe-1.5","[border-color:var(--n-line)]"),children:Q.map((l,n)=>e(a,{variant:"text",size:Y,color:Z,density:"compact",className:"justify-start whitespace-nowrap",onClick:()=>(e=>{const l="function"==typeof e.value?e.value():e.value;he(null),pe(null),be(l),p(l.start)&&ve(g(l.start)),U&&ge(!1)})(l),children:l.label},n))}):null,e(t,{...Oe,month:xe,onMonthChange:ve,showNextButton:!Se,autoFocus:!0}),Se?e(t,{...Oe,month:je,onMonthChange:e=>ve(m(e,-1)),showPreviousButton:!1}):null]}),T||null!==De?l(i,{size:Y,children:[null!==De?e("span",{className:N("me-auto text-(--neba-muted-fg)",S[Y]),children:De}):null,T?e(a,{variant:"text",size:Y,color:Z,density:"compact",onClick:()=>{he(null),pe(null),be(D),ge(!1)},children:ne.clear}):null]}):null]})})});
@@ -1 +1 @@
1
- "use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as l from"react";import{Button as n}from"../button/Button.js";import{Calendar as o,TimeGrid as a,usePickerLabels as s}from"../../internal/calendar.js";import{CalendarIcon as i}from"../../internal/icons.js";import{PickerDivider as r,PickerFooter as c,PickerShell as d}from"../../internal/picker.js";import{displaySamples as m,formatDate as u,isDayOutside as h,isHour12 as p,isValidDate as f,localeWeekStart as S,mergeDateAndTime as b,startOfDay as y,startOfMonth as D,timeUnitSpan as g,toISODateTime as v,today as x,withPlaceholder as C,withTime as j}from"../../internal/date.js";import{cx as w,gapClasses as k}from"../../internal/styles.js";export const DateTimePicker=/*@__PURE__*/l.forwardRef(function({value:z,defaultValue:O,onValueChange:T,open:N,defaultOpen:V,onOpenChange:B,defaultMonth:I,minDate:M,maxDate:R,shouldDisableDate:E,shouldDisableTime:F,locale:P,weekStartsOn:q,format:A={dateStyle:"medium",timeStyle:"short"},hour12:G,showSeconds:H=!1,hourStep:J=1,minuteStep:K=1,secondStep:L=1,placeholder:Q,clearable:U=!1,showNowButton:W=!0,closeOnSelect:X=!1,labels:Y,name:Z,size:$="md",color:_="primary",density:ee="default",readOnly:te=!1,disabled:le=!1,startIcon:ne,...oe},ae){const se=s(Y),ie=q??S(P),re=G??p(P),[ce,de]=l.useState(O??null),me=void 0!==z?z:ce,[ue,he]=l.useState(V??!1),pe=N??ue,[fe,Se]=l.useState(()=>D(f(me)?me:I??x()));l.useEffect(()=>{pe&&Se(D(f(me)?me:I??x()))},[pe]);const be=e=>{e&&(te||le)||(void 0===N&&he(e),B?.(e))},ye=e=>{void 0===z&&de(e),T?.(e)},De=l.useCallback((e,t)=>{const[l,n]=g(t,e),o=y(e).getTime();return!!(f(M)&&o+1e3*n<M.getTime())||(!!(f(R)&&o+1e3*l>R.getTime())||(F?.(e,t)??!1))},[M,R,F]),ge=new Date,ve=j(ge,{seconds:H?ge.getSeconds():0}),xe=h(ve,M,R)||(E?.(ve)??!1)||De(ve,"second"),Ce=C(m(P,A),Q);return e(d,{...oe,size:$,color:_,density:ee,readOnly:te,disabled:le,triggerRef:ae,startIcon:ne??e(i,{}),display:f(me)?u(me,P,A):Q??"",samples:Ce,empty:!f(me),clearable:U,onClear:()=>ye(null),open:pe,onOpenChange:be,labels:se,hiddenValues:Z?[{name:Z,value:f(me)?v(me,H):""}]:void 0,children:t("div",{className:"flex flex-col gap-1.5",children:[t("div",{className:w("flex items-stretch",k[$]),children:[e(o,{size:$,color:_,locale:P,weekStartsOn:ie,month:fe,onMonthChange:Se,selected:[me],onSelect:e=>{const t=f(me)?b(e,me):y(e);ye(t),Se(D(t)),X&&be(!1)},minDate:M,maxDate:R,shouldDisableDate:E,labels:se,autoFocus:!0}),e(r,{}),e(a,{size:$,density:ee,locale:P,value:f(me)?me:null,referenceDate:f(me)?me:x(),onChange:ye,hour12:re,showSeconds:H,hourStep:J,minuteStep:K,secondStep:L,shouldDisableTime:De,labels:se})]}),t(c,{size:$,children:[U?e(n,{variant:"text",size:$,color:_,density:"compact",onClick:()=>{ye(null),be(!1)},children:se.clear}):null,W?e(n,{variant:"text",size:$,color:_,density:"compact",disabled:xe,onClick:()=>{ye(ve),Se(D(ve))},children:se.now}):null,e(n,{variant:"solid",size:$,color:_,density:"compact",onClick:()=>be(!1),children:se.done})]})]})})});
1
+ "use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as l from"react";import{Button as n}from"../button/Button.js";import{Calendar as o,TimeGrid as a,usePickerLabels as s}from"../../internal/calendar.js";import{CalendarIcon as i}from"../../internal/icons.js";import{PickerDivider as r,PickerFooter as c,PickerShell as d}from"../../internal/picker.js";import{displaySamples as m,formatDate as u,isDayOutside as p,isHour12 as h,isValidDate as f,localeWeekStart as S,mergeDateAndTime as b,startOfDay as y,startOfMonth as D,timeUnitSpan as g,toISODateTime as v,today as x,withPlaceholder as j,withTime as C}from"../../internal/date.js";import{cx as w,gapClasses as z}from"../../internal/styles.js";import{useStyleDefaults as k}from"../../internal/defaults.js";export const DateTimePicker=/*@__PURE__*/l.forwardRef(function(O,T){const{value:N,defaultValue:V,onValueChange:B,open:I,defaultOpen:M,onOpenChange:R,defaultMonth:E,minDate:F,maxDate:P,shouldDisableDate:q,shouldDisableTime:A,locale:G,weekStartsOn:H,format:J={dateStyle:"medium",timeStyle:"short"},hour12:K,showSeconds:L=!1,hourStep:Q=1,minuteStep:U=1,secondStep:W=1,placeholder:X,clearable:Y=!1,showNowButton:Z=!0,closeOnSelect:$=!1,labels:_,name:ee,size:te="md",color:le="primary",density:ne="default",readOnly:oe=!1,disabled:ae=!1,startIcon:se,...ie}=k(O,["size","density","locale"]),re=s(_),ce=H??S(G),de=K??h(G),[me,ue]=l.useState(V??null),pe=void 0!==N?N:me,[he,fe]=l.useState(M??!1),Se=I??he,[be,ye]=l.useState(()=>D(f(pe)?pe:E??x()));l.useEffect(()=>{Se&&ye(D(f(pe)?pe:E??x()))},[Se]);const De=e=>{e&&(oe||ae)||(void 0===I&&fe(e),R?.(e))},ge=e=>{void 0===N&&ue(e),B?.(e)},ve=l.useCallback((e,t)=>{const[l,n]=g(t,e),o=y(e).getTime();return!!(f(F)&&o+1e3*n<F.getTime())||(!!(f(P)&&o+1e3*l>P.getTime())||(A?.(e,t)??!1))},[F,P,A]),xe=new Date,je=C(xe,{seconds:L?xe.getSeconds():0}),Ce=p(je,F,P)||(q?.(je)??!1)||ve(je,"second"),we=j(m(G,J),X);return e(d,{...ie,size:te,color:le,density:ne,readOnly:oe,disabled:ae,triggerRef:T,startIcon:se??e(i,{}),display:f(pe)?u(pe,G,J):X??"",samples:we,empty:!f(pe),clearable:Y,onClear:()=>ge(null),open:Se,onOpenChange:De,labels:re,hiddenValues:ee?[{name:ee,value:f(pe)?v(pe,L):""}]:void 0,children:t("div",{className:"flex flex-col gap-1.5",children:[t("div",{className:w("flex items-stretch",z[te]),children:[e(o,{size:te,color:le,locale:G,weekStartsOn:ce,month:be,onMonthChange:ye,selected:[pe],onSelect:e=>{const t=f(pe)?b(e,pe):y(e);ge(t),ye(D(t)),$&&De(!1)},minDate:F,maxDate:P,shouldDisableDate:q,labels:re,autoFocus:!0}),e(r,{}),e(a,{size:te,density:ne,locale:G,value:f(pe)?pe:null,referenceDate:f(pe)?pe:x(),onChange:ge,hour12:de,showSeconds:L,hourStep:Q,minuteStep:U,secondStep:W,shouldDisableTime:ve,labels:re})]}),t(c,{size:te,children:[Y?e(n,{variant:"text",size:te,color:le,density:"compact",onClick:()=>{ge(null),De(!1)},children:re.clear}):null,Z?e(n,{variant:"text",size:te,color:le,density:"compact",disabled:Ce,onClick:()=>{ge(je),ye(D(je))},children:re.now}):null,e(n,{variant:"solid",size:te,color:le,density:"compact",onClick:()=>De(!1),children:re.done})]})]})})});
@@ -131,4 +131,4 @@ export declare const DialogClose: React.ForwardRefExoticComponent<Omit<import("@
131
131
  * the header and the actions stay put while only the body scrolls, which is why
132
132
  * `dividers` matters more here than on a Card.
133
133
  */
134
- export declare function Dialog({ size, color, density, open, defaultOpen, onOpenChange, trigger, title, description, actions, dividers, showClose, locale, closeLabel, width, fullWidth, fullScreen, modal, dismissible, className, classNames, style, children, ...props }: DialogProps): React.JSX.Element;
134
+ export declare function Dialog(rawProps: DialogProps): React.JSX.Element;
@@ -1 +1 @@
1
- "use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import{Dialog as l}from"@base-ui/react/dialog";import{boxPaddingXClasses as n,boxPaddingYClasses as i}from"../box/Box.js";import{actionMessages as o,useMessages as r}from"../../internal/i18n.js";import{CloseIcon as s}from"../../internal/icons.js";import{cx as t,hasContent as c,metaTextClasses as d,radiusClasses as m,sheetBodyClasses as p,sheetHeaderGapClasses as f,sheetSectionGapClasses as u,sheetTitleClasses as b,surfaceClasses as x,surfaceSlots as h}from"../../internal/styles.js";const v={xs:"max-w-80",sm:"max-w-96",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl"},g=[x,"relative flex w-full flex-col overflow-hidden","border text-(--neba-fg) bg-(--n-panel-press)","[border-color:var(--n-line)]","[box-shadow:var(--neba-shadow-3),var(--neba-plate-glass)]","[outline:none]","[transition:opacity_var(--neba-duration)_var(--neba-ease)]","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0"].join(" "),y=["fixed inset-0 z-50 bg-(--neba-scrim)","[backdrop-filter:blur(2px)]","[transition:opacity_var(--neba-duration)_var(--neba-ease)]","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0"].join(" "),w="border-t [border-color:var(--n-line)]";export const DialogClose=l.Close;export function Dialog({size:x="md",color:j="primary",density:N="default",open:_,defaultOpen:k,onOpenChange:$,trigger:C,title:z,description:D,actions:O,dividers:P=!1,showClose:B=!0,locale:T,closeLabel:W,width:L,fullWidth:R=!0,fullScreen:S=!1,modal:V=!0,dismissible:q=!0,className:A,classNames:E,style:F,children:G,...H}){const I=r(o,T),J=n[N][x],K=i[N][x],M=P?`${J} ${K}`:J,Q=c(z)||c(D),U=c(O);return a(l.Root,{open:_,defaultOpen:k,modal:V,disablePointerDismissal:!q,onOpenChange:(e,a)=>{q||e||"escape-key"!==a.reason?$?.(e):a.cancel()},children:[C?e(l.Trigger,{render:C}):null,a(l.Portal,{children:[e(l.Backdrop,{className:t("neba-portal",y,E?.backdrop)}),e(l.Viewport,{className:t("neba-portal fixed inset-0 z-50 flex justify-center",S?"items-stretch":"items-center p-4",E?.viewport),children:a(l.Popup,{className:t(g,p[x],S?"h-full max-w-none rounded-none":`max-h-full ${m[x]} ${void 0===L?v[x]:""}`,S||R?"":"w-auto",P?"":`${K} ${u[x]}`,A??""),style:{...h(j,3),...void 0===L?null:{maxWidth:"number"==typeof L?`${L}px`:L},...F},...H,children:[Q||B?a("div",{className:`flex shrink-0 items-start gap-3 ${M}`,children:[a("div",{className:`flex min-w-0 flex-1 flex-col ${f[x]}`,children:[c(z)?e(l.Title,{className:t("font-semibold",b[x],"m-0",E?.title),children:z}):null,c(D)?e(l.Description,{className:t("m-0 text-(--neba-muted-fg)",d[x],E?.description),children:D}):null]}),B?e(l.Close,{"aria-label":W??I.close,className:t("flex size-[1.6em] shrink-0 cursor-pointer items-center justify-center","rounded-full text-(--neba-muted-fg)","[&_svg]:size-[1.1em] [&_svg]:shrink-0","[transition:background-color_var(--neba-duration)_var(--neba-ease),color_var(--neba-duration)_var(--neba-ease)]","hover:bg-(--n-soft) hover:text-(--neba-fg)","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-2",E?.close),children:e(s,{})}):null]}):null,c(G)?e("div",{className:t("min-h-0 flex-1 overflow-y-auto overscroll-contain",M,P&&(Q||B)?w:"",P?"":"py-1 -my-1",E?.body),children:G}):null,U?e("div",{className:t("flex shrink-0 flex-wrap items-center justify-end gap-2",M,P?w:"",E?.actions),children:O}):null]})})]})]})}
1
+ "use client";import{jsx as e,jsxs as l}from"react/jsx-runtime";import{Dialog as n}from"@base-ui/react/dialog";import{boxPaddingXClasses as o,boxPaddingYClasses as r}from"../box/Box.js";import{actionMessages as s,useMessages as i}from"../../internal/i18n.js";import{CloseIcon as a}from"../../internal/icons.js";import{cx as t,hasContent as c,metaTextClasses as d,popupFadeClasses as m,radiusClasses as f,sheetBodyClasses as u,sheetHeaderGapClasses as p,sheetSectionGapClasses as x,sheetTitleClasses as b,surfaceClasses as h,surfaceSlots as v}from"../../internal/styles.js";import{useStyleDefaults as g}from"../../internal/defaults.js";const w={xs:"max-w-80",sm:"max-w-96",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl"},y=[h,"relative flex w-full flex-col overflow-hidden","border text-(--neba-fg) bg-(--n-panel-press)","[border-color:var(--n-line)]","[box-shadow:var(--neba-shadow-3),var(--neba-plate-glass)]","[outline:none]",m].join(" "),j=["fixed inset-0 z-50 bg-(--neba-scrim)","[backdrop-filter:blur(2px)]",m].join(" "),N="border-t [border-color:var(--n-line)]";export const DialogClose=n.Close;export function Dialog(m){const{size:h="md",color:k="primary",density:$="default",open:_,defaultOpen:z,onOpenChange:C,trigger:D,title:O,description:P,actions:B,dividers:T=!1,showClose:W=!0,locale:L,closeLabel:R,width:S,fullWidth:V=!0,fullScreen:q=!1,modal:A=!0,dismissible:E=!0,className:F,classNames:G,style:H,children:I,...J}=g(m,["size","density","locale"]),K=i(s,L),M=o[$][h],Q=r[$][h],U=T?`${M} ${Q}`:M,X=c(O)||c(P),Y=c(B);return l(n.Root,{open:_,defaultOpen:z,modal:A,disablePointerDismissal:!E,onOpenChange:(e,l)=>{E||e||"escape-key"!==l.reason?C?.(e):l.cancel()},children:[D?e(n.Trigger,{render:D}):null,l(n.Portal,{children:[e(n.Backdrop,{className:t("neba-portal",j,G?.backdrop)}),e(n.Viewport,{className:t("neba-portal fixed inset-0 z-50 flex justify-center",q?"items-stretch":"items-center p-4",G?.viewport),children:l(n.Popup,{className:t(y,u[h],q?"h-full max-w-none rounded-none":`max-h-full ${f[h]} ${void 0===S?w[h]:""}`,q||V?"":"w-auto",T?"":`${Q} ${x[h]}`,F??""),style:{...v(k,3),...void 0===S?null:{maxWidth:"number"==typeof S?`${S}px`:S},...H},...J,children:[X||W?l("div",{className:`flex shrink-0 items-start gap-3 ${U}`,children:[l("div",{className:`flex min-w-0 flex-1 flex-col ${p[h]}`,children:[c(O)?e(n.Title,{className:t("font-semibold",b[h],"m-0",G?.title),children:O}):null,c(P)?e(n.Description,{className:t("m-0 text-(--neba-muted-fg)",d[h],G?.description),children:P}):null]}),W?e(n.Close,{"aria-label":R??K.close,className:t("flex size-[1.6em] shrink-0 cursor-pointer items-center justify-center","rounded-full text-(--neba-muted-fg)","[&_svg]:size-[1.1em] [&_svg]:shrink-0","[transition:background-color_var(--neba-duration)_var(--neba-ease),color_var(--neba-duration)_var(--neba-ease)]","hover:bg-(--n-soft) hover:text-(--neba-fg)","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-2",G?.close),children:e(a,{})}):null]}):null,c(I)?e("div",{className:t("min-h-0 flex-1 overflow-y-auto overscroll-contain",U,T&&(X||W)?N:"",T?"":"py-1 -my-1",G?.body),children:I}):null,Y?e("div",{className:t("flex shrink-0 flex-wrap items-center justify-end gap-2",U,T?N:"",G?.actions),children:B}):null]})})]})]})}
@@ -1 +1 @@
1
- "use client";import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as t from"react";import{Separator as l}from"@base-ui/react/separator";import{cx as a,metaTextClasses as n,toLength as i}from"../../internal/styles.js";const s="[border-color:var(--n-line)]",o={horizontal:{start:["w-4 shrink-0","flex-1"],center:["flex-1","flex-1"],end:["flex-1","w-4 shrink-0"]},vertical:{start:["h-4 shrink-0","flex-1"],center:["flex-1","flex-1"],end:["flex-1","h-4 shrink-0"]}},d={xs:"gap-1.5",sm:"gap-2",md:"gap-3",lg:"gap-3.5",xl:"gap-4"};export const Divider=/*@__PURE__*/t.forwardRef(function({orientation:t="horizontal",color:c="primary",size:f="md",length:h,thickness:m,textAlign:p="center",className:u,style:x,children:w,...v},b){const g="vertical"===t,$=null!=w&&!1!==w&&""!==w,k={"--n-line":`var(--neba-${c}-line)`,"--n-rule":i(m)??"1px"},y=i(h),N={...k,...void 0===y?null:g?{height:y}:{width:y},...x};if(!$)return e(l,{ref:b,orientation:t,className:a(g?"w-0 border-l [border-left-width:var(--n-rule)] "+(void 0===y?"self-stretch":""):"h-0 w-full border-t [border-top-width:var(--n-rule)]",s,u??""),style:N,...v});const[j,z]=o[t][p],A=g?"w-0 border-l [border-left-width:var(--n-rule)]":"h-0 border-t [border-top-width:var(--n-rule)]";return r(l,{ref:b,orientation:t,"aria-label":"string"==typeof w?w:void 0,className:a("flex items-center",g?"w-auto flex-col "+(void 0===y?"self-stretch":""):"w-full",d[f],u??""),style:N,...v,children:[e("span",{"aria-hidden":"true",className:`${A} ${j} ${s}`}),e("span",{className:["shrink-0 whitespace-nowrap text-(--neba-muted-fg)",n[f],g?"[writing-mode:vertical-rl]":""].filter(Boolean).join(" "),children:w}),e("span",{"aria-hidden":"true",className:`${A} ${z} ${s}`})]})});
1
+ "use client";import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as t from"react";import{Separator as l}from"@base-ui/react/separator";import{cx as a,metaTextClasses as i,toLength as n}from"../../internal/styles.js";import{useStyleDefaults as s}from"../../internal/defaults.js";const o="[border-color:var(--n-line)]",d={horizontal:{start:["w-4 shrink-0","flex-1"],center:["flex-1","flex-1"],end:["flex-1","w-4 shrink-0"]},vertical:{start:["h-4 shrink-0","flex-1"],center:["flex-1","flex-1"],end:["flex-1","h-4 shrink-0"]}},c={xs:"gap-1.5",sm:"gap-2",md:"gap-3",lg:"gap-3.5",xl:"gap-4"};export const Divider=/*@__PURE__*/t.forwardRef(function(t,f){const{orientation:h="horizontal",color:m="primary",size:p="md",length:u,thickness:x,textAlign:w="center",className:v,style:b,children:g,...$}=s(t,["size"]),j="vertical"===h,k=null!=g&&!1!==g&&""!==g,y={"--n-line":`var(--neba-${m}-line)`,"--n-rule":n(x)??"1px"},N=n(u),z={...y,...void 0===N?null:j?{height:N}:{width:N},...b};if(!k)return e(l,{ref:f,orientation:h,className:a(j?"w-0 border-l [border-left-width:var(--n-rule)] "+(void 0===N?"self-stretch":""):"h-0 w-full border-t [border-top-width:var(--n-rule)]",o,v??""),style:z,...$});const[A,B]=d[h][w],D=j?"w-0 border-l [border-left-width:var(--n-rule)]":"h-0 border-t [border-top-width:var(--n-rule)]";return r(l,{ref:f,orientation:h,"aria-label":"string"==typeof g?g:void 0,className:a("flex items-center",j?"w-auto flex-col "+(void 0===N?"self-stretch":""):"w-full",c[p],v??""),style:z,...$,children:[e("span",{"aria-hidden":"true",className:`${D} ${A} ${o}`}),e("span",{className:["shrink-0 whitespace-nowrap text-(--neba-muted-fg)",i[p],j?"[writing-mode:vertical-rl]":""].filter(Boolean).join(" "),children:g}),e("span",{"aria-hidden":"true",className:`${D} ${B} ${o}`})]})});
@@ -148,4 +148,4 @@ export declare const DrawerClose: React.ForwardRefExoticComponent<Omit<import("@
148
148
  * scroll lock, the `aria-labelledby` / `aria-describedby` wiring, restoring
149
149
  * focus to the trigger, and the inert page behind.
150
150
  */
151
- export declare function Drawer({ side, mode, size, color, density, open, defaultOpen, onOpenChange, trigger, title, description, actions, dividers, showClose, locale, closeLabel, extent, rounded, modal, dismissible, className, style, children, ...props }: DrawerProps): React.JSX.Element | null;
151
+ export declare function Drawer(rawProps: DrawerProps): React.JSX.Element | null;
@@ -1 +1 @@
1
- "use client";import{jsx as e,jsxs as r,Fragment as a}from"react/jsx-runtime";import{Dialog as l}from"@base-ui/react/dialog";import{boxPaddingXClasses as n,boxPaddingYClasses as s}from"../box/Box.js";import{actionMessages as o,useMessages as i}from"../../internal/i18n.js";import{CloseIcon as d}from"../../internal/icons.js";import{cx as t,hasContent as u,metaTextClasses as b,sheetBodyClasses as m,sheetHeaderGapClasses as c,sheetSectionGapClasses as f,sheetTitleClasses as x,surfaceClasses as p,surfaceSlots as g}from"../../internal/styles.js";const h={xs:"w-56",sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[28rem]"},v={left:{xs:"rounded-r-(--neba-radius-xs)",sm:"rounded-r-(--neba-radius-sm)",md:"rounded-r-(--neba-radius-md)",lg:"rounded-r-(--neba-radius-lg)",xl:"rounded-r-(--neba-radius-xl)"},right:{xs:"rounded-l-(--neba-radius-xs)",sm:"rounded-l-(--neba-radius-sm)",md:"rounded-l-(--neba-radius-md)",lg:"rounded-l-(--neba-radius-lg)",xl:"rounded-l-(--neba-radius-xl)"},top:{xs:"rounded-b-(--neba-radius-xs)",sm:"rounded-b-(--neba-radius-sm)",md:"rounded-b-(--neba-radius-md)",lg:"rounded-b-(--neba-radius-lg)",xl:"rounded-b-(--neba-radius-xl)"},bottom:{xs:"rounded-t-(--neba-radius-xs)",sm:"rounded-t-(--neba-radius-sm)",md:"rounded-t-(--neba-radius-md)",lg:"rounded-t-(--neba-radius-lg)",xl:"rounded-t-(--neba-radius-xl)"}},y={left:"border-r",right:"border-l",top:"border-b",bottom:"border-t"},w={left:"flex-row justify-start",right:"flex-row justify-end",top:"flex-col justify-start",bottom:"flex-col justify-end"},j=[p,"relative flex flex-col overflow-hidden","text-(--neba-fg) bg-(--n-panel-press)","[border-color:var(--n-line)]","[outline:none]"].join(" "),N=["[transition:opacity_var(--neba-duration)_var(--neba-ease)]","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0"].join(" "),$=["fixed inset-0 z-50 bg-(--neba-scrim)","[backdrop-filter:blur(2px)]",N].join(" "),_="border-t [border-color:var(--n-line)]",k=["flex size-[1.6em] shrink-0 cursor-pointer items-center justify-center","rounded-full text-(--neba-muted-fg)","[&_svg]:size-[1.1em] [&_svg]:shrink-0","[transition:background-color_var(--neba-duration)_var(--neba-ease),color_var(--neba-duration)_var(--neba-ease)]","hover:bg-(--n-soft) hover:text-(--neba-fg)","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-2"].join(" ");export const DrawerClose=l.Close;export function Drawer({side:p="left",mode:C="overlay",size:z="md",color:D="primary",density:O="default",open:P,defaultOpen:B,onOpenChange:T,trigger:F,title:L,description:R,actions:V,dividers:q=!1,showClose:A,locale:E,closeLabel:G,extent:H,rounded:I=!0,modal:J=!0,dismissible:K=!0,className:M,style:Q,children:S,...U}){const W=i(o,E),X="overlay"===C,Y="left"===p||"right"===p,Z=A??X,ee=n[O][z],re=s[O][z],ae=q?`${ee} ${re}`:ee,le=u(L)||u(R),ne=u(V),se=void 0===H?null:{[Y?"width":"height"]:"number"==typeof H?`${H}px`:H},oe=t(j,m[z],y[p],I?v[p][z]:"",X?"[box-shadow:var(--neba-shadow-3),var(--neba-plate-glass)]":"[box-shadow:var(--neba-plate-glass)]",X?N:"",Y?`h-full max-w-full ${void 0===H?h[z]:""}`:"w-full "+(void 0===H?"max-h-[85%]":""),q?"":`${re} ${f[z]}`,M??""),ie=X?l.Title:"h2",de=X?l.Description:"p",te=r(a,{children:[le||Z?r("div",{className:`flex shrink-0 items-start gap-3 ${ae}`,children:[r("div",{className:`flex min-w-0 flex-1 flex-col ${c[z]}`,children:[u(L)?e(ie,{className:`m-0 font-semibold ${x[z]}`,children:L}):null,u(R)?e(de,{className:`m-0 text-(--neba-muted-fg) ${b[z]}`,children:R}):null]}),Z?X?e(l.Close,{"aria-label":G??W.close,className:k,children:e(d,{})}):e("button",{type:"button","aria-label":G??W.close,className:k,onClick:()=>T?.(!1),children:e(d,{})}):null]}):null,u(S)?e("div",{className:t("min-h-0 flex-1 overflow-y-auto overscroll-contain",ae,q&&(le||Z)?_:"",q?"":"py-1 -my-1"),children:S}):null,ne?e("div",{className:t("flex shrink-0 flex-wrap items-center justify-end gap-2",ae,q?_:""),children:V}):null]});return X?r(l.Root,{open:P,defaultOpen:B,modal:J,disablePointerDismissal:!K,onOpenChange:(e,r)=>{K||e||"escape-key"!==r.reason?T?.(e):r.cancel()},children:[F?e(l.Trigger,{render:F}):null,r(l.Portal,{children:[e(l.Backdrop,{className:`neba-portal ${$}`}),e(l.Viewport,{className:`neba-portal fixed inset-0 z-50 flex ${w[p]}`,children:e(l.Popup,{className:oe,style:{...g(D,3),...se,...Q},...U,children:te})})]})]}):P??B??!0?e("div",{className:oe,style:{...g(D,0),...se,...Q},children:te}):null}
1
+ "use client";import{jsx as e,jsxs as a,Fragment as r}from"react/jsx-runtime";import{Dialog as l}from"@base-ui/react/dialog";import{boxPaddingXClasses as n,boxPaddingYClasses as s}from"../box/Box.js";import{actionMessages as t,useMessages as o}from"../../internal/i18n.js";import{CloseIcon as d}from"../../internal/icons.js";import{cx as i,hasContent as u,metaTextClasses as m,popupFadeClasses as b,sheetBodyClasses as c,sheetHeaderGapClasses as f,sheetSectionGapClasses as x,sheetTitleClasses as g,surfaceClasses as p,surfaceSlots as h}from"../../internal/styles.js";import{useStyleDefaults as v}from"../../internal/defaults.js";const y={xs:"w-56",sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[28rem]"},w={left:{xs:"rounded-r-(--neba-radius-xs)",sm:"rounded-r-(--neba-radius-sm)",md:"rounded-r-(--neba-radius-md)",lg:"rounded-r-(--neba-radius-lg)",xl:"rounded-r-(--neba-radius-xl)"},right:{xs:"rounded-l-(--neba-radius-xs)",sm:"rounded-l-(--neba-radius-sm)",md:"rounded-l-(--neba-radius-md)",lg:"rounded-l-(--neba-radius-lg)",xl:"rounded-l-(--neba-radius-xl)"},top:{xs:"rounded-b-(--neba-radius-xs)",sm:"rounded-b-(--neba-radius-sm)",md:"rounded-b-(--neba-radius-md)",lg:"rounded-b-(--neba-radius-lg)",xl:"rounded-b-(--neba-radius-xl)"},bottom:{xs:"rounded-t-(--neba-radius-xs)",sm:"rounded-t-(--neba-radius-sm)",md:"rounded-t-(--neba-radius-md)",lg:"rounded-t-(--neba-radius-lg)",xl:"rounded-t-(--neba-radius-xl)"}},_={left:"border-r",right:"border-l",top:"border-b",bottom:"border-t"},j={left:"data-[starting-style]:[translate:-100%_0] data-[ending-style]:[translate:-100%_0]",right:"data-[starting-style]:[translate:100%_0] data-[ending-style]:[translate:100%_0]",top:"data-[starting-style]:[translate:0_-100%] data-[ending-style]:[translate:0_-100%]",bottom:"data-[starting-style]:[translate:0_100%] data-[ending-style]:[translate:0_100%]"},N={left:"flex-row justify-start",right:"flex-row justify-end",top:"flex-col justify-start",bottom:"flex-col justify-end"},$=[p,"relative flex flex-col overflow-hidden","text-(--neba-fg) bg-(--n-panel-press)","[border-color:var(--n-line)]","[outline:none]"].join(" "),k=["fixed inset-0 z-50 bg-(--neba-scrim)","[backdrop-filter:blur(2px)]",b].join(" "),C="border-t [border-color:var(--n-line)]",z=["flex size-[1.6em] shrink-0 cursor-pointer items-center justify-center","rounded-full text-(--neba-muted-fg)","[&_svg]:size-[1.1em] [&_svg]:shrink-0","[transition:background-color_var(--neba-duration)_var(--neba-ease),color_var(--neba-duration)_var(--neba-ease)]","hover:bg-(--n-soft) hover:text-(--neba-fg)","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-2"].join(" ");export const DrawerClose=l.Close;export function Drawer(b){const{side:p="left",mode:D="overlay",size:O="md",color:P="primary",density:B="default",open:T,defaultOpen:F,onOpenChange:L,trigger:R,title:V,description:q,actions:A,dividers:E=!1,showClose:G,locale:H,closeLabel:I,extent:J,rounded:K=!0,modal:M=!0,dismissible:Q=!0,className:S,style:U,children:W,...X}=v(b,["size","density","locale"]),Y=o(t,H),Z="overlay"===D,ee="left"===p||"right"===p,ae=G??Z,re=n[B][O],le=s[B][O],ne=E?`${re} ${le}`:re,se=u(V)||u(q),te=u(A),oe=void 0===J?null:{[ee?"width":"height"]:"number"==typeof J?`${J}px`:J},de=i($,c[O],_[p],K?w[p][O]:"",Z?"[box-shadow:var(--neba-shadow-3),var(--neba-plate-glass)]":"[box-shadow:var(--neba-plate-glass)]",Z?`[transition:translate_var(--neba-duration)_var(--neba-ease)] ${j[p]}`:"",ee?`h-full max-w-full ${void 0===J?y[O]:""}`:"w-full "+(void 0===J?"max-h-[85%]":""),E?"":`${le} ${x[O]}`,S??""),ie=Z?l.Title:"h2",ue=Z?l.Description:"p",me=a(r,{children:[se||ae?a("div",{className:`flex shrink-0 items-start gap-3 ${ne}`,children:[a("div",{className:`flex min-w-0 flex-1 flex-col ${f[O]}`,children:[u(V)?e(ie,{className:`m-0 font-semibold ${g[O]}`,children:V}):null,u(q)?e(ue,{className:`m-0 text-(--neba-muted-fg) ${m[O]}`,children:q}):null]}),ae?Z?e(l.Close,{"aria-label":I??Y.close,className:z,children:e(d,{})}):e("button",{type:"button","aria-label":I??Y.close,className:z,onClick:()=>L?.(!1),children:e(d,{})}):null]}):null,u(W)?e("div",{className:i("min-h-0 flex-1 overflow-y-auto overscroll-contain",ne,E&&(se||ae)?C:"",E?"":"py-1 -my-1"),children:W}):null,te?e("div",{className:i("flex shrink-0 flex-wrap items-center justify-end gap-2",ne,E?C:""),children:A}):null]});return Z?a(l.Root,{open:T,defaultOpen:F,modal:M,disablePointerDismissal:!Q,onOpenChange:(e,a)=>{Q||e||"escape-key"!==a.reason?L?.(e):a.cancel()},children:[R?e(l.Trigger,{render:R}):null,a(l.Portal,{children:[e(l.Backdrop,{className:`neba-portal ${k}`}),e(l.Viewport,{className:`neba-portal fixed inset-0 z-50 flex ${N[p]}`,children:e(l.Popup,{className:de,style:{...h(P,3),...oe,...U},...X,children:me})})]})]}):T??F??!0?e("div",{className:de,style:{...h(P,0),...oe,...U},...X,children:me}):null}
@@ -1 +1 @@
1
- "use client";import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import*as n from"react";import{useRender as l}from"@base-ui/react/use-render";import{boxPaddingXClasses as a}from"../box/Box.js";import{transitionProps as s}from"../../internal/animate.js";import{emptyMessages as o,useMessages as i}from"../../internal/i18n.js";import{cx as m,hasContent as c,iconClasses as d,radiusClasses as x,sheetBodyClasses as p,sheetHeaderGapClasses as f,sheetSectionGapClasses as u,sheetTitleClasses as h,surfaceClasses as v,surfaceSlots as y,transitionClasses as b}from"../../internal/styles.js";const g={default:{xs:"py-5",sm:"py-6",md:"py-8",lg:"py-10",xl:"py-12"},compact:{xs:"py-3",sm:"py-3.5",md:"py-4",lg:"py-5",xl:"py-6"}},j={xs:"text-[1.25rem]",sm:"text-[1.5rem]",md:"text-[1.75rem]",lg:"text-[2.125rem]",xl:"text-[2.5rem]"},N={solid:[v,"text-(--neba-fg) bg-(--n-panel-hover)","[box-shadow:var(--n-elev),var(--neba-plate-solid)]"].join(" "),outline:[v,"border text-(--neba-fg) bg-(--n-panel)","[border-color:var(--n-line)]","[box-shadow:var(--n-elev),var(--neba-plate-glass)]"].join(" "),text:"text-(--neba-fg) bg-transparent"};function k(){return t("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[e("path",{d:"M1.75 9.75h3l.9 1.6h4.7l.9-1.6h3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"m1.75 9.75 2.1-6a1.5 1.5 0 0 1 1.42-1h5.46a1.5 1.5 0 0 1 1.42 1l2.1 6v2a1.5 1.5 0 0 1-1.5 1.5h-9.5a1.5 1.5 0 0 1-1.5-1.5Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"})]})}export const Empty=/*@__PURE__*/n.forwardRef(function({variant:n="text",size:v="md",color:w="secondary",density:$="default",elevation:L=0,title:B,icon:C,action:W,locale:z,transition:E,render:F,className:M,style:R,children:Z,...q},A){const D=i(o,z),G=void 0===B?D.title:B,H=void 0===C?e(k,{}):C,I=s(E),J=c(G),K=m("flex w-full flex-col items-center justify-center text-center",a[$][v],g[$][v],x[v],u[v],b,N[n],I.className,M??"");return l({render:F,ref:A,props:{role:"status",className:K,style:{...y(w,L),...I.style,...R},children:t(r,{children:[c(H)?e("span",{className:`flex items-center text-(--neba-muted-fg) ${j[v]} ${d}`,children:H}):null,J||c(Z)?t("div",{className:`flex max-w-prose flex-col items-center ${f[v]}`,children:[J?e("div",{className:`neba-title font-semibold ${h[v]}`,children:G}):null,c(Z)?e("div",{className:`${p[v]} ${J?"text-(--neba-muted-fg)":""}`,children:Z}):null]}):null,c(W)?e("div",{className:"flex flex-wrap items-center justify-center gap-2",children:W}):null]}),...q}})});
1
+ "use client";import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import*as n from"react";import{useRender as l}from"@base-ui/react/use-render";import{boxPaddingXClasses as a}from"../box/Box.js";import{transitionProps as s}from"../../internal/animate.js";import{emptyMessages as o,useMessages as i}from"../../internal/i18n.js";import{cx as m,hasContent as c,iconClasses as d,radiusClasses as x,sheetBodyClasses as p,sheetHeaderGapClasses as f,sheetSectionGapClasses as u,sheetTitleClasses as h,surfaceClasses as v,surfaceSlots as y,transitionClasses as b}from"../../internal/styles.js";import{useStyleDefaults as g}from"../../internal/defaults.js";const j={default:{xs:"py-5",sm:"py-6",md:"py-8",lg:"py-10",xl:"py-12"},compact:{xs:"py-3",sm:"py-3.5",md:"py-4",lg:"py-5",xl:"py-6"}},N={xs:"text-[1.25rem]",sm:"text-[1.5rem]",md:"text-[1.75rem]",lg:"text-[2.125rem]",xl:"text-[2.5rem]"},k={solid:[v,"text-(--neba-fg) bg-(--n-panel-hover)","[box-shadow:var(--n-elev),var(--neba-plate-solid)]"].join(" "),outline:[v,"border text-(--neba-fg) bg-(--n-panel)","[border-color:var(--n-line)]","[box-shadow:var(--n-elev),var(--neba-plate-glass)]"].join(" "),text:"text-(--neba-fg) bg-transparent"};function w(){return t("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[e("path",{d:"M1.75 9.75h3l.9 1.6h4.7l.9-1.6h3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"m1.75 9.75 2.1-6a1.5 1.5 0 0 1 1.42-1h5.46a1.5 1.5 0 0 1 1.42 1l2.1 6v2a1.5 1.5 0 0 1-1.5 1.5h-9.5a1.5 1.5 0 0 1-1.5-1.5Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"})]})}export const Empty=/*@__PURE__*/n.forwardRef(function(n,v){const{variant:$="text",size:L="md",color:z="secondary",density:B="default",elevation:C=0,title:W,icon:E,action:F,locale:M,transition:R,render:Z,className:q,style:A,children:D,...G}=g(n,["size","density","variant","locale"]),H=i(o,M),I=void 0===W?H.title:W,J=void 0===E?e(w,{}):E,K=s(R),O=c(I),P=m("flex w-full flex-col items-center justify-center text-center",a[B][L],j[B][L],x[L],u[L],b,k[$],K.className,q??"");return l({render:Z,ref:v,props:{role:"status",className:P,style:{...y(z,C),...K.style,...A},children:t(r,{children:[c(J)?e("span",{className:`flex items-center text-(--neba-muted-fg) ${N[L]} ${d}`,children:J}):null,O||c(D)?t("div",{className:`flex max-w-prose flex-col items-center ${f[L]}`,children:[O?e("div",{className:`neba-title font-semibold ${h[L]}`,children:I}):null,c(D)?e("div",{className:`${p[L]} ${O?"text-(--neba-muted-fg)":""}`,children:D}):null]}):null,c(F)?e("div",{className:"flex flex-wrap items-center justify-center gap-2",children:F}):null]}),...G}})});
@@ -1 +1 @@
1
- "use client";import{jsx as e,jsxs as n}from"react/jsx-runtime";import*as t from"react";import{CloseIcon as r}from"../../internal/icons.js";import{controlTextLeadingClasses as a,cx as l,disabledClasses as o,gapClasses as s,hasContent as i,iconClasses as c,metaTextClasses as d,radiusClasses as u,readOnlyFilterClasses as f,sheetTitleClasses as p,stackGapClasses as m,surfaceClasses as h,surfaceSlots as v,transitionClasses as b}from"../../internal/styles.js";const x={default:{xs:"p-4",sm:"p-5",md:"p-6",lg:"p-8",xl:"p-10"},compact:{xs:"p-2",sm:"p-3",md:"p-4",lg:"p-5",xl:"p-6"}},g={solid:[h,"border-2 border-dashed text-(--neba-fg) bg-(--n-panel-hover)","[border-color:var(--n-line)]","[box-shadow:var(--n-elev),var(--neba-plate-glass)]"].join(" "),outline:[h,"border-2 border-dashed text-(--neba-fg) bg-(--n-panel)","[border-color:var(--n-line)]","[box-shadow:var(--n-elev),var(--neba-plate-glass)]"].join(" "),text:"border-2 border-dashed text-(--neba-fg) bg-transparent [border-color:var(--n-line)]"},y={solid:"hover:bg-(--n-panel-press) hover:[border-color:var(--n-line-hover)]",outline:"hover:bg-(--n-panel-hover) hover:[border-color:var(--n-line-hover)]",text:"hover:bg-(--n-soft) hover:[border-color:var(--n-line-hover)]"};function k(){return n("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[e("path",{d:"M8 10.5V2.75m0 0L5.25 5.5M8 2.75 10.75 5.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M2.75 9.75v1.75a1.75 1.75 0 0 0 1.75 1.75h7a1.75 1.75 0 0 0 1.75-1.75V9.75",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}export function formatFileSize(e){if(e<1e3)return`${e} B`;const n=["kB","MB","GB","TB"];let t=e/1e3,r=0;for(;t>=1e3&&r<n.length-1;)t/=1e3,r+=1;return`${t<10?t.toFixed(1):Math.round(t)} ${n[r]}`}function N(e,n){const t=e.name.toLowerCase(),r=e.type.toLowerCase();return n.split(",").map(e=>e.trim().toLowerCase()).filter(Boolean).some(e=>e.startsWith(".")?t.endsWith(e):e.endsWith("/*")?r.startsWith(`${e.slice(0,-1)}`):r===e)}export const FilePicker=/*@__PURE__*/t.forwardRef(function({variant:h="outline",size:$="md",color:w="primary",density:j="default",elevation:L=0,accept:z,multiple:C=!1,maxSize:_,maxFiles:E,value:D,defaultValue:F,onFilesChange:I,onReject:M,label:B,description:W,error:S,invalid:R,title:T,hint:V,icon:O,showList:q=!0,removeLabel:A=e=>`Remove ${e}`,fullWidth:G=!0,disabled:P=!1,readOnly:H=!1,required:Y=!1,name:J,id:K,className:Q,style:U,...X},Z){const ee=t.useRef(null);t.useImperativeHandle(Z,()=>ee.current);const[ne,te]=t.useState(()=>[...F??[]]),re=t.useMemo(()=>D?[...D]:ne,[D,ne]),ae=t.useRef(0),[le,oe]=t.useState(!1);t.useEffect(()=>{const e=()=>{ae.current=0,oe(!1)};return document.addEventListener("dragend",e,!0),document.addEventListener("drop",e,!0),()=>{document.removeEventListener("dragend",e,!0),document.removeEventListener("drop",e,!0)}},[]);const se=i(S),ie=R??se,ce=ie?"danger":w,de=P||H,ue=t.useId(),fe=t.useCallback(e=>{D||te(e),I?.(e)},[I,D]),pe=t.useCallback(e=>{const n=[],t=[],r=C?E??Number.POSITIVE_INFINITY:1,a=C?re.length:0;for(const l of e)z&&!N(l,z)?t.push({file:l,reason:"type"}):void 0!==_&&l.size>_?t.push({file:l,reason:"size"}):a+n.length>=r?t.push({file:l,reason:"count"}):n.push(l);return{kept:n,rejections:t}},[z,re.length,E,_,C]),me=t.useCallback(e=>{const{kept:n,rejections:t}=pe(e);t.length>0&&M?.(t),n.length>0&&fe(C?[...re,...n]:n)},[pe,fe,re,C,M]),he=l("flex w-full flex-col items-center justify-center text-center","cursor-pointer select-none",x[j][$],u[$],s[$],b,c,"focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-2",P?`${o[h]} border-2 border-dashed`:H?`${g[h]} ${f} cursor-default`:g[h],de?"":y[h],le&&!de?"bg-(--n-soft-press) [border-color:var(--n-ring)]":"");return n("div",{className:l("flex-col align-top",m[$],G?"flex w-full":"inline-flex",Q??""),style:{...v(ce,L),...U},...X,children:[i(B)?e("span",{className:[d[$],"font-medium",P?"text-(--neba-disabled-fg)":"text-(--neba-fg)"].join(" "),children:B}):null,n("div",{className:"flex w-full flex-col",onDragEnter:e=>{de||(e.preventDefault(),ae.current+=1,oe(!0))},onDragOver:e=>{de||(e.preventDefault(),e.dataTransfer.dropEffect="copy")},onDragLeave:()=>{de||(ae.current=Math.max(0,ae.current-1),0===ae.current&&oe(!1))},onDrop:e=>{de||(e.preventDefault(),ae.current=0,oe(!1),me(function(e){const n=[...e.items],t=[...e.files];return n.length!==t.length?t:t.filter((e,t)=>{const r=n[t]?.webkitGetAsEntry?.();return!r||r.isFile})}(e.dataTransfer)))},children:[n("button",{type:"button",id:K,disabled:P,"aria-describedby":i(W)||se?ue:void 0,"aria-invalid":ie||void 0,className:he,onClick:()=>{de||ee.current&&(ee.current.value="",ee.current.click())},children:[void 0===O?e("span",{className:"flex items-center text-(--n-accent) [&_svg]:size-[1.8em]",children:e(k,{})}):i(O)?e("span",{className:"flex items-center text-(--n-accent) [&_svg]:size-[1.8em]",children:O}):null,e("span",{className:`font-medium ${p[$]}`,children:T??"Drop files here, or click to browse"}),i(V)?e("span",{className:`text-(--neba-muted-fg) ${d[$]}`,children:V}):null]}),e("input",{ref:ee,type:"file",name:J,accept:z,multiple:C,required:Y&&0===re.length,disabled:de,tabIndex:-1,"aria-hidden":"true",className:"absolute size-px overflow-hidden opacity-0 [clip-path:inset(50%)]",onChange:e=>me(Array.from(e.target.files??[]))})]}),q&&re.length>0?e("ul",{role:"list",className:`flex w-full flex-col ${m[$]} m-0 list-none p-0`,children:re.map((t,l)=>n("li",{className:["flex w-full items-center gap-2 px-2 py-1.5",u.xs,a[$],"bg-(--n-soft) text-(--neba-fg)"].join(" "),children:[e("span",{className:"min-w-0 flex-1 truncate",children:t.name}),e("span",{className:`shrink-0 text-(--neba-muted-fg) tabular-nums ${d[$]}`,children:formatFileSize(t.size)}),de?null:e("button",{type:"button","aria-label":A(t.name),className:["inline-flex shrink-0 cursor-pointer items-center justify-center rounded-full","size-[1.3em] text-(--neba-muted-fg) opacity-70","[transition:opacity_var(--neba-duration)_var(--neba-ease),color_var(--neba-duration)_var(--neba-ease)]","[&_svg]:size-[0.9em]","hover:text-(--neba-fg) hover:opacity-100 focus-visible:opacity-100","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-1"].join(" "),onClick:()=>fe(re.filter((e,n)=>n!==l)),children:e(r,{})})]},`${t.name}-${t.size}-${t.lastModified}-${l}`))}):null,i(W)&&!se?e("span",{id:ue,className:`${d[$]} text-(--neba-muted-fg)`,children:W}):null,se?e("span",{id:ue,className:`${d[$]} text-(--n-accent)`,children:S}):null]})});
1
+ "use client";import{jsx as e,jsxs as n}from"react/jsx-runtime";import*as t from"react";import{CloseIcon as r}from"../../internal/icons.js";import{controlTextLeadingClasses as a,cx as l,disabledClasses as o,gapClasses as s,hasContent as i,iconClasses as c,metaTextClasses as d,radiusClasses as u,readOnlyFilterClasses as f,sheetTitleClasses as p,stackGapClasses as m,surfaceClasses as h,surfaceSlots as v,transitionClasses as b}from"../../internal/styles.js";import{useStyleDefaults as x}from"../../internal/defaults.js";const g={default:{xs:"p-4",sm:"p-5",md:"p-6",lg:"p-8",xl:"p-10"},compact:{xs:"p-2",sm:"p-3",md:"p-4",lg:"p-5",xl:"p-6"}},y={solid:[h,"border-2 border-dashed text-(--neba-fg) bg-(--n-panel-hover)","[border-color:var(--n-line)]","[box-shadow:var(--n-elev),var(--neba-plate-glass)]"].join(" "),outline:[h,"border-2 border-dashed text-(--neba-fg) bg-(--n-panel)","[border-color:var(--n-line)]","[box-shadow:var(--n-elev),var(--neba-plate-glass)]"].join(" "),text:"border-2 border-dashed text-(--neba-fg) bg-transparent [border-color:var(--n-line)]"},k={solid:"hover:bg-(--n-panel-press) hover:[border-color:var(--n-line-hover)]",outline:"hover:bg-(--n-panel-hover) hover:[border-color:var(--n-line-hover)]",text:"hover:bg-(--n-soft) hover:[border-color:var(--n-line-hover)]"};function N(){return n("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[e("path",{d:"M8 10.5V2.75m0 0L5.25 5.5M8 2.75 10.75 5.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M2.75 9.75v1.75a1.75 1.75 0 0 0 1.75 1.75h7a1.75 1.75 0 0 0 1.75-1.75V9.75",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}export function formatFileSize(e){if(e<1e3)return`${e} B`;const n=["kB","MB","GB","TB"];let t=e/1e3,r=0;for(;t>=1e3&&r<n.length-1;)t/=1e3,r+=1;return`${t<10?t.toFixed(1):Math.round(t)} ${n[r]}`}function $(e,n){const t=e.name.toLowerCase(),r=e.type.toLowerCase();return n.split(",").map(e=>e.trim().toLowerCase()).filter(Boolean).some(e=>e.startsWith(".")?t.endsWith(e):e.endsWith("/*")?r.startsWith(`${e.slice(0,-1)}`):r===e)}export const FilePicker=/*@__PURE__*/t.forwardRef(function(h,j){const{variant:w="outline",size:z="md",color:L="primary",density:C="default",elevation:_=0,accept:E,multiple:D=!1,maxSize:F,maxFiles:I,value:M,defaultValue:B,onFilesChange:W,onReject:S,label:R,description:T,error:V,invalid:O,title:q,hint:A,icon:G,showList:P=!0,removeLabel:H=e=>`Remove ${e}`,fullWidth:Y=!0,disabled:J=!1,readOnly:K=!1,required:Q=!1,name:U,id:X,className:Z,style:ee,...ne}=x(h,["size","density","variant"]),te=t.useRef(null);t.useImperativeHandle(j,()=>te.current);const[re,ae]=t.useState(()=>[...B??[]]),le=t.useMemo(()=>M?[...M]:re,[M,re]),oe=t.useRef(0),[se,ie]=t.useState(!1);t.useEffect(()=>{const e=()=>{oe.current=0,ie(!1)};return document.addEventListener("dragend",e,!0),document.addEventListener("drop",e,!0),()=>{document.removeEventListener("dragend",e,!0),document.removeEventListener("drop",e,!0)}},[]);const ce=i(V),de=O??ce,ue=de?"danger":L,fe=J||K,pe=t.useId(),me=t.useCallback(e=>{M||ae(e),W?.(e)},[W,M]),he=t.useCallback(e=>{const n=[],t=[],r=D?I??Number.POSITIVE_INFINITY:1,a=D?le.length:0;for(const l of e)E&&!$(l,E)?t.push({file:l,reason:"type"}):void 0!==F&&l.size>F?t.push({file:l,reason:"size"}):a+n.length>=r?t.push({file:l,reason:"count"}):n.push(l);return{kept:n,rejections:t}},[E,le.length,I,F,D]),ve=t.useCallback(e=>{const{kept:n,rejections:t}=he(e);t.length>0&&S?.(t),n.length>0&&me(D?[...le,...n]:n)},[he,me,le,D,S]),be=l("flex w-full flex-col items-center justify-center text-center","cursor-pointer select-none",g[C][z],u[z],s[z],b,c,"focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-2",J?`${o[w]} border-2 border-dashed`:K?`${y[w]} ${f} cursor-default`:y[w],fe?"":k[w],se&&!fe?"bg-(--n-soft-press) [border-color:var(--n-ring)]":"");return n("div",{className:l("flex-col align-top",m[z],Y?"flex w-full":"inline-flex",Z??""),style:{...v(ue,_),...ee},...ne,children:[i(R)?e("span",{className:[d[z],"font-medium",J?"text-(--neba-disabled-fg)":"text-(--neba-fg)"].join(" "),children:R}):null,n("div",{className:"flex w-full flex-col",onDragEnter:e=>{fe||(e.preventDefault(),oe.current+=1,ie(!0))},onDragOver:e=>{fe||(e.preventDefault(),e.dataTransfer.dropEffect="copy")},onDragLeave:()=>{fe||(oe.current=Math.max(0,oe.current-1),0===oe.current&&ie(!1))},onDrop:e=>{fe||(e.preventDefault(),oe.current=0,ie(!1),ve(function(e){const n=[...e.items],t=[...e.files];return n.length!==t.length?t:t.filter((e,t)=>{const r=n[t]?.webkitGetAsEntry?.();return!r||r.isFile})}(e.dataTransfer)))},children:[n("button",{type:"button",id:X,disabled:J,"aria-describedby":i(T)||ce?pe:void 0,"aria-invalid":de||void 0,className:be,onClick:()=>{fe||te.current&&(te.current.value="",te.current.click())},children:[void 0===G?e("span",{className:"flex items-center text-(--n-accent) [&_svg]:size-[1.8em]",children:e(N,{})}):i(G)?e("span",{className:"flex items-center text-(--n-accent) [&_svg]:size-[1.8em]",children:G}):null,e("span",{className:`font-medium ${p[z]}`,children:q??"Drop files here, or click to browse"}),i(A)?e("span",{className:`text-(--neba-muted-fg) ${d[z]}`,children:A}):null]}),e("input",{ref:te,type:"file",name:U,accept:E,multiple:D,required:Q&&0===le.length,disabled:fe,tabIndex:-1,"aria-hidden":"true",className:"absolute size-px overflow-hidden opacity-0 [clip-path:inset(50%)]",onChange:e=>ve(Array.from(e.target.files??[]))})]}),P&&le.length>0?e("ul",{role:"list",className:`flex w-full flex-col ${m[z]} m-0 list-none p-0`,children:le.map((t,l)=>n("li",{className:["flex w-full items-center gap-2 px-2 py-1.5",u.xs,a[z],"bg-(--n-soft) text-(--neba-fg)"].join(" "),children:[e("span",{className:"min-w-0 flex-1 truncate",children:t.name}),e("span",{className:`shrink-0 text-(--neba-muted-fg) tabular-nums ${d[z]}`,children:formatFileSize(t.size)}),fe?null:e("button",{type:"button","aria-label":H(t.name),className:["inline-flex shrink-0 cursor-pointer items-center justify-center rounded-full","size-[1.3em] text-(--neba-muted-fg) opacity-70","[transition:opacity_var(--neba-duration)_var(--neba-ease),color_var(--neba-duration)_var(--neba-ease)]","[&_svg]:size-[0.9em]","hover:text-(--neba-fg) hover:opacity-100 focus-visible:opacity-100","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-1"].join(" "),onClick:()=>me(le.filter((e,n)=>n!==l)),children:e(r,{})})]},`${t.name}-${t.size}-${t.lastModified}-${l}`))}):null,i(T)&&!ce?e("span",{id:pe,className:`${d[z]} text-(--neba-muted-fg)`,children:T}):null,ce?e("span",{id:pe,className:`${d[z]} text-(--n-accent)`,children:V}):null]})});
@@ -0,0 +1,93 @@
1
+ import * as React from 'react';
2
+ import { useRender } from '@base-ui/react/use-render';
3
+ import type { NebaAlignItems, NebaJustifyContent, NebaOrientation, NebaResponsive } from '../../types.js';
4
+ export interface FlexProps extends React.ComponentPropsWithoutRef<'div'> {
5
+ /**
6
+ * Which way the row runs, in the library's own two words rather than CSS's
7
+ * four — `horizontal` is a row and `vertical` is a column, and `reverse`
8
+ * turns either around.
9
+ *
10
+ * Responsive, and this is the prop the component exists for:
11
+ * `direction={{ xs: 'vertical', md: 'horizontal' }}` is a stack on a phone
12
+ * and a row from 48rem, which is most of what a responsive layout is.
13
+ * @default 'horizontal'
14
+ */
15
+ direction?: NebaResponsive<NebaOrientation>;
16
+ /**
17
+ * Runs the children the other way along whichever axis `direction` chose —
18
+ * `row-reverse` or `column-reverse`.
19
+ *
20
+ * Not responsive on purpose: it applies to every breakpoint's direction at
21
+ * once, which is what "the same row, backwards" means. It is a visual order
22
+ * only, so the DOM order is still what a screen reader and the tab sequence
23
+ * follow — reverse a row whose order carries meaning and the two disagree.
24
+ * @default false
25
+ */
26
+ reverse?: boolean;
27
+ /**
28
+ * The gutter between children, on Tailwind's spacing scale — `spacing={4}`
29
+ * is `1rem`, the same length `gap-4` is. Fractions are allowed, so `1.5` is
30
+ * `0.375rem`.
31
+ *
32
+ * The same prop, the same scale and the same slot a
33
+ * [GridContainer](../grid) uses, so a gutter is one number across the two.
34
+ * @default 0
35
+ */
36
+ spacing?: NebaResponsive<number>;
37
+ /** The gutter between wrapped lines only. Falls back to `spacing`. */
38
+ rowSpacing?: NebaResponsive<number>;
39
+ /** The gutter along the row only. Falls back to `spacing`. */
40
+ columnSpacing?: NebaResponsive<number>;
41
+ /** How the row distributes the space its children did not use. */
42
+ justifyContent?: NebaJustifyContent;
43
+ /** How the children sit across the axis the row runs on. */
44
+ alignItems?: NebaAlignItems;
45
+ /** Where wrapped lines sit when the box is taller than they are. */
46
+ alignContent?: NebaJustifyContent;
47
+ /**
48
+ * Whether a row that runs out of width continues on the next line.
49
+ *
50
+ * Off by default, which is the opposite of a `GridContainer` and deliberate:
51
+ * a grid is columns and wrapping is what columns do, while a Flex is most
52
+ * often a toolbar or a field row that should stay on one line and let its
53
+ * children shrink.
54
+ * @default false
55
+ */
56
+ wrap?: boolean;
57
+ /** Lays the box out inline, so it sits in a line of text. @default false */
58
+ inline?: boolean;
59
+ /**
60
+ * Renders something other than a `<div>`: `render={<nav />}`,
61
+ * `render={<ul />}`. Base UI's own escape hatch.
62
+ */
63
+ render?: useRender.RenderProp;
64
+ children?: React.ReactNode;
65
+ }
66
+ /**
67
+ * A row, or a column, and the width at which it changes from one to the other.
68
+ *
69
+ * This is the most common responsive decision there is — a pair of buttons side
70
+ * by side on a desktop and stacked on a phone, a form's label beside its field
71
+ * and then above it — and until now the only way to say it was a
72
+ * [GridContainer](../grid) with a `Grid` around each child, which is two
73
+ * components and a column count to describe a row of two things.
74
+ *
75
+ * `direction` is the whole point and is responsive; `spacing` is the gutter, on
76
+ * the same scale and through the same slot a grid's is, so one number means one
77
+ * length across both. Everything else is the flexbox vocabulary spelled the way
78
+ * the rest of the library spells it.
79
+ *
80
+ * It draws nothing at all — no surface, no padding, not even a gutter unless
81
+ * one is asked for. That is the difference between it and a `GridContainer`,
82
+ * which pads by default because a grid is a page's own arrangement; a Flex is
83
+ * used inside everything, and a wrapper that changed how its children looked
84
+ * would make `direction` a visual decision. Put it in a Box or a Card when a
85
+ * sheet is wanted.
86
+ *
87
+ * The direction and the gutters arrive as inherited custom properties rather
88
+ * than through a context, for the reason `GridContainer` does the same: a media
89
+ * query can change one without React hearing about it, so what is on screen is
90
+ * always what the window is currently worth. A context would have to re-render
91
+ * the tree at every breakpoint to say the same thing.
92
+ */
93
+ export declare const Flex: React.ForwardRefExoticComponent<FlexProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1 @@
1
+ "use client";import*as e from"react";import{useRender as r}from"@base-ui/react/use-render";import{alignContentClasses as n,alignItemsClasses as i,justifyContentClasses as t,spacingValue as a}from"../../internal/grid.js";import{overlayResponsive as o,responsiveSlots as l,withBaseline as s}from"../../internal/responsive.js";import{cx as p}from"../../internal/styles.js";function c(e){return r=>{const n="vertical"===r?"column":"row";return e?`${n}-reverse`:n}}export const Flex=/*@__PURE__*/e.forwardRef(function({direction:e,reverse:f=!1,spacing:m,rowSpacing:x,columnSpacing:g,justifyContent:d,alignItems:u,alignContent:y,wrap:w=!1,inline:v=!1,render:j,className:h,style:b,children:C,...N},S){const z=p("neba-flex",v?"inline-flex":"flex","[flex-direction:var(--n-flex-dir)] gap-x-(--n-gap-x) gap-y-(--n-gap-y)",w?"flex-wrap":"flex-nowrap",d?t[d]:"",u?i[u]:"",y?n[y]:"",h??"");return r({render:j,ref:S,props:{className:z,style:{...l("flex-dir",s(e,"horizontal"),c(f)),...l("gap-x",o(s(m,0),g),a),...l("gap-y",o(s(m,0),x),a),...b},children:C,...N}})});
@@ -0,0 +1,2 @@
1
+ export { Flex } from './Flex.js';
2
+ export type { FlexProps } from './Flex.js';
@@ -0,0 +1 @@
1
+ export{Flex}from"./Flex.js";
@@ -1 +1 @@
1
- "use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as o from"react";import{Button as n}from"../button/Button.js";import{CloseIcon as s,PlusIcon as a}from"../../internal/icons.js";import{cx as r,hasContent as i,metaTextClasses as l,radiusClasses as c,surfaceClasses as d}from"../../internal/styles.js";const f=/*@__PURE__*/o.createContext({variant:"solid",size:"md",color:"primary",density:"default",elevation:1,showLabels:!0,reversed:!0,close:()=>{}}),p={xs:"xs",sm:"xs",md:"sm",lg:"md",xl:"lg"},m={static:"",absolute:"absolute z-30",sticky:"sticky z-30",fixed:"fixed z-40"},u={"top-start":"top-(--n-fab-offset) start-(--n-fab-offset)","top-end":"top-(--n-fab-offset) end-(--n-fab-offset)","bottom-start":"bottom-(--n-fab-offset) start-(--n-fab-offset)","bottom-end":"bottom-(--n-fab-offset) end-(--n-fab-offset)"},b=r("pointer-events-none max-w-40 truncate select-none","px-2 py-0.5 text-(--neba-fg) bg-(--n-panel)",d,c.xs,"[box-shadow:var(--neba-shadow-1),var(--neba-plate-glass)]");export const FloatingActionButton=/*@__PURE__*/o.forwardRef(function({variant:i="solid",size:l="lg",color:c="primary",density:d="default",elevation:b=2,icon:v,label:x,extended:y=!1,openIcon:h,position:g="fixed",corner:w="bottom-end",offset:z=16,direction:C,open:k,defaultOpen:L=!1,onOpenChange:N,openOnHover:j=!0,closeOnAction:E=!0,showLabels:P=!0,disabled:R=!1,className:A,style:I,children:O,onClick:B,onKeyDown:D,onPointerEnter:F,onPointerLeave:K,...T},W){const H=o.useId(),M=o.useRef(null),S=o.useRef(null),[$,q]=o.useState(L),G=void 0!==k,J=o.Children.toArray(O).length>0,Q=(G?k:$)&&J&&!R,U=o.useCallback(e=>{G||q(e),N?.(e)},[G,N]),V=o.useCallback(()=>U(!1),[U]);o.useEffect(()=>{if(!Q)return;const e=e=>{const t=S.current;t&&e.target instanceof Node&&!t.contains(e.target)&&V()};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[Q,V]);const X=C??(w.startsWith("bottom")?"top":"bottom"),Y=w.endsWith("end"),Z=o.useMemo(()=>({variant:i,size:p[l],color:c,density:d,elevation:b,showLabels:P,reversed:Y,close:E?V:()=>{}}),[i,l,c,d,b,P,Y,E,V]),_=Q&&!1!==h?h??e(s,{}):v??e(a,{});return t("div",{ref:e=>{S.current=e,"function"==typeof W?W(e):W&&(W.current=e)},className:r("flex w-fit","top"===X?"flex-col-reverse":"flex-col",Y?"items-end":"items-start","xs"===l||"sm"===l?"gap-1.5":"gap-2",m[g],"static"===g?"":u[w],A),style:{"--n-fab-offset":"number"==typeof z?`${z}px`:z,...I},onKeyDown:e=>{"Escape"===e.key&&Q&&(e.stopPropagation(),V(),M.current?.focus()),D?.(e)},onPointerEnter:e=>{j&&J&&!R&&"mouse"===e.pointerType&&U(!0),F?.(e)},onPointerLeave:e=>{j&&"mouse"===e.pointerType&&V(),K?.(e)},...T,children:[e(n,{ref:M,variant:i,size:l,color:c,density:d,elevation:b,disabled:R,"aria-label":x,"aria-expanded":J?Q:void 0,"aria-controls":J&&Q?H:void 0,startIcon:_,style:{borderRadius:"9999px"},onClick:e=>{J&&U(!Q),B?.(e)},children:y?x:void 0}),Q?e("div",{id:H,className:r("flex","top"===X?"flex-col-reverse":"flex-col",Y?"items-end":"items-start","xs"===l||"sm"===l?"gap-1.5":"gap-2"),children:e(f.Provider,{value:Z,children:O})}):null]})});export const FloatingAction=/*@__PURE__*/o.forwardRef(function({icon:s,label:a,disabled:c=!1,className:d,onClick:p,...m},u){const v=o.useContext(f);return t("div",{className:r("flex items-center gap-2",v.reversed?"flex-row-reverse":"flex-row",d),children:[e(n,{ref:u,variant:v.variant,size:v.size,color:v.color,density:v.density,elevation:v.elevation,disabled:c,"aria-label":a,startIcon:s,style:{borderRadius:"9999px"},onClick:e=>{p?.(e),v.close()},...m}),v.showLabels&&i(a)?e("span",{"aria-hidden":"true",className:r(b,l[v.size]),children:a}):null]})});
1
+ "use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as o from"react";import{Button as n}from"../button/Button.js";import{CloseIcon as s,PlusIcon as a}from"../../internal/icons.js";import{cx as r,hasContent as i,metaTextClasses as l,radiusClasses as d,surfaceClasses as c}from"../../internal/styles.js";import{useStyleDefaults as f}from"../../internal/defaults.js";const m=/*@__PURE__*/o.createContext({variant:"solid",size:"md",color:"primary",density:"default",elevation:1,showLabels:!0,reversed:!0,close:()=>{}}),p={xs:"xs",sm:"xs",md:"sm",lg:"md",xl:"lg"},u="lg",b={static:"",absolute:"absolute z-30",sticky:"sticky z-30",fixed:"fixed z-40"},v={"top-start":"top-(--n-fab-offset) start-(--n-fab-offset)","top-end":"top-(--n-fab-offset) end-(--n-fab-offset)","bottom-start":"bottom-(--n-fab-offset) start-(--n-fab-offset)","bottom-end":"bottom-(--n-fab-offset) end-(--n-fab-offset)"},x=r("pointer-events-none max-w-40 truncate select-none","px-2 py-0.5 text-(--neba-fg) bg-(--n-panel)",c,d.xs,"[box-shadow:var(--neba-shadow-1),var(--neba-plate-glass)]");export const FloatingActionButton=/*@__PURE__*/o.forwardRef(function(i,l){const{variant:d="solid",size:c=u,color:x="primary",density:y="default",elevation:h=2,icon:g,label:w,extended:z=!1,openIcon:C,position:k="fixed",corner:L="bottom-end",offset:j=16,direction:N,open:E,defaultOpen:P=!1,onOpenChange:R,openOnHover:A=!0,closeOnAction:I=!0,showLabels:O=!0,disabled:_=!1,className:B,style:D,children:F,onClick:K,onKeyDown:T,onPointerEnter:W,onPointerLeave:H,...M}=f(i,["size","density","variant"]),S=o.useId(),$=o.useRef(null),q=o.useRef(null),[G,J]=o.useState(P),Q=void 0!==E,U=o.Children.toArray(F).length>0,V=(Q?E:G)&&U&&!_,X=o.useCallback(e=>{Q||J(e),R?.(e)},[Q,R]),Y=o.useCallback(()=>X(!1),[X]);o.useEffect(()=>{if(!V)return;const e=e=>{const t=q.current;t&&e.target instanceof Node&&!t.contains(e.target)&&Y()};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[V,Y]);const Z=N??(L.startsWith("bottom")?"top":"bottom"),ee=L.endsWith("end"),te=o.useMemo(()=>({variant:d,size:p[c],color:x,density:y,elevation:h,showLabels:O,reversed:ee,close:I?Y:()=>{}}),[d,c,x,y,h,O,ee,I,Y]),oe=V&&!1!==C?C??e(s,{}):g??e(a,{});return t("div",{ref:e=>{q.current=e,"function"==typeof l?l(e):l&&(l.current=e)},className:r("flex w-fit","top"===Z?"flex-col-reverse":"flex-col",ee?"items-end":"items-start","xs"===c||"sm"===c?"gap-1.5":"gap-2",b[k],"static"===k?"":v[L],B),style:{"--n-fab-offset":"number"==typeof j?`${j}px`:j,...D},onKeyDown:e=>{"Escape"===e.key&&V&&(e.stopPropagation(),Y(),$.current?.focus()),T?.(e)},onPointerEnter:e=>{A&&U&&!_&&"mouse"===e.pointerType&&X(!0),W?.(e)},onPointerLeave:e=>{A&&"mouse"===e.pointerType&&Y(),H?.(e)},...M,children:[e(n,{ref:$,variant:d,size:c,color:x,density:y,elevation:h,disabled:_,"aria-label":w,"aria-expanded":U?V:void 0,"aria-controls":U&&V?S:void 0,startIcon:oe,style:{borderRadius:"9999px"},onClick:e=>{U&&X(!V),K?.(e)},children:z?w:void 0}),V?e("div",{id:S,className:r("flex","top"===Z?"flex-col-reverse":"flex-col",ee?"items-end":"items-start","xs"===c||"sm"===c?"gap-1.5":"gap-2","[animation:neba-anim-fade_var(--neba-duration)_var(--neba-ease)_both]"),children:e(m.Provider,{value:te,children:F})}):null]})});export const FloatingAction=/*@__PURE__*/o.forwardRef(function({icon:s,label:a,disabled:d=!1,className:c,onClick:f,...p},u){const b=o.useContext(m);return t("div",{className:r("flex items-center gap-2",b.reversed?"flex-row-reverse":"flex-row",c),children:[e(n,{ref:u,variant:b.variant,size:b.size,color:b.color,density:b.density,elevation:b.elevation,disabled:d,"aria-label":a,startIcon:s,style:{borderRadius:"9999px"},onClick:e=>{f?.(e),b.close()},...p}),b.showLabels&&i(a)?e("span",{"aria-hidden":"true",className:r(x,l[b.size]),children:a}):null]})});