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 n}from"react/jsx-runtime";import*as i from"react";import{useRender as o}from"@base-ui/react/use-render";import{beginPointerDrag as r}from"../../internal/drag.js";import{actionMessages as a,useMessages as s,windowMessages as l}from"../../internal/i18n.js";import{cx as d,hasContent as c,iconClasses as u,surfaceClasses as m}from"../../internal/styles.js";import{WindowControls as h,orderControls as f,windowChrome as w,windowMetrics as g,windowSlots as p}from"../../internal/window.js";function b(e,t,n){const[o,r]=i.useState(t),a=void 0!==e;return[a?e:o,i.useCallback(e=>{a||r(e),n?.(e)},[a,n])]}const v=[{edge:"n",className:"inset-x-3 top-0 h-1.5 cursor-ns-resize"},{edge:"s",className:"inset-x-3 bottom-0 h-1.5 cursor-ns-resize"},{edge:"w",className:"inset-y-3 left-0 w-1.5 cursor-ew-resize"},{edge:"e",className:"inset-y-3 right-0 w-1.5 cursor-ew-resize"},{edge:"nw",className:"top-0 left-0 size-3 cursor-nwse-resize"},{edge:"ne",className:"top-0 right-0 size-3 cursor-nesw-resize"},{edge:"sw",className:"bottom-0 left-0 size-3 cursor-nesw-resize"},{edge:"se",className:"right-0 bottom-0 size-3 cursor-nwse-resize"}];export const WindowPane=/*@__PURE__*/i.forwardRef(function({os:x="macos",title:z,icon:y,actions:N,controls:M=!0,size:C="md",color:E="primary",accent:S=!1,transparency:k=0,active:L,elevation:I=2,position:R="static",draggable:j=!1,resizable:B=!1,width:D,height:A,minWidth:T=180,minHeight:H,offset:P,defaultOffset:W,onOffsetChange:O,onResize:X,open:$,defaultOpen:F=!0,onOpenChange:Y,minimized:_,defaultMinimized:q=!1,onMinimizedChange:K,maximized:U,defaultMaximized:G=!1,onMaximizedChange:J,scroll:Q=!0,locale:V,minimizeLabel:Z,maximizeLabel:ee,restoreLabel:te,closeLabel:ne,resizeLabel:ie,render:oe,className:re,style:ae,children:se,...le},de){const ce=s(l,V),ue=s(a,V),me=w(x),he=g(x,C),fe=i.useId(),[we,ge]=b($,F,Y),[pe,be]=b(_,q,K),[ve,xe]=b(U,G,J),[ze,ye]=b(P,W??{x:0,y:0},O),[Ne,Me]=i.useState(null),[Ce,Ee]=i.useState(!0),Se=L??Ce,[ke,Le]=i.useState(null),[Ie,Re]=i.useState(null),[je,Be]=i.useState(!1),[De,Ae]=i.useState(!1),[Te,He]=i.useState(we);Te!==we&&(He(we),Ae(!we)),i.useEffect(()=>{if(!De)return;const e=window.setTimeout(()=>Ae(!1),260);return()=>window.clearTimeout(e)},[De]);const Pe=i.useRef(null),We=i.useCallback(e=>{Pe.current=e,"function"==typeof de?de(e):de&&(de.current=e)},[de]);i.useEffect(()=>{if(void 0!==L)return;const e=Pe.current;if(!e)return;const t=t=>{const n=t.target;if(!(n instanceof Node))return;if(e.contains(n))return void Ee(!0);const i=n instanceof Element?n:n.parentElement;i?.closest(".neba-window")&&Ee(!1)};return document.addEventListener("pointerdown",t,!0),document.addEventListener("focusin",t,!0),()=>{document.removeEventListener("pointerdown",t,!0),document.removeEventListener("focusin",t,!0)}},[L]);const Oe=i.useRef(null);function Xe(e,t){if(0!==e.button)return;Oe.current?.();const n=e.currentTarget,i=e.clientX,o=e.clientY;Be(!0);const a=()=>{Oe.current=null,Be(!1)},s=r({target:n,pointerId:e.pointerId,onMove:e=>t(e.clientX-i,e.clientY-o),onEnd:a});Oe.current=()=>{s(),a()}}i.useEffect(()=>()=>Oe.current?.(),[]);const $e={width:Math.max(0,T),height:Math.max(he.bar,H??he.bar)};function Fe(e){Me(e),X?.(e)}const Ye=f(x,!0===M?["minimize","maximize","close"]:!1===M?[]:M),_e=Ye.includes("maximize");i.useEffect(()=>{if(pe||null===Ie)return;const e=window.setTimeout(()=>Re(null),400);return()=>window.clearTimeout(e)},[pe,Ie]);const qe={minimize:Z??ce.minimize,maximize:ee??ce.maximize,restore:te??ce.restore,close:ne??ue.close},Ke=e(h,{os:x,metrics:he,controls:Ye,maximized:ve,active:Se,labels:qe,onCommand:function(e){"close"===e?ge(!1):"minimize"===e?function(e){const t=Pe.current,n=t?.firstElementChild;if(t&&n instanceof HTMLElement&&Le(n.offsetHeight+(t.offsetHeight-t.clientHeight)),e&&void 0===(Ne?.height??A)&&t)return Re(t.getBoundingClientRect().height),void requestAnimationFrame(()=>be(!0));be(e)}(!pe):xe(!ve)}}),Ue=c(z)?e("span",{id:fe,className:"min-w-0 truncate",children:z}):null,Ge=c(y)?e("span",{className:"flex shrink-0 items-center",children:y}):null,Je=t("div",{className:d("relative flex shrink-0 items-center select-none",u,j&&!ve?"cursor-grab active:cursor-grabbing":""),style:{height:he.bar,textShadow:"var(--n-window-bar-shadow)",fontWeight:he.weight,paddingInlineStart:he.padX,paddingInlineEnd:he.padEnd,gap:Math.round(.7*he.title),fontSize:he.title,backgroundColor:"var(--n-window-bar)",backgroundImage:"var(--n-window-bar-image)",color:"var(--n-window-bar-fg)",borderBlockEnd:me.rule?"1px solid var(--n-window-line)":void 0},onPointerDown:function(e){if(!j||ve)return;const t={...ze};Xe(e,(e,n)=>ye({x:t.x+e,y:t.y+n}))},onDoubleClick:_e?()=>xe(!ve):void 0,children:["start"===me.controlsSide?Ke:null,"center"===me.titleAlign?e("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 flex items-center justify-center",style:{paddingInline:he.controlsWidth(Ye.length)+2*he.padX},children:t("span",{className:"flex min-w-0 items-center",style:{gap:Math.round(.5*he.title)},children:[Ge,Ue]})}):t(n,{children:[Ge,Ue]}),e("span",{className:"flex-1"}),c(N)?e("span",{className:"flex shrink-0 items-center",style:{gap:Math.round(.5*he.title)},onPointerDown:e=>e.stopPropagation(),children:N}):null,"end"===me.controlsSide?Ke:null]}),Qe=ve?{left:0,top:0,width:"100%",height:"100%"}:{left:ze.x,top:ze.y,width:Ne?.width??D,height:pe?ke??he.bar:Ne?.height??A??Ie??void 0},Ve=o({render:oe,ref:We,props:{role:"group","aria-labelledby":Ue?fe:void 0,className:d("neba-window relative flex min-w-0 flex-col overflow-hidden",k>0?m:"",me.glass&&0===k?"[backdrop-filter:var(--neba-blur)]":"","[transition-property:left,top,width,height,opacity,box-shadow,background-color,border-color,border-radius]","[transition-duration:var(--neba-duration-window)]","[transition-timing-function:var(--neba-ease)]","motion-reduce:[transition-duration:0ms]","data-[gesture]:[transition-property:none]",re),"data-gesture":je?"":void 0,inert:!we||void 0,style:{opacity:we?void 0:0,...p({os:x,color:E,accent:S,transparency:k,active:Se,elevation:I}),position:"static"===R?"relative":R,...Qe,borderRadius:ve?0:`${he.radius}px ${he.radius}px ${he.radiusBottom}px ${he.radiusBottom}px`,borderStyle:"solid",borderWidth:he.frame,borderColor:"var(--n-window-line)",backgroundColor:"var(--n-window-band)",boxShadow:"var(--n-window-shadow), var(--neba-plate-glass)",...ae},children:t(n,{children:[Je,e("div",{className:d("min-h-0 flex-1",Q?"overflow-auto":"overflow-hidden"),style:{backgroundColor:"var(--n-window-body)",marginInline:he.band.side,marginBottom:he.band.bottom,boxShadow:he.band.side>0?"inset 0 0 0 1px rgb(0 0 0 / 0.12)":void 0},inert:pe,children:se}),!B||ve||pe?null:v.map(t=>{const n="se"===t.edge;return e("div",{role:n?"button":void 0,tabIndex:n?0:void 0,"aria-label":n?ie??ce.resize:void 0,"aria-hidden":n?void 0:"true",className:d("absolute z-10 touch-none",t.className,n?"focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:[outline-offset:-2px]":""),onPointerDown:e=>function(e,t){const n=Pe.current;if(!n||ve)return;const i=n.getBoundingClientRect(),o={width:i.width,height:i.height,x:ze.x,y:ze.y},r=e.includes("e"),a=e.includes("w"),s=e.includes("n"),l=e.includes("s");Xe(t,(e,t)=>{let{width:n,height:i}=o,{x:d,y:c}=o;r&&(n=Math.max($e.width,o.width+e)),l&&(i=Math.max($e.height,o.height+t)),a&&(n=Math.max($e.width,o.width-e),d=o.x+(o.width-n)),s&&(i=Math.max($e.height,o.height-t),c=o.y+(o.height-i)),Fe({width:n,height:i}),(a||s)&&ye({x:d,y:c})})}(t.edge,e),onKeyDown:n?e=>{const t={ArrowRight:[16,0],ArrowLeft:[-16,0],ArrowDown:[0,16],ArrowUp:[0,-16]}[e.key];t&&(e.preventDefault(),function(e,t){const n=Pe.current;if(!n)return;const i=n.getBoundingClientRect();Fe({width:Math.max($e.width,i.width+e),height:Math.max($e.height,i.height+t)})}(t[0],t[1]))}:void 0},t.edge)})]}),...le}});return we||De?Ve:null});
1
+ "use client";import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import*as i from"react";import{useRender as o}from"@base-ui/react/use-render";import{beginPointerDrag as r}from"../../internal/drag.js";import{actionMessages as a,useMessages as s,windowMessages as l}from"../../internal/i18n.js";import{cx as d,hasContent as c,iconClasses as u,surfaceClasses as m}from"../../internal/styles.js";import{WindowControls as h,orderControls as f,windowChrome as w,windowMetrics as g,windowSlots as p}from"../../internal/window.js";import{useStyleDefaults as b}from"../../internal/defaults.js";function v(e,t,n){const[o,r]=i.useState(t),a=void 0!==e;return[a?e:o,i.useCallback(e=>{a||r(e),n?.(e)},[a,n])]}const x=[{edge:"n",className:"inset-x-3 top-0 h-1.5 cursor-ns-resize"},{edge:"s",className:"inset-x-3 bottom-0 h-1.5 cursor-ns-resize"},{edge:"w",className:"inset-y-3 left-0 w-1.5 cursor-ew-resize"},{edge:"e",className:"inset-y-3 right-0 w-1.5 cursor-ew-resize"},{edge:"nw",className:"top-0 left-0 size-3 cursor-nwse-resize"},{edge:"ne",className:"top-0 right-0 size-3 cursor-nesw-resize"},{edge:"sw",className:"bottom-0 left-0 size-3 cursor-nesw-resize"},{edge:"se",className:"right-0 bottom-0 size-3 cursor-nwse-resize"}];export const WindowPane=/*@__PURE__*/i.forwardRef(function(z,y){const{os:N="macos",title:M,icon:C,actions:E,controls:S=!0,size:k="md",color:L="primary",accent:j=!1,transparency:I=0,active:R,elevation:B=2,position:D="static",draggable:A=!1,resizable:T=!1,width:H,height:P,minWidth:W=180,minHeight:O,offset:X,defaultOffset:$,onOffsetChange:F,onResize:Y,open:_,defaultOpen:q=!0,onOpenChange:K,minimized:U,defaultMinimized:G=!1,onMinimizedChange:J,maximized:Q,defaultMaximized:V=!1,onMaximizedChange:Z,scroll:ee=!0,locale:te,minimizeLabel:ne,maximizeLabel:ie,restoreLabel:oe,closeLabel:re,resizeLabel:ae,render:se,className:le,style:de,children:ce,...ue}=b(z,["size","locale"]),me=s(l,te),he=s(a,te),fe=w(N),we=g(N,k),ge=i.useId(),[pe,be]=v(_,q,K),[ve,xe]=v(U,G,J),[ze,ye]=v(Q,V,Z),[Ne,Me]=v(X,$??{x:0,y:0},F),[Ce,Ee]=i.useState(null),[Se,ke]=i.useState(!0),Le=R??Se,[je,Ie]=i.useState(null),[Re,Be]=i.useState(null),[De,Ae]=i.useState(!1),[Te,He]=i.useState(!1),[Pe,We]=i.useState(pe);Pe!==pe&&(We(pe),He(!pe)),i.useEffect(()=>{if(!Te)return;const e=window.setTimeout(()=>He(!1),260);return()=>window.clearTimeout(e)},[Te]);const Oe=i.useRef(null),Xe=i.useCallback(e=>{Oe.current=e,"function"==typeof y?y(e):y&&(y.current=e)},[y]);i.useEffect(()=>{if(void 0!==R)return;const e=Oe.current;if(!e)return;const t=t=>{const n=t.target;if(!(n instanceof Node))return;if(e.contains(n))return void ke(!0);const i=n instanceof Element?n:n.parentElement;i?.closest(".neba-window")&&ke(!1)};return document.addEventListener("pointerdown",t,!0),document.addEventListener("focusin",t,!0),()=>{document.removeEventListener("pointerdown",t,!0),document.removeEventListener("focusin",t,!0)}},[R]);const $e=i.useRef(null);function Fe(e,t){if(0!==e.button)return;$e.current?.();const n=e.currentTarget,i=e.clientX,o=e.clientY;Ae(!0);const a=()=>{$e.current=null,Ae(!1)},s=r({target:n,pointerId:e.pointerId,onMove:e=>t(e.clientX-i,e.clientY-o),onEnd:a});$e.current=()=>{s(),a()}}i.useEffect(()=>()=>$e.current?.(),[]);const Ye={width:Math.max(0,W),height:Math.max(we.bar,O??we.bar)};function _e(e){Ee(e),Y?.(e)}const qe=f(N,!0===S?["minimize","maximize","close"]:!1===S?[]:S),Ke=qe.includes("maximize");i.useEffect(()=>{if(ve||null===Re)return;const e=window.setTimeout(()=>Be(null),400);return()=>window.clearTimeout(e)},[ve,Re]);const Ue={minimize:ne??me.minimize,maximize:ie??me.maximize,restore:oe??me.restore,close:re??he.close},Ge=e(h,{os:N,metrics:we,controls:qe,maximized:ze,active:Le,labels:Ue,onCommand:function(e){"close"===e?be(!1):"minimize"===e?function(e){const t=Oe.current,n=t?.firstElementChild;if(t&&n instanceof HTMLElement&&Ie(n.offsetHeight+(t.offsetHeight-t.clientHeight)),e&&void 0===(Ce?.height??P)&&t)return Be(t.getBoundingClientRect().height),void requestAnimationFrame(()=>xe(!0));xe(e)}(!ve):ye(!ze)}}),Je=c(M)?e("span",{id:ge,className:"min-w-0 truncate",children:M}):null,Qe=c(C)?e("span",{className:"flex shrink-0 items-center",children:C}):null,Ve=t("div",{className:d("relative flex shrink-0 items-center select-none",u,A&&!ze?"cursor-grab active:cursor-grabbing":""),style:{height:we.bar,textShadow:"var(--n-window-bar-shadow)",fontWeight:we.weight,paddingInlineStart:we.padX,paddingInlineEnd:we.padEnd,gap:Math.round(.7*we.title),fontSize:we.title,backgroundColor:"var(--n-window-bar)",backgroundImage:"var(--n-window-bar-image)",color:"var(--n-window-bar-fg)",borderBlockEnd:fe.rule?"1px solid var(--n-window-line)":void 0},onPointerDown:function(e){if(!A||ze)return;const t={...Ne};Fe(e,(e,n)=>Me({x:t.x+e,y:t.y+n}))},onDoubleClick:Ke?()=>ye(!ze):void 0,children:["start"===fe.controlsSide?Ge:null,"center"===fe.titleAlign?e("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 flex items-center justify-center",style:{paddingInline:we.controlsWidth(qe.length)+2*we.padX},children:t("span",{className:"flex min-w-0 items-center",style:{gap:Math.round(.5*we.title)},children:[Qe,Je]})}):t(n,{children:[Qe,Je]}),e("span",{className:"flex-1"}),c(E)?e("span",{className:"flex shrink-0 items-center",style:{gap:Math.round(.5*we.title)},onPointerDown:e=>e.stopPropagation(),children:E}):null,"end"===fe.controlsSide?Ge:null]}),Ze=ze?{left:0,top:0,width:"100%",height:"100%"}:{left:Ne.x,top:Ne.y,width:Ce?.width??H,height:ve?je??we.bar:Ce?.height??P??Re??void 0},et=o({render:se,ref:Xe,props:{role:"group","aria-labelledby":Je?ge:void 0,className:d("neba-window relative flex min-w-0 flex-col overflow-hidden",I>0?m:"",fe.glass&&0===I?"[backdrop-filter:var(--neba-blur)]":"","[transition-property:left,top,width,height,opacity,box-shadow,background-color,border-color,border-radius]","[transition-duration:var(--neba-duration-window)]","[transition-timing-function:var(--neba-ease)]","motion-reduce:[transition-duration:0ms]","data-[gesture]:[transition-property:none]",le),"data-gesture":De?"":void 0,inert:!pe||void 0,style:{opacity:pe?void 0:0,...p({os:N,color:L,accent:j,transparency:I,active:Le,elevation:B}),position:"static"===D?"relative":D,...Ze,borderRadius:ze?0:`${we.radius}px ${we.radius}px ${we.radiusBottom}px ${we.radiusBottom}px`,borderStyle:"solid",borderWidth:we.frame,borderColor:"var(--n-window-line)",backgroundColor:"var(--n-window-band)",boxShadow:"var(--n-window-shadow), var(--neba-plate-glass)",...de},children:t(n,{children:[Ve,e("div",{className:d("min-h-0 flex-1",ee?"overflow-auto":"overflow-hidden"),style:{backgroundColor:"var(--n-window-body)",marginInline:we.band.side,marginBottom:we.band.bottom,boxShadow:we.band.side>0?"inset 0 0 0 1px rgb(0 0 0 / 0.12)":void 0},inert:ve,children:ce}),!T||ze||ve?null:x.map(t=>{const n="se"===t.edge;return e("div",{role:n?"button":void 0,tabIndex:n?0:void 0,"aria-label":n?ae??me.resize:void 0,"aria-hidden":n?void 0:"true",className:d("absolute z-10 touch-none",t.className,n?"focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:[outline-offset:-2px]":""),onPointerDown:e=>function(e,t){const n=Oe.current;if(!n||ze)return;const i=n.getBoundingClientRect(),o={width:i.width,height:i.height,x:Ne.x,y:Ne.y},r=e.includes("e"),a=e.includes("w"),s=e.includes("n"),l=e.includes("s");Fe(t,(e,t)=>{let{width:n,height:i}=o,{x:d,y:c}=o;r&&(n=Math.max(Ye.width,o.width+e)),l&&(i=Math.max(Ye.height,o.height+t)),a&&(n=Math.max(Ye.width,o.width-e),d=o.x+(o.width-n)),s&&(i=Math.max(Ye.height,o.height-t),c=o.y+(o.height-i)),_e({width:n,height:i}),(a||s)&&Me({x:d,y:c})})}(t.edge,e),onKeyDown:n?e=>{const t={ArrowRight:[16,0],ArrowLeft:[-16,0],ArrowDown:[0,16],ArrowUp:[0,-16]}[e.key];t&&(e.preventDefault(),function(e,t){const n=Oe.current;if(!n)return;const i=n.getBoundingClientRect();_e({width:Math.max(Ye.width,i.width+e),height:Math.max(Ye.height,i.height+t)})}(t[0],t[1]))}:void 0},t.edge)})]}),...ue}});return pe||Te?et:null});
@@ -0,0 +1,10 @@
1
+ export { useDisclosure } from './useDisclosure.js';
2
+ export type { Disclosure } from './useDisclosure.js';
3
+ export { useElementSize } from './useElementSize.js';
4
+ export type { ElementSize } from './useElementSize.js';
5
+ export { useBreakpoint, useBreakpointValue, useCurrentBreakpoint, useMediaQuery } from './useMediaQuery.js';
6
+ export { useOnScreen } from './useOnScreen.js';
7
+ export type { OnScreenOptions } from './useOnScreen.js';
8
+ export { useShortcut } from './useShortcut.js';
9
+ export type { ShortcutOptions } from './useShortcut.js';
10
+ export { usePrefersReducedMotion } from '../internal/media.js';
@@ -0,0 +1 @@
1
+ export{useDisclosure}from"./useDisclosure.js";export{useElementSize}from"./useElementSize.js";export{useBreakpoint,useBreakpointValue,useCurrentBreakpoint,useMediaQuery}from"./useMediaQuery.js";export{useOnScreen}from"./useOnScreen.js";export{useShortcut}from"./useShortcut.js";export{usePrefersReducedMotion}from"../internal/media.js";
@@ -0,0 +1,21 @@
1
+ /** What `useDisclosure` hands back: the state, and the three ways to change it. */
2
+ export interface Disclosure {
3
+ open: boolean;
4
+ setOpen: (open: boolean) => void;
5
+ onOpen: () => void;
6
+ onClose: () => void;
7
+ onToggle: () => void;
8
+ }
9
+ /**
10
+ * The caller's half of the `open` / `onOpenChange` pair every overlay in the
11
+ * library offers.
12
+ *
13
+ * A Dialog, a Drawer, a Popover, a Tour, a Menu, a CommandPalette and all four
14
+ * pickers take the same three props, so the state beside them is the same six
15
+ * lines every time — and the sixth is the one that gets written wrong: a
16
+ * `setOpen(!open)` closed over a stale render rather than an updater.
17
+ *
18
+ * Every function it returns is stable for the life of the component, so passing
19
+ * `onClose` straight to a memoised child does not re-render it on every open.
20
+ */
21
+ export declare function useDisclosure(defaultOpen?: boolean): Disclosure;
@@ -0,0 +1 @@
1
+ "use client";import*as e from"react";export function useDisclosure(o=!1){const[s,n]=e.useState(o),l=e.useCallback(()=>n(!0),[]),t=e.useCallback(()=>n(!1),[]),u=e.useCallback(()=>n(e=>!e),[]);return e.useMemo(()=>({open:s,setOpen:n,onOpen:l,onClose:t,onToggle:u}),[s,l,t,u])}
@@ -0,0 +1,23 @@
1
+ import * as React from 'react';
2
+ /** A box, in CSS pixels. `0` × `0` before the first measurement and on a server. */
3
+ export interface ElementSize {
4
+ width: number;
5
+ height: number;
6
+ }
7
+ /**
8
+ * One element's size, kept up to date.
9
+ *
10
+ * The same shared `ResizeObserver` eleven components in the library measure
11
+ * themselves with — one observer for the whole page rather than one per
12
+ * subscriber, because a dashboard of eight charts inside a PageLayout with a
13
+ * Panes in it was a dozen registrations the browser walked on every layout.
14
+ *
15
+ * The ref goes on the element to watch. It measures once as soon as that
16
+ * element is there rather than waiting to be told, because a `ResizeObserver`
17
+ * that is missing — an old browser, a server — never says anything at all, and
18
+ * a component sized `0 × 0` forever is worse than one measured once.
19
+ */
20
+ export declare function useElementSize<E extends Element = HTMLElement>(): [
21
+ React.RefObject<E | null>,
22
+ ElementSize
23
+ ];
@@ -0,0 +1 @@
1
+ "use client";import*as t from"react";import{observeResize as e}from"../internal/observe.js";export function useElementSize(){const i=t.useRef(null),[n,r]=t.useState({width:0,height:0});return t.useLayoutEffect(()=>{const t=i.current;if(!t)return;const n=()=>{const e=t.getBoundingClientRect();r(t=>t.width===e.width&&t.height===e.height?t:{width:e.width,height:e.height})};return n(),e(t,n)},[]),[i,n]}
@@ -0,0 +1,61 @@
1
+ import type { NebaBreakpoint, NebaResponsive } from '../types.js';
2
+ /**
3
+ * One media query, as a boolean this component re-renders on.
4
+ *
5
+ * The same store the library's own layout runs on, which is the reason it is
6
+ * offered rather than left to be written again: a `MediaQueryList` is live, so
7
+ * there is exactly one per query string for the whole page no matter how many
8
+ * components ask. Written the obvious way — `window.matchMedia` inside a
9
+ * `getSnapshot` — every subscriber builds a fresh one on every render *and*
10
+ * every commit, and a PageLayout with a Header, a Footer and two Sidebars in it
11
+ * asks the same question five times per render.
12
+ *
13
+ * It answers `false` on a server, where there is no window and no honest answer.
14
+ * A layout that must not flash is a layout stated in CSS; this is for the
15
+ * decisions CSS cannot make — which component to render at all.
16
+ */
17
+ export declare function useMediaQuery(query: string): boolean;
18
+ /**
19
+ * The same question in the units the rest of the library uses: is the window at
20
+ * least this wide?
21
+ *
22
+ * `useBreakpoint('md')` is `md:` in a class name, in JavaScript — the widths are
23
+ * one table, so a component that branches here and a utility that branches in
24
+ * CSS change at the same pixel. `xs` is `0rem` and therefore always true, which
25
+ * is the value with no media query around it.
26
+ */
27
+ export declare function useBreakpoint(breakpoint: NebaBreakpoint): boolean;
28
+ /**
29
+ * Which breakpoint the window is currently in — the widest whose floor it has
30
+ * reached.
31
+ *
32
+ * Four subscriptions and not five: `xs` is a floor of zero, so it is where the
33
+ * window is when none of the others match, and there is no query to ask. They
34
+ * are four separate calls rather than a loop because they are hooks; the count
35
+ * is fixed, which is what makes that legal, and each one costs nothing extra —
36
+ * a `MediaQueryList` is shared per query string for the whole page.
37
+ *
38
+ * `xs` on a server, which is the same answer the stylesheet gives before any
39
+ * media query has had a chance to apply.
40
+ */
41
+ export declare function useCurrentBreakpoint(): NebaBreakpoint;
42
+ /**
43
+ * A responsive prop's own shape, resolved in JavaScript.
44
+ *
45
+ * `useBreakpointValue({ xs: 1, md: 3 })` is `1` under 48rem and `3` from there
46
+ * up, reading the map exactly as the CSS cascade behind `span` and `spacing`
47
+ * reads it: every entry is a floor, so the nearest one at or below the current
48
+ * width wins. That sameness is the point — a component's responsive props and
49
+ * the numbers a caller works out for themselves should not need two mental
50
+ * models, or two ideas of what `{ md: 6 }` says about a phone.
51
+ *
52
+ * A bare value is returned unchanged, and `undefined` means the map has not
53
+ * said anything yet at this width: `{ lg: 4 }` on a phone is the caller
54
+ * declining to have an opinion there, not a failure. Pair it with `??` for a
55
+ * default.
56
+ *
57
+ * It re-renders on a resize, which the CSS form does not — so reach for it when
58
+ * the value is one JavaScript has to see (how many items to fetch, what to pass
59
+ * a chart), and leave layout to the props that resolve in the stylesheet.
60
+ */
61
+ export declare function useBreakpointValue<T>(value: NebaResponsive<T> | undefined): T | undefined;
@@ -0,0 +1 @@
1
+ "use client";import{useMediaQuery as e,widthAtLeast as r}from"../internal/media.js";import{valueAt as n}from"../internal/responsive.js";export function useMediaQuery(r){return e(r)}export function useBreakpoint(n){return e(r(n))}export function useCurrentBreakpoint(){const n=e(r("sm")),t=e(r("md")),u=e(r("lg"));return e(r("xl"))?"xl":u?"lg":t?"md":n?"sm":"xs"}export function useBreakpointValue(e){return n(e,useCurrentBreakpoint())}
@@ -0,0 +1,24 @@
1
+ import * as React from 'react';
2
+ export interface OnScreenOptions {
3
+ /** How much of the element has to be showing. @default 0 */
4
+ threshold?: number;
5
+ /**
6
+ * Stop watching once it has been seen. The right default for the thing this
7
+ * is usually for — mounting something, starting something, loading
8
+ * something — where the answer only has to arrive once.
9
+ * @default true
10
+ */
11
+ once?: boolean;
12
+ }
13
+ /**
14
+ * Whether an element is on screen.
15
+ *
16
+ * The same shared `IntersectionObserver` the eleven `Animate*` wrappers watch
17
+ * for their own element with — one per threshold for the whole page, because a
18
+ * page of them was one registration each.
19
+ *
20
+ * It answers `true` where there is no `IntersectionObserver` rather than
21
+ * `false`, and that is the load-bearing part: a caller cannot know without one,
22
+ * and the right fallback is to show the thing rather than to hide it forever.
23
+ */
24
+ export declare function useOnScreen<E extends Element = HTMLElement>(options?: OnScreenOptions): [React.RefObject<E | null>, boolean];
@@ -0,0 +1 @@
1
+ "use client";import*as e from"react";import{observeVisibility as r}from"../internal/observe.js";export function useOnScreen(t={}){const{threshold:n=0,once:o=!0}=t,s=e.useRef(null),[u,c]=e.useState(!1);return e.useEffect(()=>{const e=s.current;if(!e)return;const t=r(e,n,e=>{c(e),e&&o&&t?.()});if(t)return t;c(!0)},[n,o]),[s,u]}
@@ -0,0 +1,34 @@
1
+ export interface ShortcutOptions {
2
+ /** Stop listening without unmounting — a modal is open, a field has focus. @default true */
3
+ enabled?: boolean;
4
+ /**
5
+ * Ignore the key while the reader is typing into an input, a textarea or
6
+ * anything `contenteditable`.
7
+ *
8
+ * On by default, and it is the reason a bare `/` or `?` can be bound at all:
9
+ * a page-wide single-letter shortcut that fires inside a search box is a
10
+ * shortcut that eats what somebody was writing. A combination with a modifier
11
+ * is usually meant to work everywhere, so turn this off for those.
12
+ * @default true
13
+ */
14
+ ignoreWhileTyping?: boolean;
15
+ /**
16
+ * Call `preventDefault` when it matches — for a key the browser also has an
17
+ * opinion about, like `Mod+K` or `Mod+S`. @default true
18
+ */
19
+ preventDefault?: boolean;
20
+ }
21
+ /**
22
+ * A key combination bound on the window, spelled the way
23
+ * [Shortcut](../components/shortcut) draws it — `'Mod+K'`, `'Mod+Shift+P'`,
24
+ * `'?'`.
25
+ *
26
+ * This is what `CommandPalette` binds its own opener with, offered because an
27
+ * application has more shortcuts than the library does and every one of them
28
+ * should be spelled the way its key cap is. `Mod` is Command on a Mac and
29
+ * Control everywhere else; the modifiers are matched exactly.
30
+ *
31
+ * The handler is held in a ref, so a listener is bound once per combination
32
+ * rather than re-bound on every render that closes over new state.
33
+ */
34
+ export declare function useShortcut(shortcut: string | false, handler: (event: KeyboardEvent) => void, options?: ShortcutOptions): void;
@@ -0,0 +1 @@
1
+ "use client";import*as e from"react";import{matchesShortcut as t}from"../internal/keys.js";export function useShortcut(n,r,a={}){const{enabled:o=!0,ignoreWhileTyping:i=!0,preventDefault:s=!0}=a,u=e.useRef(r);e.useEffect(()=>{u.current=r}),e.useEffect(()=>{if(!1===n||!o)return;const e=e=>{var r;i&&(r=e.target,r instanceof HTMLElement&&(r.isContentEditable||"INPUT"===r.tagName||"TEXTAREA"===r.tagName||"SELECT"===r.tagName))||t(e,n)&&(s&&e.preventDefault(),u.current(e))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[n,o,i,s])}
package/dist/index.d.ts CHANGED
@@ -1,23 +1,29 @@
1
1
  export * from './types.js';
2
+ export * from './hooks/index.js';
2
3
  export * from './components/accordion/index.js';
3
4
  export * from './components/alert/index.js';
4
5
  export * from './components/anchor/index.js';
5
6
  export * from './components/animate-appear/index.js';
6
7
  export * from './components/app-logo/index.js';
7
8
  export * from './components/animate-blink/index.js';
9
+ export * from './components/animate-counter/index.js';
8
10
  export * from './components/animate-fade/index.js';
11
+ export * from './components/animate-float/index.js';
9
12
  export * from './components/animate-grow/index.js';
10
13
  export * from './components/animate-headline/index.js';
11
14
  export * from './components/animate-lighting/index.js';
12
15
  export * from './components/animate-marquee/index.js';
16
+ export * from './components/animate-reveal/index.js';
13
17
  export * from './components/animate-rotate/index.js';
18
+ export * from './components/animate-scramble/index.js';
19
+ export * from './components/animate-shake/index.js';
20
+ export * from './components/animate-split/index.js';
14
21
  export * from './components/animate-slide/index.js';
15
22
  export * from './components/animate-typing/index.js';
16
23
  export * from './components/animate-zoom/index.js';
17
24
  export * from './components/area-chart/index.js';
18
25
  export * from './components/aspect-ratio/index.js';
19
26
  export * from './components/avatar/index.js';
20
- export * from './components/avatar-group/index.js';
21
27
  export * from './components/badge/index.js';
22
28
  export * from './components/bar-chart/index.js';
23
29
  export * from './components/blockquote/index.js';
@@ -26,6 +32,7 @@ export * from './components/box/index.js';
26
32
  export * from './components/breadcrumb/index.js';
27
33
  export * from './components/button/index.js';
28
34
  export * from './components/button-group/index.js';
35
+ export * from './components/calendar/index.js';
29
36
  export * from './components/card/index.js';
30
37
  export * from './components/carousel/index.js';
31
38
  export * from './components/chat-bubble/index.js';
@@ -36,6 +43,7 @@ export * from './components/collapsible/index.js';
36
43
  export * from './components/color-picker/index.js';
37
44
  export * from './components/combobox/index.js';
38
45
  export * from './components/command-palette/index.js';
46
+ export * from './components/confirm/index.js';
39
47
  export * from './components/container/index.js';
40
48
  export * from './components/data-list/index.js';
41
49
  export * from './components/data-table/index.js';
@@ -48,7 +56,9 @@ export * from './components/drawer/index.js';
48
56
  export * from './components/empty/index.js';
49
57
  export * from './components/fieldset/index.js';
50
58
  export * from './components/file-picker/index.js';
59
+ export * from './components/flex/index.js';
51
60
  export * from './components/form/index.js';
61
+ export * from './components/gallery/index.js';
52
62
  export * from './components/gauge-chart/index.js';
53
63
  export * from './components/grid/index.js';
54
64
  export * from './components/floating-action-button/index.js';
@@ -62,6 +72,7 @@ export * from './components/hover-card/index.js';
62
72
  export * from './components/how-to-steps/index.js';
63
73
  export * from './components/icon/index.js';
64
74
  export * from './components/icon-button/index.js';
75
+ export * from './components/image/index.js';
65
76
  export * from './components/line-chart/index.js';
66
77
  export * from './components/list/index.js';
67
78
  export * from './components/menu/index.js';
@@ -77,10 +88,13 @@ export * from './components/pagination/index.js';
77
88
  export * from './components/panes/index.js';
78
89
  export * from './components/pie-chart/index.js';
79
90
  export * from './components/pill/index.js';
91
+ export * from './components/popconfirm/index.js';
80
92
  export * from './components/popover/index.js';
93
+ export * from './components/portal/index.js';
81
94
  export * from './components/progress-box/index.js';
82
95
  export * from './components/progress-circular/index.js';
83
96
  export * from './components/progress-linear/index.js';
97
+ export * from './components/provider/index.js';
84
98
  export * from './components/radio-group/index.js';
85
99
  export * from './components/rating/index.js';
86
100
  export * from './components/scatter-chart/index.js';
@@ -89,11 +103,13 @@ export * from './components/scroll-zone/index.js';
89
103
  export * from './components/segmented-button/index.js';
90
104
  export * from './components/select/index.js';
91
105
  export * from './components/shortcut/index.js';
106
+ export * from './components/show/index.js';
92
107
  export * from './components/sidebar/index.js';
93
108
  export * from './components/skeleton/index.js';
94
109
  export * from './components/slider/index.js';
95
110
  export * from './components/sparkline/index.js';
96
111
  export * from './components/spoiler/index.js';
112
+ export * from './components/stack/index.js';
97
113
  export * from './components/statistic/index.js';
98
114
  export * from './components/switch/index.js';
99
115
  export * from './components/table/index.js';
@@ -110,6 +126,8 @@ export * from './components/toolbar/index.js';
110
126
  export * from './components/tooltip/index.js';
111
127
  export * from './components/tour/index.js';
112
128
  export * from './components/transfer/index.js';
129
+ export * from './components/tree-select/index.js';
113
130
  export * from './components/tree-view/index.js';
114
131
  export * from './components/typography/index.js';
132
+ export * from './components/visually-hidden/index.js';
115
133
  export * from './components/window-pane/index.js';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export*from"./types.js";export*from"./components/accordion/index.js";export*from"./components/alert/index.js";export*from"./components/anchor/index.js";export*from"./components/animate-appear/index.js";export*from"./components/app-logo/index.js";export*from"./components/animate-blink/index.js";export*from"./components/animate-fade/index.js";export*from"./components/animate-grow/index.js";export*from"./components/animate-headline/index.js";export*from"./components/animate-lighting/index.js";export*from"./components/animate-marquee/index.js";export*from"./components/animate-rotate/index.js";export*from"./components/animate-slide/index.js";export*from"./components/animate-typing/index.js";export*from"./components/animate-zoom/index.js";export*from"./components/area-chart/index.js";export*from"./components/aspect-ratio/index.js";export*from"./components/avatar/index.js";export*from"./components/avatar-group/index.js";export*from"./components/badge/index.js";export*from"./components/bar-chart/index.js";export*from"./components/blockquote/index.js";export*from"./components/bottom-navigation/index.js";export*from"./components/box/index.js";export*from"./components/breadcrumb/index.js";export*from"./components/button/index.js";export*from"./components/button-group/index.js";export*from"./components/card/index.js";export*from"./components/carousel/index.js";export*from"./components/chat-bubble/index.js";export*from"./components/checkbox/index.js";export*from"./components/chip/index.js";export*from"./components/code-block/index.js";export*from"./components/collapsible/index.js";export*from"./components/color-picker/index.js";export*from"./components/combobox/index.js";export*from"./components/command-palette/index.js";export*from"./components/container/index.js";export*from"./components/data-list/index.js";export*from"./components/data-table/index.js";export*from"./components/date-picker/index.js";export*from"./components/date-range-picker/index.js";export*from"./components/date-time-picker/index.js";export*from"./components/dialog/index.js";export*from"./components/divider/index.js";export*from"./components/drawer/index.js";export*from"./components/empty/index.js";export*from"./components/fieldset/index.js";export*from"./components/file-picker/index.js";export*from"./components/form/index.js";export*from"./components/gauge-chart/index.js";export*from"./components/grid/index.js";export*from"./components/floating-action-button/index.js";export*from"./components/floating-bottom-navigation/index.js";export*from"./components/footer/index.js";export*from"./components/grid-container/index.js";export*from"./components/header/index.js";export*from"./components/heatmap-chart/index.js";export*from"./components/highlight/index.js";export*from"./components/hover-card/index.js";export*from"./components/how-to-steps/index.js";export*from"./components/icon/index.js";export*from"./components/icon-button/index.js";export*from"./components/line-chart/index.js";export*from"./components/list/index.js";export*from"./components/menu/index.js";export*from"./components/menubar/index.js";export*from"./components/meter/index.js";export*from"./components/mockup/index.js";export*from"./components/navigation-menu/index.js";export*from"./components/number-field/index.js";export*from"./components/otp-field/index.js";export*from"./components/overlay/index.js";export*from"./components/page-layout/index.js";export*from"./components/pagination/index.js";export*from"./components/panes/index.js";export*from"./components/pie-chart/index.js";export*from"./components/pill/index.js";export*from"./components/popover/index.js";export*from"./components/progress-box/index.js";export*from"./components/progress-circular/index.js";export*from"./components/progress-linear/index.js";export*from"./components/radio-group/index.js";export*from"./components/rating/index.js";export*from"./components/scatter-chart/index.js";export*from"./components/scroll-area/index.js";export*from"./components/scroll-zone/index.js";export*from"./components/segmented-button/index.js";export*from"./components/select/index.js";export*from"./components/shortcut/index.js";export*from"./components/sidebar/index.js";export*from"./components/skeleton/index.js";export*from"./components/slider/index.js";export*from"./components/sparkline/index.js";export*from"./components/spoiler/index.js";export*from"./components/statistic/index.js";export*from"./components/switch/index.js";export*from"./components/table/index.js";export*from"./components/tabs/index.js";export*from"./components/text-field/index.js";export*from"./components/text-link/index.js";export*from"./components/time-picker/index.js";export*from"./components/timeline/index.js";export*from"./components/timeline-chart/index.js";export*from"./components/toast/index.js";export*from"./components/toggle/index.js";export*from"./components/toggle-group/index.js";export*from"./components/toolbar/index.js";export*from"./components/tooltip/index.js";export*from"./components/tour/index.js";export*from"./components/transfer/index.js";export*from"./components/tree-view/index.js";export*from"./components/typography/index.js";export*from"./components/window-pane/index.js";
1
+ export*from"./types.js";export*from"./hooks/index.js";export*from"./components/accordion/index.js";export*from"./components/alert/index.js";export*from"./components/anchor/index.js";export*from"./components/animate-appear/index.js";export*from"./components/app-logo/index.js";export*from"./components/animate-blink/index.js";export*from"./components/animate-counter/index.js";export*from"./components/animate-fade/index.js";export*from"./components/animate-float/index.js";export*from"./components/animate-grow/index.js";export*from"./components/animate-headline/index.js";export*from"./components/animate-lighting/index.js";export*from"./components/animate-marquee/index.js";export*from"./components/animate-reveal/index.js";export*from"./components/animate-rotate/index.js";export*from"./components/animate-scramble/index.js";export*from"./components/animate-shake/index.js";export*from"./components/animate-split/index.js";export*from"./components/animate-slide/index.js";export*from"./components/animate-typing/index.js";export*from"./components/animate-zoom/index.js";export*from"./components/area-chart/index.js";export*from"./components/aspect-ratio/index.js";export*from"./components/avatar/index.js";export*from"./components/badge/index.js";export*from"./components/bar-chart/index.js";export*from"./components/blockquote/index.js";export*from"./components/bottom-navigation/index.js";export*from"./components/box/index.js";export*from"./components/breadcrumb/index.js";export*from"./components/button/index.js";export*from"./components/button-group/index.js";export*from"./components/calendar/index.js";export*from"./components/card/index.js";export*from"./components/carousel/index.js";export*from"./components/chat-bubble/index.js";export*from"./components/checkbox/index.js";export*from"./components/chip/index.js";export*from"./components/code-block/index.js";export*from"./components/collapsible/index.js";export*from"./components/color-picker/index.js";export*from"./components/combobox/index.js";export*from"./components/command-palette/index.js";export*from"./components/confirm/index.js";export*from"./components/container/index.js";export*from"./components/data-list/index.js";export*from"./components/data-table/index.js";export*from"./components/date-picker/index.js";export*from"./components/date-range-picker/index.js";export*from"./components/date-time-picker/index.js";export*from"./components/dialog/index.js";export*from"./components/divider/index.js";export*from"./components/drawer/index.js";export*from"./components/empty/index.js";export*from"./components/fieldset/index.js";export*from"./components/file-picker/index.js";export*from"./components/flex/index.js";export*from"./components/form/index.js";export*from"./components/gallery/index.js";export*from"./components/gauge-chart/index.js";export*from"./components/grid/index.js";export*from"./components/floating-action-button/index.js";export*from"./components/floating-bottom-navigation/index.js";export*from"./components/footer/index.js";export*from"./components/grid-container/index.js";export*from"./components/header/index.js";export*from"./components/heatmap-chart/index.js";export*from"./components/highlight/index.js";export*from"./components/hover-card/index.js";export*from"./components/how-to-steps/index.js";export*from"./components/icon/index.js";export*from"./components/icon-button/index.js";export*from"./components/image/index.js";export*from"./components/line-chart/index.js";export*from"./components/list/index.js";export*from"./components/menu/index.js";export*from"./components/menubar/index.js";export*from"./components/meter/index.js";export*from"./components/mockup/index.js";export*from"./components/navigation-menu/index.js";export*from"./components/number-field/index.js";export*from"./components/otp-field/index.js";export*from"./components/overlay/index.js";export*from"./components/page-layout/index.js";export*from"./components/pagination/index.js";export*from"./components/panes/index.js";export*from"./components/pie-chart/index.js";export*from"./components/pill/index.js";export*from"./components/popconfirm/index.js";export*from"./components/popover/index.js";export*from"./components/portal/index.js";export*from"./components/progress-box/index.js";export*from"./components/progress-circular/index.js";export*from"./components/progress-linear/index.js";export*from"./components/provider/index.js";export*from"./components/radio-group/index.js";export*from"./components/rating/index.js";export*from"./components/scatter-chart/index.js";export*from"./components/scroll-area/index.js";export*from"./components/scroll-zone/index.js";export*from"./components/segmented-button/index.js";export*from"./components/select/index.js";export*from"./components/shortcut/index.js";export*from"./components/show/index.js";export*from"./components/sidebar/index.js";export*from"./components/skeleton/index.js";export*from"./components/slider/index.js";export*from"./components/sparkline/index.js";export*from"./components/spoiler/index.js";export*from"./components/stack/index.js";export*from"./components/statistic/index.js";export*from"./components/switch/index.js";export*from"./components/table/index.js";export*from"./components/tabs/index.js";export*from"./components/text-field/index.js";export*from"./components/text-link/index.js";export*from"./components/time-picker/index.js";export*from"./components/timeline/index.js";export*from"./components/timeline-chart/index.js";export*from"./components/toast/index.js";export*from"./components/toggle/index.js";export*from"./components/toggle-group/index.js";export*from"./components/toolbar/index.js";export*from"./components/tooltip/index.js";export*from"./components/tour/index.js";export*from"./components/transfer/index.js";export*from"./components/tree-select/index.js";export*from"./components/tree-view/index.js";export*from"./components/typography/index.js";export*from"./components/visually-hidden/index.js";export*from"./components/window-pane/index.js";
@@ -28,7 +28,7 @@
28
28
  * components, and their logic stays in their own files.
29
29
  */
30
30
  import * as React from 'react';
31
- import type { NebaAnimateRepeat, NebaAnimateTrigger, NebaAnimation, NebaSide, NebaTransition } from '../types.js';
31
+ import type { NebaAnimateRepeat, NebaAnimateTimeline, NebaAnimateTrigger, NebaAnimation, NebaSide, NebaTransition } from '../types.js';
32
32
  /**
33
33
  * Which keyframe an effect runs.
34
34
  *
@@ -49,6 +49,8 @@ export declare const animBaseClass = "neba-anim";
49
49
  * an arrival, so its number is a period.
50
50
  */
51
51
  export declare const defaultDurations: Record<NebaAnimation, number>;
52
+ /** Where a `reveal` is clipped to before its edge travels across. */
53
+ export declare function revealClip(side: NebaSide): string;
52
54
  /** A number is pixels; a string is already a CSS length. */
53
55
  export declare function lengthValue(value: number | string): string;
54
56
  export declare function isInfinite(repeat: NebaAnimateRepeat | undefined): boolean;
@@ -66,6 +68,11 @@ export interface AnimationSlotOptions {
66
68
  y?: string;
67
69
  angle?: string;
68
70
  angleTo?: string;
71
+ clip?: string;
72
+ /** `view` points the effect at a scroll timeline instead of the clock. */
73
+ timeline?: NebaAnimateTimeline;
74
+ /** The `animation-range` a `view` timeline is mapped over. */
75
+ range?: string;
69
76
  }
70
77
  /**
71
78
  * The `--n-anim-*` slots, as an inline style object.
@@ -86,6 +93,30 @@ export declare function slideOffsets(from: NebaSide, distance: number | string):
86
93
  x: string;
87
94
  y: string;
88
95
  };
96
+ export interface StaggerOptions {
97
+ /** Milliseconds of delay added per child. */
98
+ stagger: number;
99
+ /** Milliseconds of duration added per child. Negative speeds them up. */
100
+ durationStep: number;
101
+ /** Runs the list last-to-first. Only the order reverses. */
102
+ reverse: boolean;
103
+ }
104
+ /** Whether these options ask for anything the root cannot do on its own. */
105
+ export declare function staggers({ stagger, durationStep }: StaggerOptions): boolean;
106
+ /**
107
+ * The same effect on each child, held back by its position.
108
+ *
109
+ * The animation is written onto the children **themselves** rather than onto
110
+ * wrappers around them. A row of `<li>`s stays a row of `<li>`s, a grid's cells
111
+ * stay its direct children, and nothing about the layout changes because the
112
+ * list is being animated. Only a bare string has no element to write onto, so
113
+ * that one gets a `<span>`.
114
+ *
115
+ * The step is per *child*, which means what is passed matters: eight children
116
+ * are eight steps, and one child holding eight things is one step. That is also
117
+ * how to opt part of a list out — group it.
118
+ */
119
+ export declare function staggerChildren(children: React.ReactNode, effectClass: string, slots: AnimationSlotOptions, { stagger, durationStep, reverse }: StaggerOptions): React.ReactNode[];
89
120
  /**
90
121
  * What a component's `transition` prop turns into: one class pair and a handful
91
122
  * of custom properties, merged into whatever the component was already writing.
@@ -99,6 +130,19 @@ export declare function transitionProps(transition: NebaTransition | undefined):
99
130
  className: string;
100
131
  style: React.CSSProperties;
101
132
  };
133
+ /**
134
+ * The same reading, one step before it becomes a class and a style object.
135
+ *
136
+ * A component that draws its children into boxes of its own — Stack — needs the
137
+ * *options* rather than the finished style, because it has a step per child to
138
+ * add to the delay before the slots are filled. Splitting it here is what keeps
139
+ * one table: `transition="fade"` on a Card and on a Stack item are the same
140
+ * fade, read by the same code.
141
+ */
142
+ export declare function transitionParts(transition: NebaTransition | undefined): {
143
+ effect: NebaAnimation;
144
+ slots: AnimationSlotOptions;
145
+ } | null;
102
146
  /**
103
147
  * Whether the reader has asked for less motion — the hook the three effects
104
148
  * with motion written in JavaScript read. It lives in `media.ts` beside the
@@ -146,8 +190,25 @@ export interface AnimationRun {
146
190
  */
147
191
  export declare function useAnimationRun({ trigger, play, once, threshold, paused, infinite }: AnimationRunOptions): AnimationRun;
148
192
  export interface AnimateElementParams extends AnimationSlotOptions, AnimationRunOptions {
149
- /** Which keyframe. `null` for the components that write their own. */
193
+ /** Which keyframe, out of the shared table. `null` to bring your own. */
150
194
  effect: NebaAnimation | null;
195
+ /**
196
+ * A keyframe class of this component's own, for an effect that is not in the
197
+ * `transition` vocabulary — `AnimateFloat` and `AnimateShake`. Everything else
198
+ * about them is the same machinery, `stagger` included, which is the whole
199
+ * reason this is a parameter rather than a second hook.
200
+ */
201
+ effectClass?: string;
202
+ /** What `data-neba-animation` says. Defaults to `effect`. */
203
+ name?: string;
204
+ /**
205
+ * What is inside. Only read to hand each child an effect of its own — pass it
206
+ * and render `children` back, or leave it out and render your own.
207
+ */
208
+ children?: React.ReactNode;
209
+ stagger?: number;
210
+ durationStep?: number;
211
+ reverse?: boolean;
151
212
  }
152
213
  export interface AnimateElement {
153
214
  ref: React.RefCallback<HTMLElement>;
@@ -155,6 +216,8 @@ export interface AnimateElement {
155
216
  style: React.CSSProperties;
156
217
  /** The hover handlers and the two data attributes, ready to be spread. */
157
218
  props: React.HTMLAttributes<HTMLElement> & Record<string, unknown>;
219
+ /** The children as given, or one animation each once a step is asked for. */
220
+ children: React.ReactNode;
158
221
  }
159
222
  /**
160
223
  * Everything an `Animate*` root needs, in one call.
@@ -1 +1 @@
1
- "use client";import*as e from"react";import{observeVisibility as n}from"./observe.js";export const animationClasses={fade:"neba-anim-fade",grow:"neba-anim-scale",slide:"neba-anim-slide",zoom:"neba-anim-scale",rotate:"neba-anim-rotate",blink:"neba-anim-blink"};export const animBaseClass="neba-anim";export const defaultDurations={fade:320,grow:340,slide:380,zoom:340,rotate:460,blink:900};export function lengthValue(e){return"number"==typeof e?`${e}px`:e}export function isInfinite(e){return"infinite"===e}export function animationSlots(e){const n={"--n-anim-duration":`${e.duration}ms`,"--n-anim-delay":`${e.delay}ms`,"--n-anim-repeat":(i=e.repeat,"infinite"===i?"infinite":String(i)),"--n-anim-direction":(t=e.mode??"in",a=e.alternate,"out"===t?a?"alternate-reverse":"reverse":a?"alternate":"normal")};var t,a,i;return e.easing&&(n["--n-anim-ease"]=e.easing),void 0!==e.opacity&&(n["--n-anim-opacity"]=String(e.opacity)),void 0!==e.scale&&(n["--n-anim-scale"]=String(e.scale)),void 0!==e.x&&(n["--n-anim-x"]=e.x),void 0!==e.y&&(n["--n-anim-y"]=e.y),void 0!==e.angle&&(n["--n-anim-angle"]=e.angle),void 0!==e.angleTo&&(n["--n-anim-angle-to"]=e.angleTo),n}export function slideOffsets(e,n){const t=lengthValue(n),a="number"==typeof n?-n+"px":`calc(-1 * ${t})`;switch(e){case"top":return{x:"0px",y:a};case"bottom":return{x:"0px",y:t};case"left":return{x:a,y:"0px"};default:return{x:t,y:"0px"}}}export function transitionProps(e){if(!e)return{className:"",style:{}};const n="string"==typeof e?{type:e}:e,{type:t}=n,a={duration:n.duration??defaultDurations[t],delay:n.delay??0,easing:n.easing,repeat:n.repeat??("blink"===t?"infinite":1),alternate:n.alternate};if("grow"!==t&&"zoom"!==t||(a.scale=n.scale??("zoom"===t?.4:.8)),"slide"===t){const{x:e,y:t}=slideOffsets(n.from??"bottom",n.distance??"100%");a.x=e,a.y=t}return"rotate"===t&&(a.angle=`${n.angle??-180}deg`),{className:`neba-anim ${animationClasses[t]}`,style:animationSlots(a)}}export{usePrefersReducedMotion}from"./media.js";export function useAnimationRun({trigger:t,play:a,once:i,threshold:o,paused:r,infinite:s}){const l=e.useRef(null),[u,m]=e.useState("mount"===t),[c,f]=e.useState(0),d=e.useCallback(()=>{m(!0),f(e=>e+1)},[]);e.useLayoutEffect(()=>{const e=l.current;if(!e||0===c)return;const n=[e,...e.querySelectorAll(".neba-anim, .neba-marquee-track")];for(const e of n)e.style.animationName="none";e.offsetWidth;for(const e of n)e.style.animationName=""},[c]),e.useEffect(()=>{if("visible"!==t)return;const e=l.current;if(!e)return;let a=null;if(a=n(e,o,e=>{e?(d(),i&&(a?.(),a=null)):i||m(!1)}),a)return()=>a?.();m(!0)},[t,i,o,d]),e.useEffect(()=>{"manual"===t&&(a?d():m(!1))},[t,a,d]);const p="hover"===t?{onPointerEnter:d,onFocus:d,onPointerLeave:()=>{s&&m(!1)},onBlur:()=>{s&&m(!1)}}:{};return{ref:e.useCallback(e=>{l.current=e},[]),state:u&&!r?"running":"paused",started:u,handlers:p}}export function useAnimateElement(e){const{effect:n,trigger:t,play:a,once:i,threshold:o,paused:r,infinite:s,...l}=e,u=useAnimationRun({trigger:t,play:a,once:i,threshold:o,paused:r,infinite:s});return{ref:u.ref,className:n?`neba-anim ${animationClasses[n]}`:"",style:{...animationSlots(l),"--n-anim-state":u.state},props:{...u.handlers,"data-neba-animation":n??void 0,"data-state":u.state}}}
1
+ "use client";import{jsx as e}from"react/jsx-runtime";import*as n from"react";import{observeVisibility as t}from"./observe.js";import{cx as a}from"./styles.js";export const animationClasses={fade:"neba-anim-fade",grow:"neba-anim-scale",slide:"neba-anim-slide",zoom:"neba-anim-scale",rotate:"neba-anim-rotate",blink:"neba-anim-blink",reveal:"neba-anim-reveal"};export const animBaseClass="neba-anim";export const defaultDurations={fade:320,grow:340,slide:380,zoom:340,rotate:460,blink:900,reveal:620};export function revealClip(e){switch(e){case"top":return"inset(0 0 100% 0)";case"bottom":return"inset(100% 0 0 0)";case"right":return"inset(0 0 0 100%)";default:return"inset(0 100% 0 0)"}}export function lengthValue(e){return"number"==typeof e?`${e}px`:e}export function isInfinite(e){return"infinite"===e}export function animationSlots(e){const n={"--n-anim-duration":`${e.duration}ms`,"--n-anim-delay":`${e.delay}ms`,"--n-anim-repeat":(r=e.repeat,"infinite"===r?"infinite":String(r)),"--n-anim-direction":(t=e.mode??"in",a=e.alternate,"out"===t?a?"alternate-reverse":"reverse":a?"alternate":"normal")};var t,a,r;return e.easing&&(n["--n-anim-ease"]=e.easing),void 0!==e.opacity&&(n["--n-anim-opacity"]=String(e.opacity)),void 0!==e.scale&&(n["--n-anim-scale"]=String(e.scale)),void 0!==e.x&&(n["--n-anim-x"]=e.x),void 0!==e.y&&(n["--n-anim-y"]=e.y),void 0!==e.angle&&(n["--n-anim-angle"]=e.angle),void 0!==e.angleTo&&(n["--n-anim-angle-to"]=e.angleTo),void 0!==e.clip&&(n["--n-anim-clip"]=e.clip),"view"===e.timeline&&(n["--n-anim-timeline"]="view()",n["--n-anim-range"]=e.range??"entry 0% cover 45%"),n}export function slideOffsets(e,n){const t=lengthValue(n),a="number"==typeof n?-n+"px":`calc(-1 * ${t})`;switch(e){case"top":return{x:"0px",y:a};case"bottom":return{x:"0px",y:t};case"left":return{x:a,y:"0px"};default:return{x:t,y:"0px"}}}export function staggers({stagger:e,durationStep:n}){return 0!==e||0!==n}export function staggerChildren(t,r,i,{stagger:s,durationStep:o,reverse:l}){const u=n.Children.toArray(t);return u.map((t,c)=>{const m=l?u.length-1-c:c,f=animationSlots({...i,delay:i.delay+m*s,duration:Math.max(0,i.duration+m*o)});if(!n.isValidElement(t))return e("span",{className:r,style:f,children:t},c);const d=t.props;return n.cloneElement(t,{className:a(r,d.className),style:{...f,...d.style}})})}export function transitionProps(e){const n=transitionParts(e);return n?{className:`neba-anim ${animationClasses[n.effect]}`,style:animationSlots(n.slots)}:{className:"",style:{}}}export function transitionParts(e){if(!e)return null;const n="string"==typeof e?{type:e}:e,{type:t}=n,a={duration:n.duration??defaultDurations[t],delay:n.delay??0,easing:n.easing,repeat:n.repeat??("blink"===t?"infinite":1),alternate:n.alternate,timeline:n.timeline,range:n.range};if("grow"!==t&&"zoom"!==t||(a.scale=n.scale??("zoom"===t?.4:.8)),"slide"===t){const{x:e,y:t}=slideOffsets(n.from??"bottom",n.distance??"100%");a.x=e,a.y=t}return"rotate"===t&&(a.angle=`${n.angle??-180}deg`),"reveal"===t&&(a.clip=revealClip(n.side??"left")),{effect:t,slots:a}}export{usePrefersReducedMotion}from"./media.js";export function useAnimationRun({trigger:e,play:a,once:r,threshold:i,paused:s,infinite:o}){const l=n.useRef(null),[u,c]=n.useState("mount"===e),[m,f]=n.useState(0),d=n.useCallback(()=>{c(!0),f(e=>e+1)},[]);n.useLayoutEffect(()=>{const e=l.current;if(!e||0===m)return;const n=[e,...e.querySelectorAll(".neba-anim, .neba-marquee-track")];for(const e of n)e.style.animationName="none";e.offsetWidth;for(const e of n)e.style.animationName=""},[m]),n.useEffect(()=>{if("visible"!==e)return;const n=l.current;if(!n)return;let a=null;if(a=t(n,i,e=>{e?(d(),r&&(a?.(),a=null)):r||c(!1)}),a)return()=>a?.();c(!0)},[e,r,i,d]),n.useEffect(()=>{"manual"===e&&(a?d():c(!1))},[e,a,d]);const p="hover"===e?{onPointerEnter:d,onFocus:d,onPointerLeave:()=>{o&&c(!1)},onBlur:()=>{o&&c(!1)}}:{};return{ref:n.useCallback(e=>{l.current=e},[]),state:u&&!s?"running":"paused",started:u,handlers:p}}export function useAnimateElement(e){const{effect:n,trigger:t,play:a,once:r,threshold:i,paused:s,infinite:o,children:l,stagger:u=0,durationStep:c=0,reverse:m=!1,effectClass:f,name:d,...p}=e,g=useAnimationRun({trigger:t,play:a,once:r,threshold:i,paused:s,infinite:o}),y=n?animationClasses[n]:f,x=y?`neba-anim ${y}`:"",v=""!==x&&staggers({stagger:u,durationStep:c,reverse:m}),b="view"===p.timeline?"running":g.state;return{ref:g.ref,className:v?"":x,style:v?{"--n-anim-state":b}:{...animationSlots(p),"--n-anim-state":b},props:{...g.handlers,"data-neba-animation":d??n??void 0,"data-state":b},children:v?staggerChildren(l,x,p,{stagger:u,durationStep:c,reverse:m}):l}}
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { type TimeUnit } from './date.js';
3
- import type { NebaColor, NebaDensity, NebaSize, NebaWeekday } from '../types.js';
3
+ import type { NebaColor, NebaDateGranularity, NebaDensity, NebaSize, NebaWeekday } from '../types.js';
4
4
  /**
5
5
  * The calendar grid and the clock columns, written once for the four pickers.
6
6
  *
@@ -20,9 +20,9 @@ import type { NebaColor, NebaDensity, NebaSize, NebaWeekday } from '../types.js'
20
20
  /**
21
21
  * Every string a picker says that is not a date.
22
22
  *
23
- * One object rather than eighteen props. These are a set: a caller who has to
23
+ * One object rather than twenty props. These are a set: a caller who has to
24
24
  * translate "Previous month" has to translate "Next month" in the same breath,
25
- * and a component with eighteen `*Label` props is a component whose signature is
25
+ * and a component with twenty `*Label` props is a component whose signature is
26
26
  * mostly apology. The dates themselves are never in here — those come from
27
27
  * `Intl`, which already knows what July is called in more languages than this
28
28
  * file ever will.
@@ -40,8 +40,14 @@ export interface PickerLabels {
40
40
  /** The two header buttons that open the month grid and the year grid. */
41
41
  chooseMonth: string;
42
42
  chooseYear: string;
43
- /** The footer's actions. */
43
+ /**
44
+ * The footer's actions. Three shortcuts rather than one because the button
45
+ * jumps to the current *unit*, and a month picker whose footer says "Today"
46
+ * is offering a day it has no way to accept.
47
+ */
44
48
  today: string;
49
+ thisMonth: string;
50
+ thisYear: string;
45
51
  now: string;
46
52
  clear: string;
47
53
  done: string;
@@ -71,6 +77,12 @@ export interface CalendarProps {
71
77
  rangeStart?: Date | null;
72
78
  rangeEnd?: Date | null;
73
79
  onSelect: (date: Date) => void;
80
+ /**
81
+ * Which grid the reader is allowed to stop on, and therefore what `onSelect`
82
+ * hands back: a day, the 1st of a month, or the 1st of January.
83
+ * @default 'day'
84
+ */
85
+ granularity?: NebaDateGranularity;
74
86
  /** The day under the pointer, for a range that is only half chosen. */
75
87
  onPreviewChange?: (date: Date | null) => void;
76
88
  minDate?: Date | null;
@@ -88,6 +100,14 @@ export interface CalendarProps {
88
100
  * @default true
89
101
  */
90
102
  showOutsideDays?: boolean;
103
+ /**
104
+ * What a day cell draws under its number — a dot, a count, a bar.
105
+ *
106
+ * A hook rather than a slot: the caller is the only one who knows what a day
107
+ * *has* on it, and the alternative is an `events` prop that would make this
108
+ * file responsible for a data shape it has no opinion about.
109
+ */
110
+ renderDay?: (date: Date) => React.ReactNode;
91
111
  /** Takes the focus on mount — the popup has just opened. */
92
112
  autoFocus?: boolean;
93
113
  showPreviousButton?: boolean;
@@ -104,13 +124,19 @@ export interface CalendarProps {
104
124
  * two stretch four rows and three rows across that same height — so switching
105
125
  * view never resizes the popup under the pointer that opened it.
106
126
  *
127
+ * `granularity` says which of the three the reader may stop on. At `day` the
128
+ * other two are only a way of reaching it; at `month` or `year` the grid that
129
+ * names that unit is where the calendar opens and where a click becomes an
130
+ * answer. Climbing is unaffected — a month picker still reaches 2019 through
131
+ * the year grid — so the coarser settings take a view away and add none.
132
+ *
107
133
  * Arrow keys move by one cell, `PageUp`/`PageDown` by a month (a year with
108
134
  * Shift), `Home`/`End` to the ends of the week, and running off an edge steps
109
135
  * the calendar rather than stopping. One roving tab stop, so `Tab` leaves the
110
136
  * grid instead of walking forty-two cells — the pattern the ARIA date-picker
111
137
  * practice describes, and the reason none of the cells is a `disabled` button.
112
138
  */
113
- export declare function Calendar({ size, color, locale, weekStartsOn, month, onMonthChange, selected, rangeStart, rangeEnd, onSelect, onPreviewChange, minDate, maxDate, shouldDisableDate, showOutsideDays, autoFocus, showPreviousButton, showNextButton, labels, className }: CalendarProps): React.JSX.Element;
139
+ export declare function Calendar({ size, color, locale, weekStartsOn, month, onMonthChange, selected, rangeStart, rangeEnd, onSelect, granularity, renderDay, onPreviewChange, minDate, maxDate, shouldDisableDate, showOutsideDays, autoFocus, showPreviousButton, showNextButton, labels, className }: CalendarProps): React.JSX.Element;
114
140
  export type { TimeUnit };
115
141
  export interface TimeGridProps {
116
142
  size: NebaSize;