neba 1.8.0 → 1.9.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 (222) hide show
  1. package/README.md +13 -7
  2. package/dist/components/accordion/Accordion.js +1 -1
  3. package/dist/components/alert/Alert.js +1 -1
  4. package/dist/components/anchor/Anchor.d.ts +73 -0
  5. package/dist/components/anchor/Anchor.js +1 -0
  6. package/dist/components/anchor/index.d.ts +2 -0
  7. package/dist/components/anchor/index.js +1 -0
  8. package/dist/components/animate-appear/AnimateAppear.js +1 -1
  9. package/dist/components/animate-blink/AnimateBlink.js +1 -1
  10. package/dist/components/animate-fade/AnimateFade.js +1 -1
  11. package/dist/components/animate-grow/AnimateGrow.js +1 -1
  12. package/dist/components/animate-headline/AnimateHeadline.js +1 -1
  13. package/dist/components/animate-lighting/AnimateLighting.js +1 -1
  14. package/dist/components/animate-marquee/AnimateMarquee.js +1 -1
  15. package/dist/components/animate-rotate/AnimateRotate.js +1 -1
  16. package/dist/components/animate-slide/AnimateSlide.js +1 -1
  17. package/dist/components/animate-typing/AnimateTyping.js +1 -1
  18. package/dist/components/animate-zoom/AnimateZoom.js +1 -1
  19. package/dist/components/app-logo/AppLogo.js +1 -1
  20. package/dist/components/area-chart/AreaChart.js +1 -1
  21. package/dist/components/aspect-ratio/AspectRatio.js +1 -1
  22. package/dist/components/avatar/Avatar.js +1 -1
  23. package/dist/components/avatar-group/AvatarGroup.d.ts +47 -0
  24. package/dist/components/avatar-group/AvatarGroup.js +1 -0
  25. package/dist/components/avatar-group/index.d.ts +2 -0
  26. package/dist/components/avatar-group/index.js +1 -0
  27. package/dist/components/badge/Badge.js +1 -1
  28. package/dist/components/bar-chart/BarChart.js +1 -1
  29. package/dist/components/blockquote/Blockquote.js +1 -1
  30. package/dist/components/bottom-navigation/BottomNavigation.js +1 -1
  31. package/dist/components/box/Box.js +1 -1
  32. package/dist/components/breadcrumb/Breadcrumb.js +1 -1
  33. package/dist/components/button/Button.js +1 -1
  34. package/dist/components/button-group/ButtonGroup.js +1 -1
  35. package/dist/components/card/Card.js +1 -1
  36. package/dist/components/carousel/Carousel.js +1 -1
  37. package/dist/components/chat-bubble/ChatBubble.js +1 -1
  38. package/dist/components/checkbox/Checkbox.js +1 -1
  39. package/dist/components/chip/Chip.js +1 -1
  40. package/dist/components/code-block/CodeBlock.js +1 -1
  41. package/dist/components/collapsible/Collapsible.js +1 -1
  42. package/dist/components/color-picker/ColorPicker.js +1 -1
  43. package/dist/components/combobox/Combobox.js +1 -1
  44. package/dist/components/command-palette/CommandPalette.d.ts +88 -0
  45. package/dist/components/command-palette/CommandPalette.js +1 -0
  46. package/dist/components/command-palette/index.d.ts +2 -0
  47. package/dist/components/command-palette/index.js +1 -0
  48. package/dist/components/container/Container.js +1 -1
  49. package/dist/components/data-list/DataList.d.ts +55 -0
  50. package/dist/components/data-list/DataList.js +1 -0
  51. package/dist/components/data-list/index.d.ts +2 -0
  52. package/dist/components/data-list/index.js +1 -0
  53. package/dist/components/data-table/DataTable.js +1 -1
  54. package/dist/components/date-picker/DatePicker.js +1 -1
  55. package/dist/components/date-range-picker/DateRangePicker.js +1 -1
  56. package/dist/components/date-time-picker/DateTimePicker.js +1 -1
  57. package/dist/components/dialog/Dialog.js +1 -1
  58. package/dist/components/divider/Divider.js +1 -1
  59. package/dist/components/drawer/Drawer.js +1 -1
  60. package/dist/components/empty/Empty.js +1 -1
  61. package/dist/components/fieldset/Fieldset.d.ts +33 -0
  62. package/dist/components/fieldset/Fieldset.js +1 -0
  63. package/dist/components/fieldset/index.d.ts +2 -0
  64. package/dist/components/fieldset/index.js +1 -0
  65. package/dist/components/file-picker/FilePicker.js +1 -1
  66. package/dist/components/floating-action-button/FloatingActionButton.js +1 -1
  67. package/dist/components/floating-bottom-navigation/FloatingBottomNavigation.js +1 -1
  68. package/dist/components/footer/Footer.js +1 -1
  69. package/dist/components/form/Form.d.ts +58 -0
  70. package/dist/components/form/Form.js +1 -0
  71. package/dist/components/form/index.d.ts +2 -0
  72. package/dist/components/form/index.js +1 -0
  73. package/dist/components/gauge-chart/GaugeChart.d.ts +62 -0
  74. package/dist/components/gauge-chart/GaugeChart.js +1 -0
  75. package/dist/components/gauge-chart/index.d.ts +2 -0
  76. package/dist/components/gauge-chart/index.js +1 -0
  77. package/dist/components/grid/Grid.js +1 -1
  78. package/dist/components/grid-container/GridContainer.js +1 -1
  79. package/dist/components/header/Header.js +1 -1
  80. package/dist/components/heatmap-chart/HeatmapChart.js +1 -1
  81. package/dist/components/highlight/Highlight.js +1 -1
  82. package/dist/components/hover-card/HoverCard.d.ts +78 -0
  83. package/dist/components/hover-card/HoverCard.js +1 -0
  84. package/dist/components/hover-card/index.d.ts +2 -0
  85. package/dist/components/hover-card/index.js +1 -0
  86. package/dist/components/how-to-steps/HowToSteps.d.ts +11 -25
  87. package/dist/components/how-to-steps/HowToSteps.js +1 -1
  88. package/dist/components/icon/Icon.js +1 -1
  89. package/dist/components/icon-button/IconButton.js +1 -1
  90. package/dist/components/line-chart/LineChart.js +1 -1
  91. package/dist/components/list/List.js +1 -1
  92. package/dist/components/menu/Menu.d.ts +16 -4
  93. package/dist/components/menu/Menu.js +1 -1
  94. package/dist/components/menubar/Menubar.d.ts +56 -0
  95. package/dist/components/menubar/Menubar.js +1 -0
  96. package/dist/components/menubar/index.d.ts +2 -0
  97. package/dist/components/menubar/index.js +1 -0
  98. package/dist/components/meter/Meter.d.ts +52 -0
  99. package/dist/components/meter/Meter.js +1 -0
  100. package/dist/components/meter/index.d.ts +2 -0
  101. package/dist/components/meter/index.js +1 -0
  102. package/dist/components/mockup/Mockup.js +1 -1
  103. package/dist/components/navigation-menu/NavigationMenu.d.ts +100 -0
  104. package/dist/components/navigation-menu/NavigationMenu.js +1 -0
  105. package/dist/components/navigation-menu/index.d.ts +2 -0
  106. package/dist/components/navigation-menu/index.js +1 -0
  107. package/dist/components/number-field/NumberField.js +1 -1
  108. package/dist/components/otp-field/OtpField.js +1 -1
  109. package/dist/components/overlay/Overlay.js +1 -1
  110. package/dist/components/page-layout/PageLayout.js +1 -1
  111. package/dist/components/pagination/Pagination.js +1 -1
  112. package/dist/components/panes/Panes.js +1 -1
  113. package/dist/components/pie-chart/PieChart.js +1 -1
  114. package/dist/components/pill/Pill.js +1 -1
  115. package/dist/components/popover/Popover.js +1 -1
  116. package/dist/components/progress-box/ProgressBox.js +1 -1
  117. package/dist/components/progress-circular/ProgressCircular.js +1 -1
  118. package/dist/components/progress-linear/ProgressLinear.js +1 -1
  119. package/dist/components/radio-group/RadioGroup.js +1 -1
  120. package/dist/components/rating/Rating.js +1 -1
  121. package/dist/components/scatter-chart/ScatterChart.js +1 -1
  122. package/dist/components/scroll-area/ScrollArea.d.ts +50 -0
  123. package/dist/components/scroll-area/ScrollArea.js +1 -0
  124. package/dist/components/scroll-area/index.d.ts +2 -0
  125. package/dist/components/scroll-area/index.js +1 -0
  126. package/dist/components/scroll-zone/ScrollZone.d.ts +35 -17
  127. package/dist/components/scroll-zone/ScrollZone.js +1 -1
  128. package/dist/components/segmented-button/SegmentedButton.js +1 -1
  129. package/dist/components/select/Select.js +1 -1
  130. package/dist/components/shortcut/Shortcut.js +1 -1
  131. package/dist/components/sidebar/Sidebar.js +1 -1
  132. package/dist/components/sidebar/SidebarTrigger.js +1 -1
  133. package/dist/components/skeleton/Skeleton.js +1 -1
  134. package/dist/components/slider/Slider.js +1 -1
  135. package/dist/components/sparkline/Sparkline.js +1 -1
  136. package/dist/components/spoiler/Spoiler.js +1 -1
  137. package/dist/components/statistic/Statistic.js +1 -1
  138. package/dist/components/switch/Switch.js +1 -1
  139. package/dist/components/table/Table.js +1 -1
  140. package/dist/components/tabs/Tabs.js +1 -1
  141. package/dist/components/text-field/TextField.js +1 -1
  142. package/dist/components/text-link/TextLink.js +1 -1
  143. package/dist/components/time-picker/TimePicker.js +1 -1
  144. package/dist/components/timeline/Timeline.js +1 -1
  145. package/dist/components/timeline-chart/TimelineChart.js +1 -1
  146. package/dist/components/toast/Toast.js +1 -1
  147. package/dist/components/toggle/Toggle.d.ts +53 -0
  148. package/dist/components/toggle/Toggle.js +1 -0
  149. package/dist/components/toggle/index.d.ts +2 -0
  150. package/dist/components/toggle/index.js +1 -0
  151. package/dist/components/toggle-group/ToggleGroup.d.ts +51 -0
  152. package/dist/components/toggle-group/ToggleGroup.js +1 -0
  153. package/dist/components/toggle-group/index.d.ts +2 -0
  154. package/dist/components/toggle-group/index.js +1 -0
  155. package/dist/components/toolbar/Toolbar.js +1 -1
  156. package/dist/components/tooltip/Tooltip.js +1 -1
  157. package/dist/components/tour/Tour.d.ts +82 -0
  158. package/dist/components/tour/Tour.js +1 -0
  159. package/dist/components/tour/index.d.ts +2 -0
  160. package/dist/components/tour/index.js +1 -0
  161. package/dist/components/transfer/Transfer.d.ts +52 -0
  162. package/dist/components/transfer/Transfer.js +1 -0
  163. package/dist/components/transfer/index.d.ts +2 -0
  164. package/dist/components/transfer/index.js +1 -0
  165. package/dist/components/tree-view/TreeView.js +1 -1
  166. package/dist/components/typography/Typography.js +1 -1
  167. package/dist/components/window-pane/WindowPane.js +1 -1
  168. package/dist/index.d.ts +16 -0
  169. package/dist/index.js +1 -1
  170. package/dist/internal/animate.d.ts +7 -1
  171. package/dist/internal/animate.js +1 -1
  172. package/dist/internal/avatar-group.d.ts +22 -0
  173. package/dist/internal/avatar-group.js +1 -0
  174. package/dist/internal/bottom-navigation.js +1 -1
  175. package/dist/internal/button-group.d.ts +6 -2
  176. package/dist/internal/button-group.js +1 -1
  177. package/dist/internal/calendar.js +1 -1
  178. package/dist/internal/chart-frame.d.ts +18 -1
  179. package/dist/internal/chart-frame.js +1 -1
  180. package/dist/internal/data-table.d.ts +0 -14
  181. package/dist/internal/data-table.js +1 -1
  182. package/dist/internal/drag.d.ts +62 -0
  183. package/dist/internal/drag.js +1 -0
  184. package/dist/internal/highlight.js +1 -1
  185. package/dist/internal/i18n.d.ts +82 -0
  186. package/dist/internal/i18n.js +1 -1
  187. package/dist/internal/link.d.ts +19 -0
  188. package/dist/internal/link.js +1 -0
  189. package/dist/internal/media.d.ts +29 -0
  190. package/dist/internal/media.js +1 -0
  191. package/dist/internal/menu.js +1 -1
  192. package/dist/internal/observe.d.ts +42 -0
  193. package/dist/internal/observe.js +1 -0
  194. package/dist/internal/page-layout.js +1 -1
  195. package/dist/internal/picker.js +1 -1
  196. package/dist/internal/progress.d.ts +5 -0
  197. package/dist/internal/search.d.ts +33 -0
  198. package/dist/internal/search.js +1 -0
  199. package/dist/internal/styles.d.ts +39 -0
  200. package/dist/internal/styles.js +1 -1
  201. package/dist/locales/ar.js +1 -1
  202. package/dist/locales/de.js +1 -1
  203. package/dist/locales/es.js +1 -1
  204. package/dist/locales/fr.js +1 -1
  205. package/dist/locales/hi.js +1 -1
  206. package/dist/locales/id.js +1 -1
  207. package/dist/locales/it.js +1 -1
  208. package/dist/locales/ja.js +1 -1
  209. package/dist/locales/ko.js +1 -1
  210. package/dist/locales/nl.js +1 -1
  211. package/dist/locales/pl.js +1 -1
  212. package/dist/locales/pt.js +1 -1
  213. package/dist/locales/ru.js +1 -1
  214. package/dist/locales/th.js +1 -1
  215. package/dist/locales/tr.js +1 -1
  216. package/dist/locales/vi.js +1 -1
  217. package/dist/locales/zh-hans.js +1 -1
  218. package/dist/locales/zh-hant.js +1 -1
  219. package/dist/styles.css +1 -1
  220. package/dist/tailwind.css +104 -0
  221. package/dist/types.d.ts +16 -0
  222. package/package.json +2 -2
@@ -99,7 +99,13 @@ export declare function transitionProps(transition: NebaTransition | undefined):
99
99
  className: string;
100
100
  style: React.CSSProperties;
101
101
  };
102
- export declare function usePrefersReducedMotion(): boolean;
102
+ /**
103
+ * Whether the reader has asked for less motion — the hook the three effects
104
+ * with motion written in JavaScript read. It lives in `media.ts` beside the
105
+ * query it asks, so a Carousel and a ScrollZone can ask the same question
106
+ * without pulling the eleven effects below in with the answer.
107
+ */
108
+ export { usePrefersReducedMotion } from './media.js';
103
109
  export interface AnimationRunOptions {
104
110
  trigger: NebaAnimateTrigger;
105
111
  play?: boolean;
@@ -1 +1 @@
1
- import*as e from"react";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)}}const n="(prefers-reduced-motion: reduce)";function t(e){if("undefined"==typeof window||!window.matchMedia)return()=>{};const t=window.matchMedia(n);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function a(){return!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia(n).matches}function i(){return!1}export function usePrefersReducedMotion(){return e.useSyncExternalStore(t,a,i)}export function useAnimationRun({trigger:n,play:t,once:a,threshold:i,paused:o,infinite:r}){const s=e.useRef(null),[c,l]=e.useState("mount"===n),[u,d]=e.useState(0),f=e.useCallback(()=>{l(!0),d(e=>e+1)},[]);e.useLayoutEffect(()=>{const e=s.current;if(!e||0===u)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=""},[u]),e.useEffect(()=>{if("visible"!==n)return;const e=s.current;if(!e||"undefined"==typeof IntersectionObserver)return void l(!0);const t=new IntersectionObserver(([e])=>{e.isIntersecting?(f(),a&&t.disconnect()):a||l(!1)},{threshold:i});return t.observe(e),()=>t.disconnect()},[n,a,i,f]),e.useEffect(()=>{"manual"===n&&(t?f():l(!1))},[n,t,f]);const m="hover"===n?{onPointerEnter:f,onFocus:f,onPointerLeave:()=>{r&&l(!1)},onBlur:()=>{r&&l(!1)}}:{};return{ref:e.useCallback(e=>{s.current=e},[]),state:c&&!o?"running":"paused",started:c,handlers:m}}export function useAnimateElement(e){const{effect:n,trigger:t,play:a,once:i,threshold:o,paused:r,infinite:s,...c}=e,l=useAnimationRun({trigger:t,play:a,once:i,threshold:o,paused:r,infinite:s});return{ref:l.ref,className:n?`neba-anim ${animationClasses[n]}`:"",style:{...animationSlots(c),"--n-anim-state":l.state},props:{...l.handlers,"data-neba-animation":n??void 0,"data-state":l.state}}}
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}}}
@@ -0,0 +1,22 @@
1
+ import * as React from 'react';
2
+ import type { AvatarShape } from '../components/avatar/Avatar.js';
3
+ import type { NebaColor, NebaElevation, NebaSize, NebaVariant } from '../types.js';
4
+ /**
5
+ * What an Avatar inherits from the AvatarGroup around it.
6
+ *
7
+ * `button-group.ts`'s arrangement, one component over and for the same reason:
8
+ * a stack of avatars where the fourth one is a size out is not a stack, and
9
+ * `React.Children.map` with `cloneElement` stops working the moment a caller
10
+ * wraps one of them in a Tooltip or produces them from a `.map()`.
11
+ *
12
+ * It lives here rather than in the avatar-group folder so that Avatar can read
13
+ * it without the two components importing each other.
14
+ */
15
+ export interface AvatarGroupContextValue {
16
+ size?: NebaSize;
17
+ shape?: AvatarShape;
18
+ variant?: NebaVariant;
19
+ color?: NebaColor;
20
+ elevation?: NebaElevation;
21
+ }
22
+ export declare const AvatarGroupContext: React.Context<AvatarGroupContextValue | null>;
@@ -0,0 +1 @@
1
+ "use client";import*as t from"react";export const AvatarGroupContext=/*@__PURE__*/t.createContext(null);
@@ -1 +1 @@
1
- import*as t from"react";export const BottomNavigationContext=/*@__PURE__*/t.createContext({value:null,change:()=>{},size:"md",density:"default",labels:"all",disabled:!1,floating:!1});export const barMinHeightClasses={xs:"min-h-10",sm:"min-h-12",md:"min-h-14",lg:"min-h-16",xl:"min-h-18"};
1
+ "use client";import*as t from"react";export const BottomNavigationContext=/*@__PURE__*/t.createContext({value:null,change:()=>{},size:"md",density:"default",labels:"all",disabled:!1,floating:!1});export const barMinHeightClasses={xs:"min-h-10",sm:"min-h-12",md:"min-h-14",lg:"min-h-16",xl:"min-h-18"};
@@ -1,7 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import type { NebaColor, NebaDensity, NebaElevation, NebaSize, NebaVariant } from '../types.js';
3
3
  /**
4
- * What a Button inherits from the ButtonGroup around it.
4
+ * What a Button inherits from the ButtonGroup around it — and what a Toggle
5
+ * inherits from the ToggleGroup around it, which is the same six values and so
6
+ * is the same context rather than a second one spelled identically.
5
7
  *
6
8
  * The alternative — `React.Children.map` with `cloneElement` — breaks the moment
7
9
  * a caller wraps one of the buttons in a Tooltip, a `<Fragment>` or a `.map()`,
@@ -12,7 +14,9 @@ import type { NebaColor, NebaDensity, NebaElevation, NebaSize, NebaVariant } fro
12
14
  * `<ButtonGroup>` with no props changes nothing except the corners.
13
15
  *
14
16
  * It lives in `internal/` rather than in the button-group folder so that Button
15
- * can read it without the two components importing each other.
17
+ * can read it without the two components importing each other — and by now four
18
+ * components read it, which is the arrangement `menu.ts` makes for the same
19
+ * reason.
16
20
  */
17
21
  export interface ButtonGroupContextValue {
18
22
  variant?: NebaVariant;
@@ -1 +1 @@
1
- import*as t from"react";export const ButtonGroupContext=/*@__PURE__*/t.createContext(null);
1
+ "use client";import*as t from"react";export const ButtonGroupContext=/*@__PURE__*/t.createContext(null);
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import*as o from"react";import{Button as r}from"../components/button/Button.js";import{ChevronIcon as a}from"./icons.js";import{controlHeightClasses as l,controlTextClasses as s,cx as i,gapClasses as c,metaTextClasses as u,pressTransitionClasses as d,srOnlyClasses as m,transitionClasses as h}from"./styles.js";import{addDays as g,addMonths as f,addYears as b,calendarWeeks as p,compareDay as v,daysInMonth as x,isDayOutside as w,isMonthBeforeYear as y,isSameDay as D,isSameMonth as N,isValidDate as S,makeDate as M,meridiemLabels as P,monthLabels as C,startOfDay as k,startOfMonth as Y,today as z,weekdayLabels as A,withTime as F,YEAR_PAGE_SIZE as j,yearPageStart as E}from"./date.js";import{dateFormatter as T}from"./format.js";export const defaultPickerLabels={previousMonth:"Previous month",nextMonth:"Next month",previousYear:"Previous year",nextYear:"Next year",previousYears:"Previous years",nextYears:"Next years",chooseMonth:"Choose a month",chooseYear:"Choose a year",today:"Today",now:"Now",clear:"Clear",done:"Done",hour:"Hour",minute:"Minute",second:"Second",meridiem:"AM/PM",start:"Start",end:"End"};export function usePickerLabels(e){return o.useMemo(()=>e?{...defaultPickerLabels,...e}:defaultPickerLabels,[e])}const R={xs:"1.375rem",sm:"1.625rem",md:"2rem",lg:"2.5rem",xl:"3rem"},B={xs:"rounded-(--neba-radius-xs)",sm:"rounded-(--neba-radius-xs)",md:"rounded-(--neba-radius-sm)",lg:"rounded-(--neba-radius-md)",xl:"rounded-(--neba-radius-lg)"},H={xs:"rounded-s-(--neba-radius-xs)",sm:"rounded-s-(--neba-radius-xs)",md:"rounded-s-(--neba-radius-sm)",lg:"rounded-s-(--neba-radius-md)",xl:"rounded-s-(--neba-radius-lg)"},L={xs:"rounded-e-(--neba-radius-xs)",sm:"rounded-e-(--neba-radius-xs)",md:"rounded-e-(--neba-radius-sm)",lg:"rounded-e-(--neba-radius-md)",xl:"rounded-e-(--neba-radius-lg)"},K=["relative flex select-none items-center justify-center tabular-nums","[-webkit-tap-highlight-color:transparent] [touch-action:manipulation]",h,d,"focus-visible:z-10 focus-visible:[outline:2px_solid_var(--n-ring)]","focus-visible:[outline-offset:-2px]"].join(" ");function O({children:n,label:o,selected:r,inRange:a=!1,rangeEdge:l=null,current:s=!1,muted:c=!1,disabled:u=!1,focused:d=!1,size:m,className:h,onClick:g,onPointerEnter:f,onKeyDown:b}){return t("button",{type:"button",role:"gridcell","aria-label":o,"aria-selected":r,"aria-current":s?"date":void 0,"aria-disabled":u||void 0,tabIndex:d?0:-1,"data-focus-target":d?"true":void 0,className:i(K,"start"===l?H[m]:"end"===l?L[m]:"middle"===l?"rounded-none":B[m],u?"cursor-not-allowed text-(--neba-disabled-fg)":r?"cursor-pointer bg-(--n-fill) font-semibold text-(--n-on-solid) hover:bg-(--n-fill-hover) active:bg-(--n-fill-active)":a?"cursor-pointer bg-(--n-soft) text-(--neba-fg) hover:bg-(--n-soft-hover) active:bg-(--n-soft-press)":s?"cursor-pointer font-semibold text-(--n-accent) hover:bg-(--n-soft) active:bg-(--n-soft-press)":c?"cursor-pointer text-(--neba-muted-fg) hover:bg-(--n-soft) active:bg-(--n-soft-press)":"cursor-pointer text-(--neba-fg) hover:bg-(--n-soft) active:bg-(--n-soft-press)",h),onClick:()=>{u||g()},onPointerEnter:f,onKeyDown:b,children:[n,s?e("span",{"aria-hidden":"true",className:"absolute bottom-[0.18em] size-[0.22em] rounded-full bg-current"}):null]})}function U({size:o,color:u,view:d,month:m,locale:h,labels:g,showPreviousButton:f,showNextButton:b,onStep:p,onViewChange:v}){const x=C(h,"long")[m.getMonth()],w=String(m.getFullYear()),D=y(h),N="day"===d?[g.previousMonth,g.nextMonth]:"month"===d?[g.previousYear,g.nextYear]:[g.previousYears,g.nextYears],S=(t,n)=>n?e(r,{variant:"text",size:o,color:u,density:"compact","aria-label":N[-1===t?0:1],onClick:()=>p(t),startIcon:e("span",{className:i("flex items-center",-1===t?"rotate-90 rtl:-rotate-90":"-rotate-90 rtl:rotate-90"),children:e(a,{})})}):e("span",{"aria-hidden":"true",className:i(l[o],"w-(--n-cell)")}),M=t=>e("span",{className:i("flex items-center text-(--neba-muted-fg)","[transition:rotate_var(--neba-duration)_var(--neba-ease)]",t&&"rotate-180"),children:e(a,{})}),P=e(r,{variant:"text",size:o,color:u,density:"compact","aria-label":g.chooseMonth,"aria-expanded":"month"===d,onClick:()=>v("month"===d?"day":"month"),endIcon:M("month"===d),children:x},"month"),k=e(r,{variant:"text",size:o,color:u,density:"compact",className:"tabular-nums","aria-label":g.chooseYear,"aria-expanded":"year"===d,onClick:()=>v("year"===d?"day":"year"),endIcon:M("year"===d),children:w},"year"),Y=E(m.getFullYear());return t("div",{className:"flex items-center justify-between gap-1",children:[S(-1,f),e("div",{className:i("flex min-w-0 flex-1 items-center justify-center",c[o]),children:"year"===d?e("span",{className:i("flex items-center font-medium tabular-nums text-(--neba-fg)",l[o],s[o]),children:`${Y}–${Y+j-1}`}):"month"===d?k:t(n,D?{children:[P,k]}:{children:[k,P]})}),S(1,b)]})}export function Calendar({size:n,color:r,locale:a,weekStartsOn:l,month:s,onMonthChange:u,selected:d,rangeStart:m=null,rangeEnd:h=null,onSelect:g,onPreviewChange:p,minDate:v,maxDate:x,shouldDisableDate:y,showOutsideDays:D=!0,autoFocus:P=!1,showPreviousButton:C=!0,showNextButton:A=!0,labels:F,className:E}){const[T,B]=o.useState("day"),H=o.useMemo(()=>d.filter(S),[d]),[L,K]=o.useState(()=>{const e=H.find(e=>N(e,s));return e?k(e):N(z(),s)?z():Y(s)}),O=o.useRef(P),_=o.useRef(null);o.useEffect(()=>{K(e=>N(e,s)?e:Y(s))},[s]),o.useLayoutEffect(()=>{O.current&&(O.current=!1,_.current?.querySelector('[data-focus-target="true"]')?.focus({preventScroll:!0}))});const V=o.useCallback(e=>w(e,v,x)||(y?.(e)??!1),[v,x,y]),G=e=>{O.current=!0,B(e)},J=e=>{O.current=!0,u(e)};return t("div",{ref:_,className:i("flex flex-col",c[n],E),style:{"--n-cell":R[n]},onPointerLeave:()=>p?.(null),children:[e(U,{size:n,color:r,view:T,month:s,locale:a,labels:F,showPreviousButton:C,showNextButton:A,onStep:e=>{u("day"===T?f(s,e):b(s,"month"===T?e:e*j))},onViewChange:G}),e("div",{className:"h-[calc(var(--n-cell)*7)] w-[calc(var(--n-cell)*7)]",children:"day"===T?e(q,{size:n,locale:a,weekStartsOn:l,month:s,chosen:H,rangeStart:m,rangeEnd:h,focusedDate:L,showOutsideDays:D,isDisabled:V,onSelect:e=>{K(e),g(e)},onPreviewChange:p,onMoveFocus:e=>{O.current=!0,K(e),N(e,s)||u(Y(e))}}):"month"===T?e(I,{size:n,locale:a,month:s,chosen:H,minDate:v,maxDate:x,onMoveCursor:J,onPick:e=>{u(M(s.getFullYear(),e,1)),G("day")}}):e($,{size:n,month:s,chosen:H,minDate:v,maxDate:x,onMoveCursor:J,onPick:e=>{u(M(e,s.getMonth(),1)),G("month")}})})]})}function q({size:n,locale:o,weekStartsOn:r,month:a,chosen:l,rangeStart:c,rangeEnd:d,focusedDate:m,showOutsideDays:h,isDisabled:b,onSelect:x,onPreviewChange:w,onMoveFocus:y}){const M=p(a,r),P=A(o,r,"short"),C=A(o,r,"long"),k=T(o,{dateStyle:"full"}),Y=(j=d,S(F=c)&&S(j)?v(F,j)<=0?[F,j]:[j,F]:null);var F,j;const E=z();return t("div",{role:"grid",className:"flex h-full flex-col",children:[e("div",{role:"row",className:"grid grid-cols-7",children:P.map((t,o)=>e("span",{role:"columnheader","aria-label":C[o],className:i("flex h-(--n-cell) items-center justify-center font-medium text-(--neba-muted-fg) select-none",u[n]),children:t},o))}),M.map((t,o)=>e("div",{role:"row",className:"grid grid-cols-7",children:t.map(t=>{const o=!N(t,a);if(o&&!h)return e("span",{role:"gridcell","aria-hidden":"true",className:"size-(--n-cell)"},t.getTime());const c=l.some(e=>D(e,t)),u=null!==Y&&v(t,Y[0])>=0&&v(t,Y[1])<=0,d=null!==Y&&u&&D(t,Y[0]),p=null!==Y&&u&&D(t,Y[1]);return e(O,{size:n,label:k.format(t),selected:c,inRange:u&&!c,rangeEdge:u?d&&p?"both":d?"start":p?"end":"middle":null,current:D(t,E)&&!c,muted:o,disabled:b(t),focused:D(t,m),className:i("size-(--n-cell)",s[n]),onClick:()=>x(t),onPointerEnter:()=>w?.(t),onKeyDown:e=>((e,t)=>{const n=(t.getDay()-r+7)%7,o={ArrowLeft:()=>g(t,-1),ArrowRight:()=>g(t,1),ArrowUp:()=>g(t,-7),ArrowDown:()=>g(t,7),Home:()=>g(t,-n),End:()=>g(t,6-n),PageUp:()=>f(t,e.shiftKey?-12:-1),PageDown:()=>f(t,e.shiftKey?12:1)}[e.key];o&&(e.preventDefault(),y(o()))})(e,t),children:t.getDate()},t.getTime())})},o))]})}function I({size:t,locale:n,month:o,chosen:r,minDate:a,maxDate:l,onMoveCursor:c,onPick:u}){const d=C(n,"short"),m=C(n,"long"),h=o.getFullYear(),g=new Date,b=e=>{const t={ArrowLeft:-1,ArrowRight:1,ArrowUp:-3,ArrowDown:3,PageUp:-12,PageDown:12}[e.key];void 0!==t&&(e.preventDefault(),c(f(Y(o),t)))};return e("div",{role:"grid",className:"flex h-full flex-col justify-evenly",children:[0,1,2,3].map(n=>e("div",{role:"row",className:"grid grid-cols-3 gap-1",children:[0,1,2].map(c=>{const f=3*n+c,p=M(h,f,1),w=M(h,f,x(h,f));return e(O,{size:t,label:`${m[f]} ${h}`,selected:r.some(e=>e.getFullYear()===h&&e.getMonth()===f),current:g.getFullYear()===h&&g.getMonth()===f,disabled:S(a)&&v(w,a)<0||S(l)&&v(p,l)>0,focused:f===o.getMonth(),className:i("h-(--n-cell) w-full",s[t]),onClick:()=>u(f),onKeyDown:b,children:d[f]},f)})},n))})}function $({size:t,month:n,chosen:o,minDate:r,maxDate:a,onMoveCursor:l,onPick:c}){const u=E(n.getFullYear()),d=(new Date).getFullYear(),m=e=>{const t={ArrowLeft:-1,ArrowRight:1,ArrowUp:-4,ArrowDown:4,PageUp:-j,PageDown:j}[e.key];void 0!==t&&(e.preventDefault(),l(b(Y(n),t)))};return e("div",{role:"grid",className:"flex h-full flex-col justify-evenly",children:[0,1,2].map(l=>e("div",{role:"row",className:"grid grid-cols-4 gap-1",children:[0,1,2,3].map(h=>{const g=u+4*l+h;return e(O,{size:t,label:String(g),selected:o.some(e=>e.getFullYear()===g),current:g===d,disabled:S(r)&&g<r.getFullYear()||S(a)&&g>a.getFullYear(),focused:g===n.getFullYear(),className:i("h-(--n-cell) w-full",s[t]),onClick:()=>c(g),onKeyDown:m,children:g},g)})},l))})}function _(e){const t=e.parentElement;if(!t)return;const n=e.getBoundingClientRect(),o=t.getBoundingClientRect(),r=n.top-o.top-t.clientTop+t.scrollTop,a=r+n.height;r<t.scrollTop?t.scrollTop=r:a>t.scrollTop+t.clientHeight&&(t.scrollTop=a-t.clientHeight)}export function TimeGrid({size:n,density:r,locale:a,value:c,referenceDate:u,onChange:d,hour12:h,showSeconds:g,hourStep:f,minuteStep:b,secondStep:p,shouldDisableTime:v,autoFocus:x=!1,labels:w,className:y}){const D=c??u,N=o.useRef(null),[S,M]=o.useMemo(()=>P(a),[a]);o.useEffect(()=>{const e=N.current;if(e?.querySelectorAll('[data-chosen="true"]').forEach(_),x){const t=e?.querySelector('[role="listbox"]');(t?.querySelector('[data-chosen="true"]')??t?.querySelector('[role="option"]'))?.focus({preventScroll:!0})}},[x]);const C=o.useMemo(()=>{const e=Math.ceil((h?12:24)/f),t=Array.from({length:e},(e,t)=>t*f);return h?t.map(e=>0===e?12:e):t},[h,f]),k=o.useMemo(()=>Array.from({length:Math.ceil(60/b)},(e,t)=>t*b),[b]),Y=o.useMemo(()=>Array.from({length:Math.ceil(60/p)},(e,t)=>t*p),[p]),z=e=>String(e).padStart(2,"0"),A=h?D.getHours()%12||12:D.getHours(),j=(t,o,r,a,u)=>e("div",{role:"listbox","aria-label":o,className:i("flex flex-col gap-0.5 overflow-y-auto overscroll-contain","h-[calc(var(--n-cell)*7)] w-[calc(var(--n-cell)*2)]","scroll-py-0.5 [scrollbar-width:thin]"),children:r.map(o=>{const r=((e,t)=>F(D,"hour"===e?{hours:h?t%12+(D.getHours()>=12?12:0):t}:"minute"===e?{minutes:t}:"second"===e?{seconds:t}:{hours:D.getHours()%12+12*t}))(t,o),m=null!==c&&a(o),g=v?.(r,t)??!1;return e("button",{type:"button",role:"option","aria-selected":m,"aria-disabled":g||void 0,"data-chosen":m?"true":void 0,className:i(K,B[n],l[n],s[n],"w-full shrink-0",g?"cursor-not-allowed text-(--neba-disabled-fg)":m?"cursor-pointer bg-(--n-fill) font-semibold text-(--n-on-solid) hover:bg-(--n-fill-hover) active:bg-(--n-fill-active)":"cursor-pointer text-(--neba-fg) hover:bg-(--n-soft) active:bg-(--n-soft-press)"),onClick:()=>{g||d(r)},children:u(o)},o)})},t);return t("div",{ref:N,className:i("flex","compact"===r?"gap-0.5":"gap-1",y),style:{"--n-cell":R[n]},children:[j("hour",w.hour,C,e=>e===A,e=>h?String(e):z(e)),j("minute",w.minute,k,e=>e===D.getMinutes(),z),g?j("second",w.second,Y,e=>e===D.getSeconds(),z):null,h?j("meridiem",w.meridiem,[0,1],e=>(D.getHours()>=12?1:0)===e,e=>0===e?S:M):null,e("span",{className:m,"aria-live":"polite",children:null===c?"":T(a,{hour:"numeric",minute:"2-digit",...g?{second:"2-digit"}:{}}).format(c)})]})}
1
+ "use client";import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import*as o from"react";import{Button as r}from"../components/button/Button.js";import{ChevronIcon as a}from"./icons.js";import{controlHeightClasses as l,controlTextClasses as s,cx as i,gapClasses as c,metaTextClasses as u,pressTransitionClasses as d,srOnlyClasses as m,transitionClasses as h}from"./styles.js";import{addDays as g,addMonths as f,addYears as b,calendarWeeks as p,compareDay as v,daysInMonth as x,isDayOutside as w,isMonthBeforeYear as y,isSameDay as D,isSameMonth as N,isValidDate as S,makeDate as M,meridiemLabels as P,monthLabels as C,startOfDay as k,startOfMonth as Y,today as z,weekdayLabels as A,withTime as F,YEAR_PAGE_SIZE as j,yearPageStart as E}from"./date.js";import{dateFormatter as T}from"./format.js";export const defaultPickerLabels={previousMonth:"Previous month",nextMonth:"Next month",previousYear:"Previous year",nextYear:"Next year",previousYears:"Previous years",nextYears:"Next years",chooseMonth:"Choose a month",chooseYear:"Choose a year",today:"Today",now:"Now",clear:"Clear",done:"Done",hour:"Hour",minute:"Minute",second:"Second",meridiem:"AM/PM",start:"Start",end:"End"};export function usePickerLabels(e){return o.useMemo(()=>e?{...defaultPickerLabels,...e}:defaultPickerLabels,[e])}const R={xs:"1.375rem",sm:"1.625rem",md:"2rem",lg:"2.5rem",xl:"3rem"},B={xs:"rounded-(--neba-radius-xs)",sm:"rounded-(--neba-radius-xs)",md:"rounded-(--neba-radius-sm)",lg:"rounded-(--neba-radius-md)",xl:"rounded-(--neba-radius-lg)"},H={xs:"rounded-s-(--neba-radius-xs)",sm:"rounded-s-(--neba-radius-xs)",md:"rounded-s-(--neba-radius-sm)",lg:"rounded-s-(--neba-radius-md)",xl:"rounded-s-(--neba-radius-lg)"},L={xs:"rounded-e-(--neba-radius-xs)",sm:"rounded-e-(--neba-radius-xs)",md:"rounded-e-(--neba-radius-sm)",lg:"rounded-e-(--neba-radius-md)",xl:"rounded-e-(--neba-radius-lg)"},K=["relative flex select-none items-center justify-center tabular-nums","[-webkit-tap-highlight-color:transparent] [touch-action:manipulation]",h,d,"focus-visible:z-10 focus-visible:[outline:2px_solid_var(--n-ring)]","focus-visible:[outline-offset:-2px]"].join(" ");function O({children:n,label:o,selected:r,inRange:a=!1,rangeEdge:l=null,current:s=!1,muted:c=!1,disabled:u=!1,focused:d=!1,size:m,className:h,onClick:g,onPointerEnter:f,onKeyDown:b}){return t("button",{type:"button",role:"gridcell","aria-label":o,"aria-selected":r,"aria-current":s?"date":void 0,"aria-disabled":u||void 0,tabIndex:d?0:-1,"data-focus-target":d?"true":void 0,className:i(K,"start"===l?H[m]:"end"===l?L[m]:"middle"===l?"rounded-none":B[m],u?"cursor-not-allowed text-(--neba-disabled-fg)":r?"cursor-pointer bg-(--n-fill) font-semibold text-(--n-on-solid) hover:bg-(--n-fill-hover) active:bg-(--n-fill-active)":a?"cursor-pointer bg-(--n-soft) text-(--neba-fg) hover:bg-(--n-soft-hover) active:bg-(--n-soft-press)":s?"cursor-pointer font-semibold text-(--n-accent) hover:bg-(--n-soft) active:bg-(--n-soft-press)":c?"cursor-pointer text-(--neba-muted-fg) hover:bg-(--n-soft) active:bg-(--n-soft-press)":"cursor-pointer text-(--neba-fg) hover:bg-(--n-soft) active:bg-(--n-soft-press)",h),onClick:()=>{u||g()},onPointerEnter:f,onKeyDown:b,children:[n,s?e("span",{"aria-hidden":"true",className:"absolute bottom-[0.18em] size-[0.22em] rounded-full bg-current"}):null]})}function U({size:o,color:u,view:d,month:m,locale:h,labels:g,showPreviousButton:f,showNextButton:b,onStep:p,onViewChange:v}){const x=C(h,"long")[m.getMonth()],w=String(m.getFullYear()),D=y(h),N="day"===d?[g.previousMonth,g.nextMonth]:"month"===d?[g.previousYear,g.nextYear]:[g.previousYears,g.nextYears],S=(t,n)=>n?e(r,{variant:"text",size:o,color:u,density:"compact","aria-label":N[-1===t?0:1],onClick:()=>p(t),startIcon:e("span",{className:i("flex items-center",-1===t?"rotate-90 rtl:-rotate-90":"-rotate-90 rtl:rotate-90"),children:e(a,{})})}):e("span",{"aria-hidden":"true",className:i(l[o],"w-(--n-cell)")}),M=t=>e("span",{className:i("flex items-center text-(--neba-muted-fg)","[transition:rotate_var(--neba-duration)_var(--neba-ease)]",t&&"rotate-180"),children:e(a,{})}),P=e(r,{variant:"text",size:o,color:u,density:"compact","aria-label":g.chooseMonth,"aria-expanded":"month"===d,onClick:()=>v("month"===d?"day":"month"),endIcon:M("month"===d),children:x},"month"),k=e(r,{variant:"text",size:o,color:u,density:"compact",className:"tabular-nums","aria-label":g.chooseYear,"aria-expanded":"year"===d,onClick:()=>v("year"===d?"day":"year"),endIcon:M("year"===d),children:w},"year"),Y=E(m.getFullYear());return t("div",{className:"flex items-center justify-between gap-1",children:[S(-1,f),e("div",{className:i("flex min-w-0 flex-1 items-center justify-center",c[o]),children:"year"===d?e("span",{className:i("flex items-center font-medium tabular-nums text-(--neba-fg)",l[o],s[o]),children:`${Y}–${Y+j-1}`}):"month"===d?k:t(n,D?{children:[P,k]}:{children:[k,P]})}),S(1,b)]})}export function Calendar({size:n,color:r,locale:a,weekStartsOn:l,month:s,onMonthChange:u,selected:d,rangeStart:m=null,rangeEnd:h=null,onSelect:g,onPreviewChange:p,minDate:v,maxDate:x,shouldDisableDate:y,showOutsideDays:D=!0,autoFocus:P=!1,showPreviousButton:C=!0,showNextButton:A=!0,labels:F,className:E}){const[T,B]=o.useState("day"),H=o.useMemo(()=>d.filter(S),[d]),[L,K]=o.useState(()=>{const e=H.find(e=>N(e,s));return e?k(e):N(z(),s)?z():Y(s)}),O=o.useRef(P),_=o.useRef(null);o.useEffect(()=>{K(e=>N(e,s)?e:Y(s))},[s]),o.useLayoutEffect(()=>{O.current&&(O.current=!1,_.current?.querySelector('[data-focus-target="true"]')?.focus({preventScroll:!0}))});const V=o.useCallback(e=>w(e,v,x)||(y?.(e)??!1),[v,x,y]),G=e=>{O.current=!0,B(e)},J=e=>{O.current=!0,u(e)};return t("div",{ref:_,className:i("flex flex-col",c[n],E),style:{"--n-cell":R[n]},onPointerLeave:()=>p?.(null),children:[e(U,{size:n,color:r,view:T,month:s,locale:a,labels:F,showPreviousButton:C,showNextButton:A,onStep:e=>{u("day"===T?f(s,e):b(s,"month"===T?e:e*j))},onViewChange:G}),e("div",{className:"h-[calc(var(--n-cell)*7)] w-[calc(var(--n-cell)*7)]",children:"day"===T?e(q,{size:n,locale:a,weekStartsOn:l,month:s,chosen:H,rangeStart:m,rangeEnd:h,focusedDate:L,showOutsideDays:D,isDisabled:V,onSelect:e=>{K(e),g(e)},onPreviewChange:p,onMoveFocus:e=>{O.current=!0,K(e),N(e,s)||u(Y(e))}}):"month"===T?e(I,{size:n,locale:a,month:s,chosen:H,minDate:v,maxDate:x,onMoveCursor:J,onPick:e=>{u(M(s.getFullYear(),e,1)),G("day")}}):e($,{size:n,month:s,chosen:H,minDate:v,maxDate:x,onMoveCursor:J,onPick:e=>{u(M(e,s.getMonth(),1)),G("month")}})})]})}function q({size:n,locale:o,weekStartsOn:r,month:a,chosen:l,rangeStart:c,rangeEnd:d,focusedDate:m,showOutsideDays:h,isDisabled:b,onSelect:x,onPreviewChange:w,onMoveFocus:y}){const M=p(a,r),P=A(o,r,"short"),C=A(o,r,"long"),k=T(o,{dateStyle:"full"}),Y=(j=d,S(F=c)&&S(j)?v(F,j)<=0?[F,j]:[j,F]:null);var F,j;const E=z();return t("div",{role:"grid",className:"flex h-full flex-col",children:[e("div",{role:"row",className:"grid grid-cols-7",children:P.map((t,o)=>e("span",{role:"columnheader","aria-label":C[o],className:i("flex h-(--n-cell) items-center justify-center font-medium text-(--neba-muted-fg) select-none",u[n]),children:t},o))}),M.map((t,o)=>e("div",{role:"row",className:"grid grid-cols-7",children:t.map(t=>{const o=!N(t,a);if(o&&!h)return e("span",{role:"gridcell","aria-hidden":"true",className:"size-(--n-cell)"},t.getTime());const c=l.some(e=>D(e,t)),u=null!==Y&&v(t,Y[0])>=0&&v(t,Y[1])<=0,d=null!==Y&&u&&D(t,Y[0]),p=null!==Y&&u&&D(t,Y[1]);return e(O,{size:n,label:k.format(t),selected:c,inRange:u&&!c,rangeEdge:u?d&&p?"both":d?"start":p?"end":"middle":null,current:D(t,E)&&!c,muted:o,disabled:b(t),focused:D(t,m),className:i("size-(--n-cell)",s[n]),onClick:()=>x(t),onPointerEnter:()=>w?.(t),onKeyDown:e=>((e,t)=>{const n=(t.getDay()-r+7)%7,o={ArrowLeft:()=>g(t,-1),ArrowRight:()=>g(t,1),ArrowUp:()=>g(t,-7),ArrowDown:()=>g(t,7),Home:()=>g(t,-n),End:()=>g(t,6-n),PageUp:()=>f(t,e.shiftKey?-12:-1),PageDown:()=>f(t,e.shiftKey?12:1)}[e.key];o&&(e.preventDefault(),y(o()))})(e,t),children:t.getDate()},t.getTime())})},o))]})}function I({size:t,locale:n,month:o,chosen:r,minDate:a,maxDate:l,onMoveCursor:c,onPick:u}){const d=C(n,"short"),m=C(n,"long"),h=o.getFullYear(),g=new Date,b=e=>{const t={ArrowLeft:-1,ArrowRight:1,ArrowUp:-3,ArrowDown:3,PageUp:-12,PageDown:12}[e.key];void 0!==t&&(e.preventDefault(),c(f(Y(o),t)))};return e("div",{role:"grid",className:"flex h-full flex-col justify-evenly",children:[0,1,2,3].map(n=>e("div",{role:"row",className:"grid grid-cols-3 gap-1",children:[0,1,2].map(c=>{const f=3*n+c,p=M(h,f,1),w=M(h,f,x(h,f));return e(O,{size:t,label:`${m[f]} ${h}`,selected:r.some(e=>e.getFullYear()===h&&e.getMonth()===f),current:g.getFullYear()===h&&g.getMonth()===f,disabled:S(a)&&v(w,a)<0||S(l)&&v(p,l)>0,focused:f===o.getMonth(),className:i("h-(--n-cell) w-full",s[t]),onClick:()=>u(f),onKeyDown:b,children:d[f]},f)})},n))})}function $({size:t,month:n,chosen:o,minDate:r,maxDate:a,onMoveCursor:l,onPick:c}){const u=E(n.getFullYear()),d=(new Date).getFullYear(),m=e=>{const t={ArrowLeft:-1,ArrowRight:1,ArrowUp:-4,ArrowDown:4,PageUp:-j,PageDown:j}[e.key];void 0!==t&&(e.preventDefault(),l(b(Y(n),t)))};return e("div",{role:"grid",className:"flex h-full flex-col justify-evenly",children:[0,1,2].map(l=>e("div",{role:"row",className:"grid grid-cols-4 gap-1",children:[0,1,2,3].map(h=>{const g=u+4*l+h;return e(O,{size:t,label:String(g),selected:o.some(e=>e.getFullYear()===g),current:g===d,disabled:S(r)&&g<r.getFullYear()||S(a)&&g>a.getFullYear(),focused:g===n.getFullYear(),className:i("h-(--n-cell) w-full",s[t]),onClick:()=>c(g),onKeyDown:m,children:g},g)})},l))})}function _(e){const t=e.parentElement;if(!t)return;const n=e.getBoundingClientRect(),o=t.getBoundingClientRect(),r=n.top-o.top-t.clientTop+t.scrollTop,a=r+n.height;r<t.scrollTop?t.scrollTop=r:a>t.scrollTop+t.clientHeight&&(t.scrollTop=a-t.clientHeight)}export function TimeGrid({size:n,density:r,locale:a,value:c,referenceDate:u,onChange:d,hour12:h,showSeconds:g,hourStep:f,minuteStep:b,secondStep:p,shouldDisableTime:v,autoFocus:x=!1,labels:w,className:y}){const D=c??u,N=o.useRef(null),[S,M]=o.useMemo(()=>P(a),[a]);o.useEffect(()=>{const e=N.current;if(e?.querySelectorAll('[data-chosen="true"]').forEach(_),x){const t=e?.querySelector('[role="listbox"]');(t?.querySelector('[data-chosen="true"]')??t?.querySelector('[role="option"]'))?.focus({preventScroll:!0})}},[x]);const C=o.useMemo(()=>{const e=Math.ceil((h?12:24)/f),t=Array.from({length:e},(e,t)=>t*f);return h?t.map(e=>0===e?12:e):t},[h,f]),k=o.useMemo(()=>Array.from({length:Math.ceil(60/b)},(e,t)=>t*b),[b]),Y=o.useMemo(()=>Array.from({length:Math.ceil(60/p)},(e,t)=>t*p),[p]),z=e=>String(e).padStart(2,"0"),A=h?D.getHours()%12||12:D.getHours(),j=(t,o,r,a,u)=>e("div",{role:"listbox","aria-label":o,className:i("flex flex-col gap-0.5 overflow-y-auto overscroll-contain","h-[calc(var(--n-cell)*7)] w-[calc(var(--n-cell)*2)]","scroll-py-0.5 [scrollbar-width:thin]"),children:r.map(o=>{const r=((e,t)=>F(D,"hour"===e?{hours:h?t%12+(D.getHours()>=12?12:0):t}:"minute"===e?{minutes:t}:"second"===e?{seconds:t}:{hours:D.getHours()%12+12*t}))(t,o),m=null!==c&&a(o),g=v?.(r,t)??!1;return e("button",{type:"button",role:"option","aria-selected":m,"aria-disabled":g||void 0,"data-chosen":m?"true":void 0,className:i(K,B[n],l[n],s[n],"w-full shrink-0",g?"cursor-not-allowed text-(--neba-disabled-fg)":m?"cursor-pointer bg-(--n-fill) font-semibold text-(--n-on-solid) hover:bg-(--n-fill-hover) active:bg-(--n-fill-active)":"cursor-pointer text-(--neba-fg) hover:bg-(--n-soft) active:bg-(--n-soft-press)"),onClick:()=>{g||d(r)},children:u(o)},o)})},t);return t("div",{ref:N,className:i("flex","compact"===r?"gap-0.5":"gap-1",y),style:{"--n-cell":R[n]},children:[j("hour",w.hour,C,e=>e===A,e=>h?String(e):z(e)),j("minute",w.minute,k,e=>e===D.getMinutes(),z),g?j("second",w.second,Y,e=>e===D.getSeconds(),z):null,h?j("meridiem",w.meridiem,[0,1],e=>(D.getHours()>=12?1:0)===e,e=>0===e?S:M):null,e("span",{className:m,"aria-live":"polite",children:null===c?"":T(a,{hour:"numeric",minute:"2-digit",...g?{second:"2-digit"}:{}}).format(c)})]})}
@@ -202,6 +202,23 @@ interface TooltipProps {
202
202
  * and then flickers.
203
203
  */
204
204
  declare function ChartTooltipPanel({ heading, items, x, y, flip, size }: TooltipProps): React.JSX.Element;
205
+ /**
206
+ * The same reading, said out loud rather than drawn.
207
+ *
208
+ * It cannot be the panel above, and that is not a preference. The panel is
209
+ * drawn inside the element carrying `role="img"`, and `img` is a leaf role:
210
+ * everything under it is cut out of the accessibility tree, so a live region
211
+ * in there announces to nobody. This is a *sibling* of the picture, clipped
212
+ * instead of painted, and it is what makes the arrow keys mean something to a
213
+ * reader who is not looking at the plot.
214
+ *
215
+ * Empty when nothing is active, so leaving the chart clears what was said
216
+ * rather than leaving the last column standing in the region forever.
217
+ */
218
+ declare function ChartStatus({ heading, items }: {
219
+ heading?: React.ReactNode;
220
+ items: readonly ChartTooltipItem[];
221
+ }): React.JSX.Element;
205
222
  interface DataTableProps {
206
223
  id: string;
207
224
  caption?: string;
@@ -405,5 +422,5 @@ interface CartesianProps extends CartesianChartProps {
405
422
  * component never has to know which way round the axes are.
406
423
  */
407
424
  export declare function CartesianChart({ series, categories, xAxis, yAxis, horizontal, stacked, includeZero, bandRatio, inset, headroom, markInset, xScale, marks, markRadius, table, swatch, scale: givenScale, markTooltip, height, format, locale, label, legend, tooltip, empty, size, variant, padded, className, children, ...box }: CartesianProps): React.JSX.Element;
408
- export { ChartDataTable, ChartLegendBar, ChartScaleLegend, ChartSurface, ChartTooltipPanel, useMeasuredWidth, useVisibility };
425
+ export { ChartDataTable, ChartLegendBar, ChartScaleLegend, ChartStatus, ChartSurface, ChartTooltipPanel, useMeasuredWidth, useVisibility };
409
426
  export type { Visibility };
@@ -1 +1 @@
1
- import{jsx as e,Fragment as t,jsxs as n}from"react/jsx-runtime";import*as a from"react";import{Box as l}from"../components/box/Box.js";import{bandScale as i,categoryAt as r,categoryCount as s,categoryExtent as o,chartFontSizes as c,compactNumber as d,extentOf as u,fitsLast as h,formatCategory as m,markerRadii as f,plotHeights as x,seriesColor as p,showsTick as g,textWidth as b,tickStride as v,toValues as y,truncate as k,valueScale as w}from"./chart.js";import{numberFormatter as M}from"./format.js";import{emptyMessages as N,useMessages as z}from"./i18n.js";import{cx as S,metaTextClasses as C,srOnlyClasses as A,transitionClasses as P}from"./styles.js";const j="undefined"==typeof document?a.useEffect:a.useLayoutEffect,W=[];function B(e){const[t,n]=a.useState(0);return j(()=>{const t=e.current;if(!t)return;const a=()=>n(t.clientWidth);if(a(),"undefined"==typeof ResizeObserver)return;const l=new ResizeObserver(a);return l.observe(t),()=>l.disconnect()},[e]),t}function R(e){const[t,n]=a.useState(()=>{const t=new Set;return e.forEach((e,n)=>{e.hidden&&t.add(n)}),t}),[l,i]=a.useState(null),r=a.useCallback(e=>{n(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);return{visible:e.map((e,n)=>!t.has(n)),hovered:l,toggle:r,setHovered:i}}const F={top:"flex-col-reverse",bottom:"flex-col",left:"flex-row-reverse",right:"flex-row"},E={start:"justify-start",center:"justify-center",end:"justify-end"};function H({series:a,colors:l,options:i,visibility:r,size:s,values:o,swatch:c}){const d=!1!==i.interactive,u="left"===i.side||"right"===i.side;return e("ul",{className:S("flex list-none flex-wrap items-center gap-x-3 gap-y-1 p-0",u?"min-w-0 flex-col items-start":"",E[i.align??"center"],C[s]),children:a.map((a,i)=>{const s=r.visible[i],u=null!==r.hovered&&r.hovered!==i,h=a.name??`${i+1}`,m=s?l[i]:"var(--neba-disabled-fg)",f=n(t,{children:[e("span",c?{"aria-hidden":"true",className:"flex size-2.5 shrink-0 items-center justify-center",children:c(i,m)}:{"aria-hidden":"true",className:"size-2.5 shrink-0 rounded-[0.1875rem]",style:{backgroundColor:m}}),e("span",{className:"min-w-0 truncate",children:h}),o?.[i]?e("span",{className:"shrink-0 tabular-nums text-(--neba-muted-fg)",children:o[i]}):null]});return e("li",{className:"min-w-0",children:d?e("button",{type:"button","aria-pressed":s,onClick:()=>r.toggle(i),onPointerEnter:()=>r.setHovered(i),onPointerLeave:()=>r.setHovered(null),onFocus:()=>r.setHovered(i),onBlur:()=>r.setHovered(null),className:S("flex min-w-0 cursor-pointer items-center gap-1.5 rounded-(--neba-radius-xs)","px-1 py-0.5 text-(--neba-fg)",P,"hover:bg-(--n-soft)","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-1",s?"":"text-(--neba-disabled-fg)",u?"opacity-55":""),children:f}):e("span",{className:S("flex min-w-0 items-center gap-1.5 px-1 py-0.5 text-(--neba-fg)",s?"":"text-(--neba-disabled-fg)"),children:f})},a.name??i)})})}function I({steps:a,from:l,to:i,middle:r,align:s,vertical:o,size:c}){return e("div",{className:S("flex",o?"":E[s]),children:n("div",{className:S("grid grid-cols-[auto_auto_auto] items-center gap-x-2",C[c]),children:[e("span",{className:"shrink-0 tabular-nums text-(--neba-muted-fg)",children:l}),e("span",{"aria-hidden":"true",className:S("flex h-2.5 overflow-hidden rounded-[0.1875rem]",o?"w-20":"w-24"),children:a.map(t=>e("span",{className:"h-full flex-1",style:{backgroundColor:t}},t))}),e("span",{className:"shrink-0 tabular-nums text-(--neba-muted-fg)",children:i}),r?n(t,{children:[e("span",{}),e("span",{className:"text-center tabular-nums text-(--neba-muted-fg)",children:r}),e("span",{})]}):null]})})}function _({heading:t,items:a,x:l,y:i,flip:r,size:s}){return n("div",{role:"status","aria-live":"polite",className:S("pointer-events-none absolute z-10 max-w-56 min-w-24","rounded-(--neba-radius-sm) border p-2","[background-image:var(--neba-grain),var(--neba-sheen)]","[background-blend-mode:overlay,normal] [backdrop-filter:var(--neba-blur)]","bg-(--neba-panel-press) [border-color:var(--n-line)]","[box-shadow:var(--neba-shadow-2),var(--neba-plate-glass)]",C[s]),style:r?{right:`calc(100% - ${l}px + 10px)`,top:i}:{left:l+10,top:i},children:[e("div",{className:"mb-1 font-medium text-(--neba-fg)",children:t}),e("ul",{className:"flex list-none flex-col gap-0.5 p-0",children:a.map(t=>n("li",{className:"flex items-center gap-1.5",children:[e("span",{"aria-hidden":"true",className:"size-2 shrink-0 rounded-[0.125rem]",style:{backgroundColor:t.color}}),t.name?e("span",{className:"min-w-0 flex-1 truncate text-(--neba-muted-fg)",children:t.name}):null,e("span",{className:"ms-auto shrink-0 font-medium tabular-nums text-(--neba-fg)",children:t.label??t.formatted})]},t.seriesIndex))})]})}function T({id:t,caption:a,corner:l,categories:i,series:r,values:s,format:o,locale:c}){return n("table",{id:t,className:A,children:[a?e("caption",{children:a}):null,e("thead",{children:n("tr",{children:[e("th",{scope:"col",children:l??""}),r.map((t,n)=>e("th",{scope:"col",children:t.name??n+1},t.name??n))]})}),e("tbody",{children:i.map((t,a)=>n("tr",{children:[e("th",{scope:"row",children:m(t,c)}),r.map((t,n)=>{const l=s[n]?.[a];return e("td",void 0!==l?.label?{children:l.label}:{children:null==l?.value?"":o(l.value)},t.name??n)})]},a))})]})}function $({legend:t,legendSide:a,children:i,table:r,className:s,...o}){return n(l,{...o,className:S("relative flex gap-3",F[a],s??void 0),children:[e("div",{className:"relative min-w-0 flex-1",children:i}),t,r]})}export function CartesianChart({series:t,categories:l,xAxis:h,yAxis:g,horizontal:v=!1,stacked:A=!1,includeZero:P=!0,bandRatio:j=1,inset:F=!1,headroom:E=0,markInset:I=0,xScale:V="band",marks:D,markRadius:X=24,table:Y,swatch:Z,scale:O,markTooltip:K,height:U,format:q,locale:G,label:J,legend:Q,tooltip:ee,empty:te,size:ne="md",variant:ae="text",padded:le=!1,className:ie,children:re,...se}){const oe=a.useRef(null),ce=B(oe),de=z(N,G),ue=a.useId(),he=R(t),[me,fe]=a.useState(null),[xe,pe]=a.useState(null),[ge,be]=a.useState(null),ve=a.useCallback(e=>q?M(G,q).format(e):d(e,G),[q,G]),ye=a.useMemo(()=>y(t),[t]),ke=a.useMemo(()=>t.map((e,t)=>p(e,t)),[t]),we=s(t),Me=a.useMemo(()=>Array.from({length:we},(e,t)=>r(t,l,ye)),[we,l,ye]),Ne=ye.filter((e,t)=>he.visible[t]),ze=u(Ne,A),Se="number"==typeof U?U:void 0===U?x[ne]:null,Ce=c[ne],Ae=g,Pe=h,je=O??w(ze,{min:Ae?.min,max:Ae?.max,tickCount:Ae?.tickCount,includeZero:P}),We="value"===V?o(Ne,l):null,Be="value"===V?w(We,{min:Pe?.min,max:Pe?.max,tickCount:Pe?.tickCount,includeZero:!1}):null,Re=je.ticks.map((e,t)=>Ae?.tickFormat?String(Ae.tickFormat(e,t)):ve(e)),Fe=Be?Be.ticks.map((e,t)=>Pe?.tickFormat?String(Pe.tickFormat(e,t)):d(e,G)):Me.map((e,t)=>Pe?.tickFormat?String(Pe.tickFormat(e,t)):m(e,G)),Ee=Re.reduce((e,t)=>Math.max(e,b(t,Ce)),0),He=Ce+6,Ie=Ae?.hidden?0:Ee+10+(Ae?.label?He:0),_e=(ce-(v?0:Ie)-16)/Math.max(1,we),Te=Be?Fe:v||_e-6>=2.4*Ce?Fe.map(e=>k(e,v?150:_e-6,Ce)):Fe,$e=Te.reduce((e,t)=>Math.max(e,b(t,Ce)),0),Le=v?Pe?.hidden?0:$e+10+(Pe?.label?He:0):Ie,Ve=v?Ae?.hidden?0:Ce+12+(Ae?.label?He:0):Pe?.hidden?0:Ce+12+(Pe?.label?He:0),De=(v?Pe:Ae)?.thickness??Le,Xe=(v?Ae:Pe)?.thickness??Ve,Ye=(v||Be?12:Math.max(8,Te.length?$e/2:8))+I,Ze=f[ne]+4+E+I,Oe=Se??0,Ke={left:De+I,top:Ze,width:Math.max(0,ce-De-I-Ye),height:Math.max(0,Oe-Ze-Xe-I)},Ue=v?Ke.height:Ke.width,qe=i(F?Math.max(1,we-1):we,Ue,j),Ge=a.useCallback(e=>F?we<=1?Ue/2:Ue*e/(we-1):qe.centre(e),[F,we,Ue,qe]),Je=a.useCallback(e=>v?Ke.left+je.fraction(e)*Ke.width:Ke.top+(1-je.fraction(e))*Ke.height,[v,Ke.left,Ke.top,Ke.width,Ke.height,je]),Qe=a.useCallback((e,t)=>v?{x:Je(t),y:Ke.top+Ge(e)}:{x:Ke.left+Ge(e),y:Je(t)},[v,Je,Ge,Ke.left,Ke.top]),et=a.useCallback(e=>v?Ke.top+(1-(Be?.fraction(e)??0))*Ke.height:Ke.left+(Be?.fraction(e)??0)*Ke.width,[v,Ke.left,Ke.top,Ke.width,Ke.height,Be]),tt=Je(Math.min(Math.max(0,je.min),je.max)),nt={plot:Ke,values:ye,visible:he.visible,colors:ke,scale:je,band:qe,horizontal:v,valuePx:Je,categoryPx:Ge,point:Qe,categoryScale:Be,categoryValuePx:et,zeroPx:tt,categories:Me,format:ve,size:ne},at=D?D(nt):W,lt=!1===ee?{mode:"none"}:!0===ee||void 0===ee?{}:ee,it=lt.mode??(D?"item":"index"),rt=null===xe?null:at[xe]??null,st=D?rt?rt.index:null:me,ot=D?at.length:we,ct=()=>{fe(null),pe(null),be(null)},dt=e=>{const t=null===e?null:Math.min(ot-1,Math.max(0,e));D?pe(t):fe(t)},ut=e=>{be(null);dt(((D?xe:me)??(e>0?-1:ot))+e)},ht=null===st?[]:t.flatMap((e,t)=>{if(!he.visible[t]||rt&&rt.series!==t)return[];const n=ye[t]?.[st];return n&&null!==n.value?[{seriesIndex:t,name:e.name,color:n.color??ke[t],value:n.value,formatted:ve(n.value),label:n.label}]:[]}),mt=rt&&K?K(rt):null,ft=mt?mt.items:"item"===it&&ht.length>1&&null!==ge?[ht.reduce((e,t)=>Math.abs(Je(t.value??0)-ge)<Math.abs(Je(e.value??0)-ge)?t:e)]:ht,xt=rt?ye[rt.series]?.[rt.index]?.x??l?.[rt.index]??rt.index:void 0,pt=rt?rt.x:v?Je(ft[0]?.value??0):Ke.left+Ge(st??0),gt=rt?rt.y:v?Ke.top+Ge(st??0):Ke.top,bt=rt?(rt.x-Ke.left)/Math.max(1,Ke.width)>.6:(v?je.fraction(ft[0]?.value??0):Ge(st??0)/Math.max(1,Ue))>.6,vt=!1===Q?{interactive:!1}:!0===Q||void 0===Q?{}:Q,yt=!0===Q||!1!==Q&&t.length>1,kt=vt.side??"bottom",wt={...nt,hovered:he.hovered,activeIndex:st,marks:at,activeMark:rt},Mt=0===we||null===ze||"value"===V&&null===We;return e($,{...se,size:ne,variant:ae,padded:le,className:ie,legendSide:kt,legend:yt?e(H,{series:t,colors:ke,options:vt,visibility:he,size:ne,swatch:Z,values:vt.showValue&&null!==st?t.map((e,t)=>{const n=ye[t]?.[st]?.value;return null==n?void 0:ve(n)}):void 0}):null,table:Mt?null:Y?.(ue)??e(T,{id:ue,caption:J,corner:Pe?.label,categories:Me,series:t,values:ye,format:ve,locale:G}),children:n("div",{ref:oe,role:"img",tabIndex:Mt?void 0:0,"aria-label":J,"aria-describedby":Mt?void 0:ue,onPointerMove:e=>{"none"!==it&&(D?pe(((e,t)=>{const n=oe.current;if(!n||0===at.length)return null;const a=n.getBoundingClientRect(),l=e-a.left,i=t-a.top;let r=null,s=1/0,o=1/0;return at.forEach((e,t)=>{const n=Math.hypot(e.x-l,e.y-i),a=void 0===e.rx?Math.max(0,n-e.r):Math.hypot(Math.max(0,Math.abs(e.x-l)-e.rx),Math.max(0,Math.abs(e.y-i)-(e.ry??e.rx)));a<=X&&(a<s||a===s&&n<o)&&(s=a,o=n,r=t)}),r})(e.clientX,e.clientY)):fe(((e,t)=>{const n=oe.current;if(!n||0===we)return null;const a=n.getBoundingClientRect(),l=v?t-a.top-Ke.top:e-a.left-Ke.left;if(l<-qe.step||l>Ue+qe.step)return null;const i=F?we<=1?0:Math.round(l/Ue*(we-1)):Math.floor(l/qe.step);return Math.min(we-1,Math.max(0,i))})(e.clientX,e.clientY)),"item"===it&&be(((e,t)=>{const n=oe.current;if(!n)return null;const a=n.getBoundingClientRect();return v?e-a.left:t-a.top})(e.clientX,e.clientY)))},onPointerLeave:ct,onKeyDown:"none"===it?void 0:e=>{const t=v?"ArrowDown":"ArrowRight",n=v?"ArrowUp":"ArrowLeft";if(e.key===t)ut(1);else if(e.key===n)ut(-1);else if("Home"===e.key)dt(0);else if("End"===e.key)dt(ot-1);else{if("Escape"!==e.key)return;ct()}e.preventDefault()},onBlur:ct,className:S("relative w-full","rounded-(--neba-radius-xs)","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-2"),style:{height:Se??U},children:[Mt?e("div",{className:S("flex h-full items-center justify-center text-(--neba-muted-fg)",C[ne]),children:te??de.title}):ce>0?n("svg",{width:ce,height:Oe||"100%",viewBox:`0 0 ${ce} ${Oe}`,"aria-hidden":"true",className:"block overflow-visible",children:[e(L,{plot:Ke,scale:je,band:qe,horizontal:v,inset:F,categoryPx:Ge,valuePx:Je,tickTexts:Re,categoryTexts:Te,categoryScale:Be,categoryValuePx:et,valueAxis:Ae,categoryAxis:Pe,fontSize:Ce,zeroPx:tt}),null===st||D||"index"!==it||!1===lt.crosshair?null:(()=>{const t=Ge(st);return e("line",v?{x1:Ke.left,x2:Ke.left+Ke.width,y1:Ke.top+t,y2:Ke.top+t,stroke:"var(--neba-chart-baseline)",strokeWidth:1}:{x1:Ke.left+t,x2:Ke.left+t,y1:Ke.top,y2:Ke.top+Ke.height,stroke:"var(--neba-chart-baseline)",strokeWidth:1})})(),re(wt)]}):null,null!==st&&ft.length>0&&"none"!==it?lt.render?e("div",{className:"pointer-events-none absolute z-10",style:bt?{right:`calc(100% - ${pt}px + 10px)`,top:gt}:{left:pt+10,top:gt},children:lt.render({index:st,category:xt??Me[st],items:ft})}):e(_,{heading:mt?mt.heading:m(xt??Me[st],G),items:ft,x:pt,y:gt,flip:bt,size:ne}):null]})})}function L({plot:a,scale:l,horizontal:i,categoryPx:r,valuePx:s,tickTexts:o,categoryTexts:c,categoryScale:d,categoryValuePx:u,valueAxis:m,categoryAxis:f,fontSize:x,zeroPx:p}){const y=!1!==m?.grid&&!m?.hidden,k=!f?.hidden&&(f?.grid??null!==d),w=e=>d?u(d.ticks[e]):(i?a.top:a.left)+r(e),M=v(c.length,i?a.height:a.width,i?1.8*x:Math.max(...c.map(e=>b(e,x)),1)+12),N=v(l.ticks.length,i?a.width:a.height,i?Math.max(...o.map(e=>b(e,x)),1)+16:2*x),z=c.length>1?Math.abs(w(1)-w(0)):a.width,S=l.ticks.length>1?Math.abs(s(l.ticks[1])-s(l.ticks[0])):a.height,C=h(c.length,M,z,i?1.8*x:b(c[c.length-1]??"",x)),A=h(l.ticks.length,N,S,i?b(o[o.length-1]??"",x):1.6*x);return n("g",{children:[l.ticks.map((t,r)=>{const c=s(t),d=Math.abs(t)<1e-9;return n("g",{children:[y?e("line",i?{x1:c,x2:c,y1:a.top,y2:a.top+a.height,stroke:d?"var(--neba-chart-baseline)":"var(--neba-chart-grid)",strokeWidth:1}:{x1:a.left,x2:a.left+a.width,y1:c,y2:c,stroke:d?"var(--neba-chart-baseline)":"var(--neba-chart-grid)",strokeWidth:1}):null,m?.hidden||!g(r,l.ticks.length,N,A)?null:e("text",i?{x:c,y:a.top+a.height+x+6,textAnchor:0===r?"start":r===l.ticks.length-1?"end":"middle",fontSize:x,fill:"var(--neba-muted-fg)",className:"tabular-nums",children:o[r]}:{x:a.left-8,y:c,textAnchor:"end",dominantBaseline:"central",fontSize:x,fill:"var(--neba-muted-fg)",className:"tabular-nums",children:o[r]})]},t)}),f?.hidden?null:n(t,{children:[e("line",i?{x1:p,x2:p,y1:a.top,y2:a.top+a.height,stroke:"var(--neba-chart-axis)",strokeWidth:1}:{x1:a.left,x2:a.left+a.width,y1:p,y2:p,stroke:"var(--neba-chart-axis)",strokeWidth:1}),c.map((t,l)=>{const r=w(l),s=g(l,c.length,M,C);return i?s?e("text",{x:a.left-8,y:r,textAnchor:"end",dominantBaseline:"central",fontSize:x,fill:"var(--neba-muted-fg)",className:d?"tabular-nums":void 0,children:t},l):null:n("g",{children:[k?e("line",{x1:r,x2:r,y1:a.top,y2:a.top+a.height,stroke:"var(--neba-chart-grid)",strokeWidth:1}):null,s?e("text",{x:r,y:a.top+a.height+x+6,textAnchor:d?0===l?"start":l===c.length-1?"end":"middle":"middle",fontSize:x,fill:"var(--neba-muted-fg)",className:d?"tabular-nums":void 0,children:t}):null]},l)})]}),m?.label?e("text",{x:i?a.left+a.width:a.left,y:i?a.top+a.height+2*x+12:a.top-8,textAnchor:i?"end":"start",fontSize:x,fill:"var(--neba-muted-fg)",fontWeight:500,children:m.label}):null,f?.label&&!i?e("text",{x:a.left+a.width,y:a.top+a.height+2*x+12,textAnchor:"end",fontSize:x,fill:"var(--neba-muted-fg)",fontWeight:500,children:f.label}):null]})}export{T as ChartDataTable,H as ChartLegendBar,I as ChartScaleLegend,$ as ChartSurface,_ as ChartTooltipPanel,B as useMeasuredWidth,R as useVisibility};
1
+ "use client";import{jsx as e,Fragment as t,jsxs as n}from"react/jsx-runtime";import*as l from"react";import{Box as a}from"../components/box/Box.js";import{bandScale as i,categoryAt as r,categoryCount as s,categoryExtent as o,chartFontSizes as c,compactNumber as d,extentOf as u,fitsLast as h,formatCategory as m,markerRadii as f,plotHeights as x,seriesColor as g,showsTick as p,textWidth as b,tickStride as v,toValues as y,truncate as k,valueScale as w}from"./chart.js";import{numberFormatter as M}from"./format.js";import{observeResize as N}from"./observe.js";import{chartMessages as z,emptyMessages as S,useMessages as C}from"./i18n.js";import{cx as A,hasContent as P,metaTextClasses as j,srOnlyClasses as W,transitionClasses as B}from"./styles.js";const F="undefined"==typeof document?l.useEffect:l.useLayoutEffect,E=[];function I(e){const[t,n]=l.useState(0);return F(()=>{const t=e.current;if(!t)return;const l=()=>n(t.clientWidth);return l(),N(t,l)},[e]),t}function R(e){const[t,n]=l.useState(()=>{const t=new Set;return e.forEach((e,n)=>{e.hidden&&t.add(n)}),t}),[a,i]=l.useState(null),r=l.useCallback(e=>{n(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);return{visible:e.map((e,n)=>!t.has(n)),hovered:a,toggle:r,setHovered:i}}const H={top:"flex-col-reverse",bottom:"flex-col",left:"flex-row-reverse",right:"flex-row"},$={start:"justify-start",center:"justify-center",end:"justify-end"};function _({series:l,colors:a,options:i,visibility:r,size:s,values:o,swatch:c}){const d=!1!==i.interactive,u="left"===i.side||"right"===i.side;return e("ul",{className:A("flex list-none flex-wrap items-center gap-x-3 gap-y-1 p-0",u?"min-w-0 flex-col items-start":"",$[i.align??"center"],j[s]),children:l.map((l,i)=>{const s=r.visible[i],u=null!==r.hovered&&r.hovered!==i,h=l.name??`${i+1}`,m=s?a[i]:"var(--neba-disabled-fg)",f=n(t,{children:[e("span",c?{"aria-hidden":"true",className:"flex size-2.5 shrink-0 items-center justify-center",children:c(i,m)}:{"aria-hidden":"true",className:"size-2.5 shrink-0 rounded-[0.1875rem]",style:{backgroundColor:m}}),e("span",{className:"min-w-0 truncate",children:h}),o?.[i]?e("span",{className:"shrink-0 tabular-nums text-(--neba-muted-fg)",children:o[i]}):null]});return e("li",{className:"min-w-0",children:d?e("button",{type:"button","aria-pressed":s,onClick:()=>r.toggle(i),onPointerEnter:()=>r.setHovered(i),onPointerLeave:()=>r.setHovered(null),onFocus:()=>r.setHovered(i),onBlur:()=>r.setHovered(null),className:A("flex min-w-0 cursor-pointer items-center gap-1.5 rounded-(--neba-radius-xs)","px-1 py-0.5 text-(--neba-fg)",B,"hover:bg-(--n-soft)","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-1",s?"":"text-(--neba-disabled-fg)",u?"opacity-55":""),children:f}):e("span",{className:A("flex min-w-0 items-center gap-1.5 px-1 py-0.5 text-(--neba-fg)",s?"":"text-(--neba-disabled-fg)"),children:f})},l.name??i)})})}function T({steps:l,from:a,to:i,middle:r,align:s,vertical:o,size:c}){return e("div",{className:A("flex",o?"":$[s]),children:n("div",{className:A("grid grid-cols-[auto_auto_auto] items-center gap-x-2",j[c]),children:[e("span",{className:"shrink-0 tabular-nums text-(--neba-muted-fg)",children:a}),e("span",{"aria-hidden":"true",className:A("flex h-2.5 overflow-hidden rounded-[0.1875rem]",o?"w-20":"w-24"),children:l.map(t=>e("span",{className:"h-full flex-1",style:{backgroundColor:t}},t))}),e("span",{className:"shrink-0 tabular-nums text-(--neba-muted-fg)",children:i}),r?n(t,{children:[e("span",{}),e("span",{className:"text-center tabular-nums text-(--neba-muted-fg)",children:r}),e("span",{})]}):null]})})}function L({heading:t,items:l,x:a,y:i,flip:r,size:s}){return n("div",{"data-neba-tooltip":"",className:A("pointer-events-none absolute z-10 max-w-56 min-w-24","rounded-(--neba-radius-sm) border p-2","[background-image:var(--neba-grain),var(--neba-sheen)]","[background-blend-mode:overlay,normal] [backdrop-filter:var(--neba-blur)]","bg-(--neba-panel-press) [border-color:var(--n-line)]","[box-shadow:var(--neba-shadow-2),var(--neba-plate-glass)]",j[s]),style:r?{right:`calc(100% - ${a}px + 10px)`,top:i}:{left:a+10,top:i},children:[e("div",{className:"mb-1 font-medium text-(--neba-fg)",children:t}),e("ul",{className:"flex list-none flex-col gap-0.5 p-0",children:l.map(t=>n("li",{className:"flex items-center gap-1.5",children:[e("span",{"aria-hidden":"true",className:"size-2 shrink-0 rounded-[0.125rem]",style:{backgroundColor:t.color}}),t.name?e("span",{className:"min-w-0 flex-1 truncate text-(--neba-muted-fg)",children:t.name}):null,e("span",{className:"ms-auto shrink-0 font-medium tabular-nums text-(--neba-fg)",children:t.label??t.formatted})]},t.seriesIndex))})]})}function V({heading:a,items:i}){return e("span",{role:"status","aria-live":"polite",className:W,children:0===i.length?null:n(t,{children:[P(a)?n(t,{children:[a,", "]}):null,i.map((e,t)=>n(l.Fragment,{children:[t>0?", ":null,e.name?`${e.name}: `:null,e.label??e.formatted]},e.seriesIndex))]})})}function D({id:t,caption:l,corner:a,categories:i,series:r,values:s,format:o,locale:c}){return n("table",{id:t,className:W,children:[l?e("caption",{children:l}):null,e("thead",{children:n("tr",{children:[e("th",{scope:"col",children:a??""}),r.map((t,n)=>e("th",{scope:"col",children:t.name??n+1},t.name??n))]})}),e("tbody",{children:i.map((t,l)=>n("tr",{children:[e("th",{scope:"row",children:m(t,c)}),r.map((t,n)=>{const a=s[n]?.[l];return e("td",void 0!==a?.label?{children:a.label}:{children:null==a?.value?"":o(a.value)},t.name??n)})]},l))})]})}function X({legend:t,legendSide:l,children:i,table:r,className:s,...o}){return n(a,{...o,className:A("relative flex gap-3",H[l],s??void 0),children:[e("div",{className:"relative min-w-0 flex-1",children:i}),t,r]})}export function CartesianChart({series:t,categories:a,xAxis:h,yAxis:p,horizontal:v=!1,stacked:N=!1,includeZero:P=!0,bandRatio:W=1,inset:B=!1,headroom:F=0,markInset:H=0,xScale:$="band",marks:T,markRadius:Z=24,table:K,swatch:U,scale:q,markTooltip:G,height:J,format:O,locale:Q,label:ee,legend:te,tooltip:ne,empty:le,size:ae="md",variant:ie="text",padded:re=!1,className:se,children:oe,...ce}){const de=l.useRef(null),ue=I(de),he=C(S,Q),me=C(z,Q),fe=l.useId(),xe=R(t),[ge,pe]=l.useState(null),[be,ve]=l.useState(null),[ye,ke]=l.useState(null),we=l.useCallback(e=>O?M(Q,O).format(e):d(e,Q),[O,Q]),Me=l.useMemo(()=>y(t),[t]),Ne=l.useMemo(()=>t.map((e,t)=>g(e,t)),[t]),ze=s(t),Se=l.useMemo(()=>Array.from({length:ze},(e,t)=>r(t,a,Me)),[ze,a,Me]),Ce=Me.filter((e,t)=>xe.visible[t]),Ae=u(Ce,N),Pe="number"==typeof J?J:void 0===J?x[ae]:null,je=c[ae],We=p,Be=h,Fe=q??w(Ae,{min:We?.min,max:We?.max,tickCount:We?.tickCount,includeZero:P}),Ee="value"===$?o(Ce,a):null,Ie="value"===$?w(Ee,{min:Be?.min,max:Be?.max,tickCount:Be?.tickCount,includeZero:!1}):null,Re=Fe.ticks.map((e,t)=>We?.tickFormat?String(We.tickFormat(e,t)):we(e)),He=Ie?Ie.ticks.map((e,t)=>Be?.tickFormat?String(Be.tickFormat(e,t)):d(e,Q)):Se.map((e,t)=>Be?.tickFormat?String(Be.tickFormat(e,t)):m(e,Q)),$e=Re.reduce((e,t)=>Math.max(e,b(t,je)),0),_e=je+6,Te=We?.hidden?0:$e+10+(We?.label?_e:0),Le=(ue-(v?0:Te)-16)/Math.max(1,ze),Ve=Ie?He:v||Le-6>=2.4*je?He.map(e=>k(e,v?150:Le-6,je)):He,De=Ve.reduce((e,t)=>Math.max(e,b(t,je)),0),Xe=v?Be?.hidden?0:De+10+(Be?.label?_e:0):Te,Ye=v?We?.hidden?0:je+12+(We?.label?_e:0):Be?.hidden?0:je+12+(Be?.label?_e:0),Ze=(v?Be:We)?.thickness??Xe,Ke=(v?We:Be)?.thickness??Ye,Ue=(v||Ie?12:Math.max(8,Ve.length?De/2:8))+H,qe=f[ae]+4+F+H,Ge=Pe??0,Je={left:Ze+H,top:qe,width:Math.max(0,ue-Ze-H-Ue),height:Math.max(0,Ge-qe-Ke-H)},Oe=v?Je.height:Je.width,Qe=i(B?Math.max(1,ze-1):ze,Oe,W),et=l.useCallback(e=>B?ze<=1?Oe/2:Oe*e/(ze-1):Qe.centre(e),[B,ze,Oe,Qe]),tt=l.useCallback(e=>v?Je.left+Fe.fraction(e)*Je.width:Je.top+(1-Fe.fraction(e))*Je.height,[v,Je.left,Je.top,Je.width,Je.height,Fe]),nt=l.useCallback((e,t)=>v?{x:tt(t),y:Je.top+et(e)}:{x:Je.left+et(e),y:tt(t)},[v,tt,et,Je.left,Je.top]),lt=l.useCallback(e=>v?Je.top+(1-(Ie?.fraction(e)??0))*Je.height:Je.left+(Ie?.fraction(e)??0)*Je.width,[v,Je.left,Je.top,Je.width,Je.height,Ie]),at=tt(Math.min(Math.max(0,Fe.min),Fe.max)),it={plot:Je,values:Me,visible:xe.visible,colors:Ne,scale:Fe,band:Qe,horizontal:v,valuePx:tt,categoryPx:et,point:nt,categoryScale:Ie,categoryValuePx:lt,zeroPx:at,categories:Se,format:we,size:ae},rt=T?T(it):E,st=!1===ne?{mode:"none"}:!0===ne||void 0===ne?{}:ne,ot=st.mode??(T?"item":"index"),ct=null===be?null:rt[be]??null,dt=T?ct?ct.index:null:ge,ut=T?rt.length:ze,ht=()=>{pe(null),ve(null),ke(null)},mt=e=>{const t=null===e?null:Math.min(ut-1,Math.max(0,e));T?ve(t):pe(t)},ft=e=>{ke(null);mt(((T?be:ge)??(e>0?-1:ut))+e)},xt=null===dt?[]:t.flatMap((e,t)=>{if(!xe.visible[t]||ct&&ct.series!==t)return[];const n=Me[t]?.[dt];return n&&null!==n.value?[{seriesIndex:t,name:e.name,color:n.color??Ne[t],value:n.value,formatted:we(n.value),label:n.label}]:[]}),gt=ct&&G?G(ct):null,pt=gt?gt.items:"item"===ot&&xt.length>1&&null!==ye?[xt.reduce((e,t)=>Math.abs(tt(t.value??0)-ye)<Math.abs(tt(e.value??0)-ye)?t:e)]:xt,bt=ct?Me[ct.series]?.[ct.index]?.x??a?.[ct.index]??ct.index:void 0,vt=ct?ct.x:v?tt(pt[0]?.value??0):Je.left+et(dt??0),yt=ct?ct.y:v?Je.top+et(dt??0):Je.top,kt=ct?(ct.x-Je.left)/Math.max(1,Je.width)>.6:(v?Fe.fraction(pt[0]?.value??0):et(dt??0)/Math.max(1,Oe))>.6,wt=!1===te?{interactive:!1}:!0===te||void 0===te?{}:te,Mt=!0===te||!1!==te&&t.length>1,Nt=wt.side??"bottom",zt={...it,hovered:xe.hovered,activeIndex:dt,marks:rt,activeMark:ct},St=0===ze||null===Ae||"value"===$&&null===Ee;return n(X,{...ce,size:ae,variant:ie,padded:re,className:se,legendSide:Nt,legend:Mt?e(_,{series:t,colors:Ne,options:wt,visibility:xe,size:ae,swatch:U,values:wt.showValue&&null!==dt?t.map((e,t)=>{const n=Me[t]?.[dt]?.value;return null==n?void 0:we(n)}):void 0}):null,table:St?null:K?.(fe)??e(D,{id:fe,caption:ee,corner:Be?.label,categories:Se,series:t,values:Me,format:we,locale:Q}),children:[n("div",{ref:de,role:"img",tabIndex:St?void 0:0,"aria-label":ee??me.label,"aria-describedby":St?void 0:fe,onPointerMove:e=>{"none"!==ot&&(T?ve(((e,t)=>{const n=de.current;if(!n||0===rt.length)return null;const l=n.getBoundingClientRect(),a=e-l.left,i=t-l.top;let r=null,s=1/0,o=1/0;return rt.forEach((e,t)=>{const n=Math.hypot(e.x-a,e.y-i),l=void 0===e.rx?Math.max(0,n-e.r):Math.hypot(Math.max(0,Math.abs(e.x-a)-e.rx),Math.max(0,Math.abs(e.y-i)-(e.ry??e.rx)));l<=Z&&(l<s||l===s&&n<o)&&(s=l,o=n,r=t)}),r})(e.clientX,e.clientY)):pe(((e,t)=>{const n=de.current;if(!n||0===ze)return null;const l=n.getBoundingClientRect(),a=v?t-l.top-Je.top:e-l.left-Je.left;if(a<-Qe.step||a>Oe+Qe.step)return null;const i=B?ze<=1?0:Math.round(a/Oe*(ze-1)):Math.floor(a/Qe.step);return Math.min(ze-1,Math.max(0,i))})(e.clientX,e.clientY)),"item"===ot&&ke(((e,t)=>{const n=de.current;if(!n)return null;const l=n.getBoundingClientRect();return v?e-l.left:t-l.top})(e.clientX,e.clientY)))},onPointerLeave:ht,onKeyDown:"none"===ot?void 0:e=>{const t=v?"ArrowDown":"ArrowRight",n=v?"ArrowUp":"ArrowLeft";if(e.key===t)ft(1);else if(e.key===n)ft(-1);else if("Home"===e.key)mt(0);else if("End"===e.key)mt(ut-1);else{if("Escape"!==e.key)return;ht()}e.preventDefault()},onBlur:ht,className:A("relative w-full","rounded-(--neba-radius-xs)","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-2"),style:{height:Pe??J},children:[St?e("div",{className:A("flex h-full items-center justify-center text-(--neba-muted-fg)",j[ae]),children:le??he.title}):ue>0?n("svg",{width:ue,height:Ge||"100%",viewBox:`0 0 ${ue} ${Ge}`,"aria-hidden":"true",className:"block overflow-visible",children:[e(Y,{plot:Je,scale:Fe,band:Qe,horizontal:v,inset:B,categoryPx:et,valuePx:tt,tickTexts:Re,categoryTexts:Ve,categoryScale:Ie,categoryValuePx:lt,valueAxis:We,categoryAxis:Be,fontSize:je,zeroPx:at}),null===dt||T||"index"!==ot||!1===st.crosshair?null:(()=>{const t=et(dt);return e("line",v?{x1:Je.left,x2:Je.left+Je.width,y1:Je.top+t,y2:Je.top+t,stroke:"var(--neba-chart-baseline)",strokeWidth:1}:{x1:Je.left+t,x2:Je.left+t,y1:Je.top,y2:Je.top+Je.height,stroke:"var(--neba-chart-baseline)",strokeWidth:1})})(),oe(zt)]}):null,null!==dt&&pt.length>0&&"none"!==ot?st.render?e("div",{className:"pointer-events-none absolute z-10",style:kt?{right:`calc(100% - ${vt}px + 10px)`,top:yt}:{left:vt+10,top:yt},children:st.render({index:dt,category:bt??Se[dt],items:pt})}):e(L,{heading:gt?gt.heading:m(bt??Se[dt],Q),items:pt,x:vt,y:yt,flip:kt,size:ae}):null]}),"none"===ot?null:e(V,{heading:null===dt?void 0:gt?.heading??m(bt??Se[dt],Q),items:pt})]})}function Y({plot:l,scale:a,horizontal:i,categoryPx:r,valuePx:s,tickTexts:o,categoryTexts:c,categoryScale:d,categoryValuePx:u,valueAxis:m,categoryAxis:f,fontSize:x,zeroPx:g}){const y=!1!==m?.grid&&!m?.hidden,k=!f?.hidden&&(f?.grid??null!==d),w=e=>d?u(d.ticks[e]):(i?l.top:l.left)+r(e),M=v(c.length,i?l.height:l.width,i?1.8*x:Math.max(...c.map(e=>b(e,x)),1)+12),N=v(a.ticks.length,i?l.width:l.height,i?Math.max(...o.map(e=>b(e,x)),1)+16:2*x),z=c.length>1?Math.abs(w(1)-w(0)):l.width,S=a.ticks.length>1?Math.abs(s(a.ticks[1])-s(a.ticks[0])):l.height,C=h(c.length,M,z,i?1.8*x:b(c[c.length-1]??"",x)),A=h(a.ticks.length,N,S,i?b(o[o.length-1]??"",x):1.6*x);return n("g",{children:[a.ticks.map((t,r)=>{const c=s(t),d=Math.abs(t)<1e-9;return n("g",{children:[y?e("line",i?{x1:c,x2:c,y1:l.top,y2:l.top+l.height,stroke:d?"var(--neba-chart-baseline)":"var(--neba-chart-grid)",strokeWidth:1}:{x1:l.left,x2:l.left+l.width,y1:c,y2:c,stroke:d?"var(--neba-chart-baseline)":"var(--neba-chart-grid)",strokeWidth:1}):null,m?.hidden||!p(r,a.ticks.length,N,A)?null:e("text",i?{x:c,y:l.top+l.height+x+6,textAnchor:0===r?"start":r===a.ticks.length-1?"end":"middle",fontSize:x,fill:"var(--neba-muted-fg)",className:"tabular-nums",children:o[r]}:{x:l.left-8,y:c,textAnchor:"end",dominantBaseline:"central",fontSize:x,fill:"var(--neba-muted-fg)",className:"tabular-nums",children:o[r]})]},t)}),f?.hidden?null:n(t,{children:[e("line",i?{x1:g,x2:g,y1:l.top,y2:l.top+l.height,stroke:"var(--neba-chart-axis)",strokeWidth:1}:{x1:l.left,x2:l.left+l.width,y1:g,y2:g,stroke:"var(--neba-chart-axis)",strokeWidth:1}),c.map((t,a)=>{const r=w(a),s=p(a,c.length,M,C);return i?s?e("text",{x:l.left-8,y:r,textAnchor:"end",dominantBaseline:"central",fontSize:x,fill:"var(--neba-muted-fg)",className:d?"tabular-nums":void 0,children:t},a):null:n("g",{children:[k?e("line",{x1:r,x2:r,y1:l.top,y2:l.top+l.height,stroke:"var(--neba-chart-grid)",strokeWidth:1}):null,s?e("text",{x:r,y:l.top+l.height+x+6,textAnchor:d?0===a?"start":a===c.length-1?"end":"middle":"middle",fontSize:x,fill:"var(--neba-muted-fg)",className:d?"tabular-nums":void 0,children:t}):null]},a)})]}),m?.label?e("text",{x:i?l.left+l.width:l.left,y:i?l.top+l.height+2*x+12:l.top-8,textAnchor:i?"end":"start",fontSize:x,fill:"var(--neba-muted-fg)",fontWeight:500,children:m.label}):null,f?.label&&!i?e("text",{x:l.left+l.width,y:l.top+l.height+2*x+12,textAnchor:"end",fontSize:x,fill:"var(--neba-muted-fg)",fontWeight:500,children:f.label}):null]})}export{D as ChartDataTable,_ as ChartLegendBar,T as ChartScaleLegend,V as ChartStatus,X as ChartSurface,L as ChartTooltipPanel,I as useMeasuredWidth,R as useVisibility};
@@ -94,20 +94,6 @@ export declare function sortRows<T>(rows: readonly T[], sort: readonly SortEntry
94
94
  * of a two-key sort does not silently make it the first.
95
95
  */
96
96
  export declare function nextSort(current: readonly SortEntry[], key: string, additive: boolean): SortEntry[];
97
- /**
98
- * A cell value as something a query can be matched against.
99
- *
100
- * Case-folded and stripped of combining marks, so `jose` finds `José` and
101
- * `SEOUL` finds `Seoul`. `NFD` splits an accented letter into the letter and
102
- * its accent and the range then deletes the accent; a search field is the one
103
- * place where losing that distinction is the point.
104
- *
105
- * A `Date` is deliberately *not* formatted here. What a reader sees in the cell
106
- * came out of the caller's `render`, and guessing a format the search would
107
- * agree with is how a table ends up not finding a date that is on the screen —
108
- * a column that wants its dates searchable gives them a `value`.
109
- */
110
- export declare function searchText(value: unknown): string;
111
97
  /** Where one page starts and stops, and how many there are. */
112
98
  export interface PageBounds {
113
99
  /** How many pages the rows come to. Never below `1`. */
@@ -1 +1 @@
1
- export const dataRowHeights={default:{xs:24,sm:28,md:32,lg:38,xl:44},compact:{xs:20,sm:24,md:28,lg:32,xl:38}};export const dataHeaderHeights={default:{xs:28,sm:32,md:36,lg:42,xl:48},compact:{xs:24,sm:28,md:32,lg:36,xl:42}};export const dataTickWidths={xs:30,sm:34,md:38,lg:42,xl:50};export const defaultColumnWidth=160;export const minColumnWidth=48;export function compareValues(t,e,n){const o=null==t||""===t,r=null==e||""===e;return o||r?o&&r?0:o?1:-1:"number"==typeof t&&"number"==typeof e?Number.isNaN(t)||Number.isNaN(e)?Number.isNaN(t)&&Number.isNaN(e)?0:Number.isNaN(t)?1:-1:t-e:"boolean"==typeof t&&"boolean"==typeof e?Number(t)-Number(e):t instanceof Date&&e instanceof Date?t.getTime()-e.getTime():n.compare(String(t),String(e))}export function sortRows(t,e,n){if(0===e.length)return t;const o=e.map(t=>{const e=n(t.key);return e?{compare:e,sign:"desc"===t.direction?-1:1}:null}).filter(t=>null!==t);return 0===o.length?t:[...t].sort((t,e)=>{for(const n of o){const o=n.compare(t,e);if(0!==o)return o*n.sign}return 0})}export function nextSort(t,e,n){const o=t.find(t=>t.key===e),r=void 0===o?"asc":"asc"===o.direction?"desc":null;return n?null===r?t.filter(t=>t.key!==e):void 0===o?[...t,{key:e,direction:r}]:t.map(t=>t.key===e?{key:e,direction:r}:t):null===r?[]:[{key:e,direction:r}]}export function searchText(t){return null==t||"object"==typeof t?"":String(t).normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}export function pageBounds(t,e,n){const o=Math.max(1,Math.floor(n)),r=Math.max(1,Math.ceil(t/o)),a=Math.min(Math.max(Math.floor(e),1),r),i=(a-1)*o;return{pages:r,page:a,start:i,end:Math.min(i+o,t)}}export function virtualWindow(t,e,n,o,r){const a=e>0?Math.ceil(e/n):3*r,i=Math.max(0,Math.floor(t/n)-r),s=Math.min(o,i+a+2*r);return{start:i,end:s,before:i*n,after:Math.max(0,(o-s)*n)}}export function keysBetween(t,e,n){const o=t.indexOf(e),r=t.indexOf(n);return-1===o||-1===r?[]:t.slice(Math.min(o,r),Math.max(o,r)+1)}
1
+ export const dataRowHeights={default:{xs:24,sm:28,md:32,lg:38,xl:44},compact:{xs:20,sm:24,md:28,lg:32,xl:38}};export const dataHeaderHeights={default:{xs:28,sm:32,md:36,lg:42,xl:48},compact:{xs:24,sm:28,md:32,lg:36,xl:42}};export const dataTickWidths={xs:30,sm:34,md:38,lg:42,xl:50};export const defaultColumnWidth=160;export const minColumnWidth=48;export function compareValues(t,e,n){const o=null==t||""===t,r=null==e||""===e;return o||r?o&&r?0:o?1:-1:"number"==typeof t&&"number"==typeof e?Number.isNaN(t)||Number.isNaN(e)?Number.isNaN(t)&&Number.isNaN(e)?0:Number.isNaN(t)?1:-1:t-e:"boolean"==typeof t&&"boolean"==typeof e?Number(t)-Number(e):t instanceof Date&&e instanceof Date?t.getTime()-e.getTime():n.compare(String(t),String(e))}export function sortRows(t,e,n){if(0===e.length)return t;const o=e.map(t=>{const e=n(t.key);return e?{compare:e,sign:"desc"===t.direction?-1:1}:null}).filter(t=>null!==t);return 0===o.length?t:[...t].sort((t,e)=>{for(const n of o){const o=n.compare(t,e);if(0!==o)return o*n.sign}return 0})}export function nextSort(t,e,n){const o=t.find(t=>t.key===e),r=void 0===o?"asc":"asc"===o.direction?"desc":null;return n?null===r?t.filter(t=>t.key!==e):void 0===o?[...t,{key:e,direction:r}]:t.map(t=>t.key===e?{key:e,direction:r}:t):null===r?[]:[{key:e,direction:r}]}export function pageBounds(t,e,n){const o=Math.max(1,Math.floor(n)),r=Math.max(1,Math.ceil(t/o)),a=Math.min(Math.max(Math.floor(e),1),r),i=(a-1)*o;return{pages:r,page:a,start:i,end:Math.min(i+o,t)}}export function virtualWindow(t,e,n,o,r){const a=e>0?Math.ceil(e/n):3*r,i=Math.max(0,Math.floor(t/n)-r),s=Math.min(o,i+a+2*r);return{start:i,end:s,before:i*n,after:Math.max(0,(o-s)*n)}}export function keysBetween(t,e,n){const o=t.indexOf(e),r=t.indexOf(n);return-1===o||-1===r?[]:t.slice(Math.min(o,r),Math.max(o,r)+1)}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Everything a pointer drag takes from outside itself, and the one function
3
+ * that gives all of it back.
4
+ *
5
+ * Five components drag something: a Sidebar's edge, a Panes boundary, a
6
+ * WindowPane by its bar or its corner, a ScrollZone's strip, a DataTable's
7
+ * column rule. The arithmetic differs in every one of them and stays where it
8
+ * is. What was written five times and had already drifted is the scaffold
9
+ * around it — three listeners, a `dataset.dragging`, the document's text
10
+ * selection, and a teardown an unmount can call.
11
+ *
12
+ * The drift is the reason this exists rather than the repetition. A DataTable's
13
+ * column resize was the one copy with no selection suppression in it, so
14
+ * dragging a column boundary in Safari selected the text of every cell the
15
+ * pointer crossed; and it was the one with no unmount teardown, so a table that
16
+ * went away mid-drag left two listeners on a detached node.
17
+ *
18
+ * There is deliberately **no requestAnimationFrame in here.** A `pointermove`
19
+ * is already delivered once per frame in every browser the library supports —
20
+ * `pointerrawupdate` is the uncoalesced one — so coalescing again would buy
21
+ * nothing and cost a frame of latency on the one gesture where latency is the
22
+ * whole feel of it.
23
+ */
24
+ export interface PointerDragOptions {
25
+ /**
26
+ * The element the three listeners go on, and the one the pointer is captured
27
+ * to. Capture is what retargets every later event here, so a drag survives
28
+ * the pointer leaving the element it started on.
29
+ */
30
+ target: HTMLElement;
31
+ /** The pointer that started it. */
32
+ pointerId: number;
33
+ /** Every move until the gesture ends. */
34
+ onMove: (event: PointerEvent) => void;
35
+ /**
36
+ * The gesture ended the way it was meant to — the pointer was released.
37
+ *
38
+ * A `pointercancel` counts: the gesture is over and the caller wants to know
39
+ * where it settled. What does **not** count is the drag being torn down by an
40
+ * unmount — a component that disappeared did not finish resizing, and telling
41
+ * a caller it did would set state on the way out of the tree. That split is
42
+ * why `release` and `onEnd` are two things.
43
+ */
44
+ onEnd?: () => void;
45
+ /**
46
+ * Whether the document's text selection is taken for the length of it.
47
+ * @default true
48
+ */
49
+ selectable?: boolean;
50
+ /**
51
+ * Marks the target while it runs, for `data-[dragging]` to style against.
52
+ * @default true
53
+ */
54
+ mark?: boolean;
55
+ }
56
+ /**
57
+ * Starts a drag. Returns `release` — everything above, given back.
58
+ *
59
+ * Call `release` from an unmount effect. It is idempotent, so the pointer's own
60
+ * `pointerup` calling it first costs nothing.
61
+ */
62
+ export declare function beginPointerDrag({ target, pointerId, onMove, onEnd, selectable, mark }: PointerDragOptions): () => void;
@@ -0,0 +1 @@
1
+ export function beginPointerDrag({target:e,pointerId:t,onMove:r,onEnd:n,selectable:o=!0,mark:s=!0}){const i=o?function(){const e=document.body,t=e.style.getPropertyValue("-webkit-user-select");return e.style.setProperty("-webkit-user-select","none"),()=>{t?e.style.setProperty("-webkit-user-select",t):e.style.removeProperty("-webkit-user-select")}}():null;s&&(e.dataset.dragging="true"),e.setPointerCapture&&e.setPointerCapture(t);let a=!0;const l=()=>{a&&(a=!1,e.removeEventListener("pointermove",r),e.removeEventListener("pointerup",p),e.removeEventListener("pointercancel",p),s&&delete e.dataset.dragging,i?.())},p=()=>{l(),n?.()};return e.addEventListener("pointermove",r),e.addEventListener("pointerup",p),e.addEventListener("pointercancel",p),l}
@@ -1 +1 @@
1
- const i={bash:()=>import("highlight.js/lib/languages/bash"),c:()=>import("highlight.js/lib/languages/c"),cpp:()=>import("highlight.js/lib/languages/cpp"),csharp:()=>import("highlight.js/lib/languages/csharp"),css:()=>import("highlight.js/lib/languages/css"),diff:()=>import("highlight.js/lib/languages/diff"),dockerfile:()=>import("highlight.js/lib/languages/dockerfile"),go:()=>import("highlight.js/lib/languages/go"),graphql:()=>import("highlight.js/lib/languages/graphql"),ini:()=>import("highlight.js/lib/languages/ini"),java:()=>import("highlight.js/lib/languages/java"),javascript:()=>import("highlight.js/lib/languages/javascript"),json:()=>import("highlight.js/lib/languages/json"),kotlin:()=>import("highlight.js/lib/languages/kotlin"),less:()=>import("highlight.js/lib/languages/less"),lua:()=>import("highlight.js/lib/languages/lua"),makefile:()=>import("highlight.js/lib/languages/makefile"),markdown:()=>import("highlight.js/lib/languages/markdown"),objectivec:()=>import("highlight.js/lib/languages/objectivec"),perl:()=>import("highlight.js/lib/languages/perl"),php:()=>import("highlight.js/lib/languages/php"),plaintext:()=>import("highlight.js/lib/languages/plaintext"),powershell:()=>import("highlight.js/lib/languages/powershell"),python:()=>import("highlight.js/lib/languages/python"),r:()=>import("highlight.js/lib/languages/r"),ruby:()=>import("highlight.js/lib/languages/ruby"),rust:()=>import("highlight.js/lib/languages/rust"),scss:()=>import("highlight.js/lib/languages/scss"),shell:()=>import("highlight.js/lib/languages/shell"),sql:()=>import("highlight.js/lib/languages/sql"),swift:()=>import("highlight.js/lib/languages/swift"),typescript:()=>import("highlight.js/lib/languages/typescript"),xml:()=>import("highlight.js/lib/languages/xml"),yaml:()=>import("highlight.js/lib/languages/yaml")},t={"c++":"cpp",cc:"cpp",cjs:"javascript",console:"bash",cs:"csharp",cts:"typescript",docker:"dockerfile",gql:"graphql",golang:"go",h:"cpp",hpp:"cpp",htm:"xml",html:"xml",js:"javascript",jsx:"javascript",kt:"kotlin",kts:"kotlin",md:"markdown",mdx:"markdown",mjs:"javascript",mm:"objectivec",mts:"typescript",mysql:"sql",node:"javascript",none:"plaintext",objc:"objectivec",plain:"plaintext",posh:"powershell",ps1:"powershell",psql:"sql",py:"python",rb:"ruby",rs:"rust",sh:"bash",svelte:"xml",svg:"xml",text:"plaintext",toml:"ini",ts:"typescript",tsx:"typescript",txt:"plaintext",vue:"xml",yml:"yaml",zsh:"bash"},l=new Map;export function registerLanguage(i,t){const g=i.toLowerCase();l.set(g,t),s.delete(g)}let g=null;const s=new Map;export function canonicalLanguage(i){if(!i)return null;const l=i.trim().toLowerCase();return l?t[l]??l:null}export async function highlight(t,a){let e=s.get(a);e||(e=async function(t){const s=l.get(t),a=s?void 0:i[t];if(!s&&!a)return null;g??=import("highlight.js/lib/core").then(i=>i.default);const e=await g;return s?e.registerLanguage(t,s):e.getLanguage(t)||e.registerLanguage(t,(await a()).default),t}(a),s.set(a,e));const h=await e;if(!h||!g)return null;return tokenize((await g).highlight(t,{language:h,ignoreIllegals:!0}).value)}const a={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#x27;":"'"};export function tokenize(i){const t=[[]],l=[],g=/<span class="([^"]*)">|<\/span>/g;let s=0;const e=i=>{if(!i)return;const g=l[l.length-1];i.replace(/&(?:amp|lt|gt|quot|#x27);/g,i=>a[i]).split("\n").forEach((i,l)=>{l>0&&t.push([]),i&&t[t.length-1].push(g?{text:i,token:g}:{text:i})})};for(const t of i.matchAll(g))e(i.slice(s,t.index)),s=t.index+t[0].length,void 0===t[1]?l.pop():l.push(t[1]);return e(i.slice(s)),t}export function plainLines(i){return i.split("\n").map(i=>i?[{text:i}]:[])}
1
+ const i={bash:()=>import("highlight.js/lib/languages/bash"),c:()=>import("highlight.js/lib/languages/c"),cpp:()=>import("highlight.js/lib/languages/cpp"),csharp:()=>import("highlight.js/lib/languages/csharp"),css:()=>import("highlight.js/lib/languages/css"),diff:()=>import("highlight.js/lib/languages/diff"),dockerfile:()=>import("highlight.js/lib/languages/dockerfile"),go:()=>import("highlight.js/lib/languages/go"),graphql:()=>import("highlight.js/lib/languages/graphql"),ini:()=>import("highlight.js/lib/languages/ini"),java:()=>import("highlight.js/lib/languages/java"),javascript:()=>import("highlight.js/lib/languages/javascript"),json:()=>import("highlight.js/lib/languages/json"),kotlin:()=>import("highlight.js/lib/languages/kotlin"),less:()=>import("highlight.js/lib/languages/less"),lua:()=>import("highlight.js/lib/languages/lua"),makefile:()=>import("highlight.js/lib/languages/makefile"),markdown:()=>import("highlight.js/lib/languages/markdown"),objectivec:()=>import("highlight.js/lib/languages/objectivec"),perl:()=>import("highlight.js/lib/languages/perl"),php:()=>import("highlight.js/lib/languages/php"),plaintext:()=>import("highlight.js/lib/languages/plaintext"),powershell:()=>import("highlight.js/lib/languages/powershell"),python:()=>import("highlight.js/lib/languages/python"),r:()=>import("highlight.js/lib/languages/r"),ruby:()=>import("highlight.js/lib/languages/ruby"),rust:()=>import("highlight.js/lib/languages/rust"),scss:()=>import("highlight.js/lib/languages/scss"),shell:()=>import("highlight.js/lib/languages/shell"),sql:()=>import("highlight.js/lib/languages/sql"),swift:()=>import("highlight.js/lib/languages/swift"),typescript:()=>import("highlight.js/lib/languages/typescript"),xml:()=>import("highlight.js/lib/languages/xml"),yaml:()=>import("highlight.js/lib/languages/yaml")},t={"c++":"cpp",cc:"cpp",cjs:"javascript",console:"bash",cs:"csharp",cts:"typescript",docker:"dockerfile",gql:"graphql",golang:"go",h:"cpp",hpp:"cpp",htm:"xml",html:"xml",js:"javascript",jsx:"javascript",kt:"kotlin",kts:"kotlin",md:"markdown",mdx:"markdown",mjs:"javascript",mm:"objectivec",mts:"typescript",mysql:"sql",node:"javascript",none:"plaintext",objc:"objectivec",plain:"plaintext",posh:"powershell",ps1:"powershell",psql:"sql",py:"python",rb:"ruby",rs:"rust",sh:"bash",svelte:"xml",svg:"xml",text:"plaintext",toml:"ini",ts:"typescript",tsx:"typescript",txt:"plaintext",vue:"xml",yml:"yaml",zsh:"bash"},l=new Map;export function registerLanguage(i,t){const g=i.toLowerCase();l.set(g,t),s.delete(g)}let g=null;const s=new Map;export function canonicalLanguage(i){if(!i)return null;const l=i.trim().toLowerCase();return l?t[l]??l:null}export async function highlight(t,a){let e=s.get(a);e||(e=async function(t){const s=l.get(t),a=s?void 0:i[t];if(!s&&!a)return null;g??=import("highlight.js/lib/core").then(i=>i.default);const e=await g;return s?e.registerLanguage(t,s):e.getLanguage(t)||e.registerLanguage(t,(await a()).default),t}(a).catch(i=>{throw s.delete(a),i}),s.set(a,e));const h=await e;if(!h||!g)return null;return tokenize((await g).highlight(t,{language:h,ignoreIllegals:!0}).value)}const a={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#x27;":"'"};export function tokenize(i){const t=[[]],l=[],g=/<span class="([^"]*)">|<\/span>/g;let s=0;const e=i=>{if(!i)return;const g=l[l.length-1];i.replace(/&(?:amp|lt|gt|quot|#x27);/g,i=>a[i]).split("\n").forEach((i,l)=>{l>0&&t.push([]),i&&t[t.length-1].push(g?{text:i,token:g}:{text:i})})};for(const t of i.matchAll(g))e(i.slice(s,t.index)),s=t.index+t[0].length,void 0===t[1]?l.pop():l.push(t[1]);return e(i.slice(s)),t}export function plainLines(i){return i.split("\n").map(i=>i?[{text:i}]:[])}
@@ -33,6 +33,16 @@
33
33
  * string itself, so an unsupported language is never a dead end: `locale` gets
34
34
  * you a translation for free, and the prop gets you one for anything else.
35
35
  */
36
+ /**
37
+ * `{index}`, `{total}` and `{title}` filled into a message.
38
+ *
39
+ * It lives beside the tables rather than in whichever component needed it first
40
+ * because the placeholders are part of the message format: a language that
41
+ * orders "3 of 8" the other way round writes `{total}단계 중 {index}단계`, and a
42
+ * second copy of this function would eventually disagree about what a
43
+ * placeholder looks like.
44
+ */
45
+ export declare function fill(template: string, values: Record<string, string>): string;
36
46
  /**
37
47
  * One namespace's strings, in every language that has them.
38
48
  *
@@ -257,6 +267,21 @@ export interface CarouselMessages {
257
267
  }
258
268
  /** The `carousel` namespace, as Carousel read it. */
259
269
  export declare const carouselMessages: MessageTable<CarouselMessages>;
270
+ /**
271
+ * The charts.
272
+ *
273
+ * A chart is a `role="img"`, and an image without a name is a focus stop that
274
+ * announces nothing at all. Every chart takes a `label` saying what it is a
275
+ * chart *of*, and this is what stands in when it was not given one — the same
276
+ * bargain Empty makes, and for the same reason: there is nowhere else for the
277
+ * word to come from.
278
+ */
279
+ export interface ChartMessages {
280
+ /** Names the drawing when the caller did not. */
281
+ label: string;
282
+ }
283
+ /** The `chart` namespace, as every chart reads it. */
284
+ export declare const chartMessages: MessageTable<ChartMessages>;
260
285
  /**
261
286
  * ScrollZone.
262
287
  *
@@ -266,6 +291,16 @@ export declare const carouselMessages: MessageTable<CarouselMessages>;
266
291
  * right.
267
292
  */
268
293
  export interface ScrollMessages {
294
+ /**
295
+ * Names the strip itself.
296
+ *
297
+ * A scroll container is a tab stop — it has to be, or a reader with no
298
+ * pointer cannot move it — and a tab stop with no name announces nothing at
299
+ * all when the focus lands on it. `label` on the component says what the
300
+ * strip holds; this says what it *is*, for the far more common case where
301
+ * the surrounding page has already said the first part.
302
+ */
303
+ label: string;
269
304
  previous: string;
270
305
  next: string;
271
306
  }
@@ -280,6 +315,43 @@ export interface BreadcrumbMessages {
280
315
  }
281
316
  /** The `breadcrumb` namespace, as Breadcrumb read it. */
282
317
  export declare const breadcrumbMessages: MessageTable<BreadcrumbMessages>;
318
+ /** CommandPalette. */
319
+ export interface CommandMessages {
320
+ /** Names the dialog, which has no visible title of its own. */
321
+ label: string;
322
+ /** The placeholder in the field the reader types into. */
323
+ search: string;
324
+ /** The line where the rows would be, when nothing matched. */
325
+ empty: string;
326
+ }
327
+ /** The `command` namespace, as CommandPalette read it. */
328
+ export declare const commandMessages: MessageTable<CommandMessages>;
329
+ /** Transfer. */
330
+ export interface TransferMessages {
331
+ /** The heading over the list of everything not yet chosen. */
332
+ source: string;
333
+ /** And over the list of what has been. */
334
+ target: string;
335
+ /** The button that moves the ticked rows to the right-hand list. */
336
+ toTarget: string;
337
+ /** And the one that sends them back. */
338
+ toSource: string;
339
+ /** The placeholder in each list's filter. */
340
+ search: string;
341
+ /** The tick above a list that takes every row in it at once. */
342
+ selectAll: string;
343
+ /** The line where the rows would be, when a list has none. */
344
+ empty: string;
345
+ }
346
+ /** The `transfer` namespace, as Transfer read it. */
347
+ export declare const transferMessages: MessageTable<TransferMessages>;
348
+ /** Anchor. */
349
+ export interface AnchorMessages {
350
+ /** Names the `<nav>` landmark. */
351
+ label: string;
352
+ }
353
+ /** The `anchor` namespace, as Anchor read it. */
354
+ export declare const anchorMessages: MessageTable<AnchorMessages>;
283
355
  /** Combobox. */
284
356
  export interface ComboboxMessages {
285
357
  /** The line where the list would be, when nothing matched what was typed. */
@@ -380,6 +452,8 @@ export interface StepsMessages {
380
452
  next: string;
381
453
  /** And what it becomes on the last step. */
382
454
  done: string;
455
+ /** The way out of a guide that is running over the page, for a Tour. */
456
+ skip: string;
383
457
  /** The button under a finished guide. */
384
458
  restart: string;
385
459
  /** What a finished guide says. */
@@ -448,10 +522,18 @@ export interface NebaLocale {
448
522
  pagination?: Partial<PaginationMessages>;
449
523
  /** Carousel. */
450
524
  carousel?: Partial<CarouselMessages>;
525
+ /** Chart. */
526
+ chart?: Partial<ChartMessages>;
451
527
  /** Scroll. */
452
528
  scroll?: Partial<ScrollMessages>;
453
529
  /** Breadcrumb. */
454
530
  breadcrumb?: Partial<BreadcrumbMessages>;
531
+ /** Anchor. */
532
+ anchor?: Partial<AnchorMessages>;
533
+ /** Transfer. */
534
+ transfer?: Partial<TransferMessages>;
535
+ /** Command. */
536
+ command?: Partial<CommandMessages>;
455
537
  /** Combobox. */
456
538
  combobox?: Partial<ComboboxMessages>;
457
539
  /** Overlay. */
@@ -1 +1 @@
1
- import*as e from"react";export const actionMessages={"":{close:"Close",dismiss:"Dismiss",clear:"Clear",remove:"Remove"}};export const linkMessages={"":{newTab:"(opens in a new tab)"}};export const spoilerMessages={"":{reveal:"Reveal",hide:"Hide",notice:"This may contain spoilers"}};export const chatMessages={"":{sending:"Sending",sent:"Sent",delivered:"Delivered",read:"Read",failed:"Not sent",typing:"Typing…"}};export const emptyMessages={"":{title:"Nothing here"}};export const tableMessages={"":{search:"Search",selectAll:"Select all rows",selectRow:"Select row",rowsPerPage:"Rows per page",range:"{start}–{end} of {total}",selected:"{count} selected",empty:"No data"}};export const colorMessages={"":{area:"Saturation and brightness",hue:"Hue",alpha:"Opacity",value:"Colour value",swatches:"Preset colours",clear:"Clear",empty:"Choose a colour"}};export const ratingMessages={"":{label:"Rating",value:"{value} out of {max}",empty:"No rating"}};export const numberMessages={"":{increase:"Increase",decrease:"Decrease"}};export const paginationMessages={"":{label:"Pagination",page:"Page {page}",status:"Page {page} of {total}",previous:"Previous page",next:"Next page",first:"First page",last:"Last page"}};export const carouselMessages={"":{label:"Carousel",slide:"Slide {index} of {total}",previous:"Previous slide",next:"Next slide"}};export const scrollMessages={"":{previous:"Scroll back",next:"Scroll forward"}};export const breadcrumbMessages={"":{label:"Breadcrumb",expand:"Show hidden steps"}};export const comboboxMessages={"":{empty:"No matches",remove:"Remove {label}"}};export const overlayMessages={"":{label:"Overlay"}};export const windowMessages={"":{minimize:"Minimize",maximize:"Maximize",restore:"Restore",resize:"Resize window"}};export const layoutMessages={"":{skipToContent:"Skip to content",sidebar:"Sidebar",openSidebar:"Open sidebar",closeSidebar:"Close sidebar",resizeSidebar:"Resize sidebar"}};export const codeMessages={"":{code:"Code",copy:"Copy",copied:"Copied",copyFailed:"Could not copy",raw:"Raw",prompt:"Prompt"}};export const stepsMessages={"":{previous:"Previous",next:"Next",done:"Done",restart:"Start over",completed:"All steps complete",steps:"Steps",position:"{index} of {total}",step:"Step {index}: {title}"}};const s={zh:"zh-hans","zh-cn":"zh-hans","zh-my":"zh-hans","zh-sg":"zh-hans","zh-hk":"zh-hant","zh-mo":"zh-hant","zh-tw":"zh-hant"};const o=new WeakMap;export function resolveMessages(e,t){const a=e[""],r=t?.trim()??"";if(!r)return a;let n=o.get(e);n||(n=new Map,o.set(e,n));const i=n.get(r);if(i)return i;const l=function(e){const s=e.toLowerCase().split(/[-_]/).filter(Boolean),o=s[0];if(!o)return[];const t=s.slice(1),a=t.find(e=>/^[a-z]{4}$/.test(e)),r=t.find(e=>/^([a-z]{2}|\d{3})$/.test(e));return[a?`${o}-${a}`:"",r?`${o}-${r}`:"",o].filter(Boolean)}(r).map(o=>{const t=s[o];return e[o]??(t?e[t]:void 0)}).find(Boolean),c=l?{...a,...l}:a;return n.set(r,c),c}export function useMessages(s,o){return e.useMemo(()=>resolveMessages(s,o),[s,o])}export function fillMessage(e,s){return e.replace(/\{(\w+)\}/g,(e,o)=>s[o]??e)}const t={action:actionMessages,link:linkMessages,spoiler:spoilerMessages,chat:chatMessages,empty:emptyMessages,table:tableMessages,color:colorMessages,rating:ratingMessages,number:numberMessages,pagination:paginationMessages,carousel:carouselMessages,scroll:scrollMessages,breadcrumb:breadcrumbMessages,combobox:comboboxMessages,overlay:overlayMessages,window:windowMessages,layout:layoutMessages,code:codeMessages,steps:stepsMessages};export function registerMessages(e,s){const a=e.trim().toLowerCase();for(const[e,r]of Object.entries(s)){const s=t[e];s&&r&&(s[a]=r,o.delete(s))}}
1
+ import*as e from"react";export function fill(e,s){return e.replace(/\{(\w+)\}/g,(e,t)=>s[t]??e)}export const actionMessages={"":{close:"Close",dismiss:"Dismiss",clear:"Clear",remove:"Remove"}};export const linkMessages={"":{newTab:"(opens in a new tab)"}};export const spoilerMessages={"":{reveal:"Reveal",hide:"Hide",notice:"This may contain spoilers"}};export const chatMessages={"":{sending:"Sending",sent:"Sent",delivered:"Delivered",read:"Read",failed:"Not sent",typing:"Typing…"}};export const emptyMessages={"":{title:"Nothing here"}};export const tableMessages={"":{search:"Search",selectAll:"Select all rows",selectRow:"Select row",rowsPerPage:"Rows per page",range:"{start}–{end} of {total}",selected:"{count} selected",empty:"No data"}};export const colorMessages={"":{area:"Saturation and brightness",hue:"Hue",alpha:"Opacity",value:"Colour value",swatches:"Preset colours",clear:"Clear",empty:"Choose a colour"}};export const ratingMessages={"":{label:"Rating",value:"{value} out of {max}",empty:"No rating"}};export const numberMessages={"":{increase:"Increase",decrease:"Decrease"}};export const paginationMessages={"":{label:"Pagination",page:"Page {page}",status:"Page {page} of {total}",previous:"Previous page",next:"Next page",first:"First page",last:"Last page"}};export const carouselMessages={"":{label:"Carousel",slide:"Slide {index} of {total}",previous:"Previous slide",next:"Next slide"}};export const chartMessages={"":{label:"Chart"}};export const scrollMessages={"":{label:"Scrollable content",previous:"Scroll back",next:"Scroll forward"}};export const breadcrumbMessages={"":{label:"Breadcrumb",expand:"Show hidden steps"}};export const commandMessages={"":{label:"Command palette",search:"Type a command or search…",empty:"No commands found"}};export const transferMessages={"":{source:"Available",target:"Selected",toTarget:"Move to selected",toSource:"Move to available",search:"Search",selectAll:"Select all",empty:"Nothing here"}};export const anchorMessages={"":{label:"On this page"}};export const comboboxMessages={"":{empty:"No matches",remove:"Remove {label}"}};export const overlayMessages={"":{label:"Overlay"}};export const windowMessages={"":{minimize:"Minimize",maximize:"Maximize",restore:"Restore",resize:"Resize window"}};export const layoutMessages={"":{skipToContent:"Skip to content",sidebar:"Sidebar",openSidebar:"Open sidebar",closeSidebar:"Close sidebar",resizeSidebar:"Resize sidebar"}};export const codeMessages={"":{code:"Code",copy:"Copy",copied:"Copied",copyFailed:"Could not copy",raw:"Raw",prompt:"Prompt"}};export const stepsMessages={"":{previous:"Previous",next:"Next",done:"Done",skip:"Skip",restart:"Start over",completed:"All steps complete",steps:"Steps",position:"{index} of {total}",step:"Step {index}: {title}"}};const s={zh:"zh-hans","zh-cn":"zh-hans","zh-my":"zh-hans","zh-sg":"zh-hans","zh-hk":"zh-hant","zh-mo":"zh-hant","zh-tw":"zh-hant"};const t=new WeakMap;export function resolveMessages(e,o){const a=e[""],r=o?.trim()??"";if(!r)return a;let n=t.get(e);n||(n=new Map,t.set(e,n));const l=n.get(r);if(l)return l;const c=function(e){const s=e.toLowerCase().split(/[-_]/).filter(Boolean),t=s[0];if(!t)return[];const o=s.slice(1),a=o.find(e=>/^[a-z]{4}$/.test(e)),r=o.find(e=>/^([a-z]{2}|\d{3})$/.test(e));return[a?`${t}-${a}`:"",r?`${t}-${r}`:"",t].filter(Boolean)}(r).map(t=>{const o=s[t];return e[t]??(o?e[o]:void 0)}).find(Boolean),i=c?{...a,...c}:a;return n.set(r,i),i}export function useMessages(s,t){return e.useMemo(()=>resolveMessages(s,t),[s,t])}export function fillMessage(e,s){return e.replace(/\{(\w+)\}/g,(e,t)=>s[t]??e)}const o={action:actionMessages,link:linkMessages,spoiler:spoilerMessages,chat:chatMessages,empty:emptyMessages,table:tableMessages,color:colorMessages,rating:ratingMessages,number:numberMessages,pagination:paginationMessages,carousel:carouselMessages,chart:chartMessages,scroll:scrollMessages,breadcrumb:breadcrumbMessages,anchor:anchorMessages,transfer:transferMessages,command:commandMessages,combobox:comboboxMessages,overlay:overlayMessages,window:windowMessages,layout:layoutMessages,code:codeMessages,steps:stepsMessages};export function registerMessages(e,s){const a=e.trim().toLowerCase();for(const[e,r]of Object.entries(s)){const s=o[e];s&&r&&(s[a]=r,t.delete(s))}}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The one rule the library makes about a link it did not write.
3
+ *
4
+ * A `target` other than the current tab hands the new page a `window.opener`
5
+ * pointing back at this one, and a `Referer` header naming it. Modern browsers
6
+ * imply `noopener` for `target="_blank"`; none of them implies `noreferrer`,
7
+ * and neither is implied for a named target. So the two tokens are added
8
+ * wherever a component lets a caller choose where a link opens — TextLink,
9
+ * a Menu row, a NavigationMenu link — and they are added the same way in all
10
+ * three, because a library where only one of them is safe is a library whose
11
+ * users cannot tell which.
12
+ *
13
+ * It is a *merge* and not an override, and that is the whole reason this is a
14
+ * function rather than a string. The common reason to write a `rel` by hand is
15
+ * `nofollow` or `sponsored`, which is an SEO decision and has nothing to do
16
+ * with the two tokens above — spelled as a plain default it would silently take
17
+ * the protection off the link that still opens in a new tab.
18
+ */
19
+ export declare function safeRel(target: string | undefined, rel: string | undefined): string | undefined;
@@ -0,0 +1 @@
1
+ export function safeRel(e,n){return e&&"_self"!==e&&"_parent"!==e&&"_top"!==e?[...new Set([...(n??"").split(/\s+/).filter(Boolean),"noopener","noreferrer"])].join(" "):n}
@@ -0,0 +1,29 @@
1
+ /** Subscribes to one query. A no-op where there is no window to ask. */
2
+ export declare function subscribeToQuery(query: string, onChange: () => void): () => void;
3
+ /** The current answer. Reads a live object rather than building one. */
4
+ export declare function queryMatches(query: string): boolean;
5
+ /** A server has no window, so nothing matches. */
6
+ export declare function noMatchOnServer(): boolean;
7
+ /** The query behind every "the reader asked for less motion" decision. */
8
+ export declare const reducedMotionQuery = "(prefers-reduced-motion: reduce)";
9
+ /**
10
+ * Whether the reader has asked for less motion.
11
+ *
12
+ * The CSS side of this is handled in the stylesheet, where every keyframe is
13
+ * switched off at once. This is for the motion written in JavaScript — a
14
+ * typewriter, a headline reel, a measured marquee, a carousel that advances on
15
+ * a timer — where there is no rule to switch off and the component has to
16
+ * decide for itself what "still" means.
17
+ *
18
+ * `useSyncExternalStore` rather than state plus an effect, which is the same
19
+ * choice Shortcut makes for the same reason: a media query is an external
20
+ * store, and reading it in an effect means every animated element on the page
21
+ * renders once with the wrong answer and then again with the right one. Here
22
+ * that first render is the one that would start a typewriter a reader asked
23
+ * not to see.
24
+ *
25
+ * It lives beside the query rather than in `animate.ts` so that a Carousel and
26
+ * a ScrollZone can ask without pulling the eleven animation effects in with the
27
+ * answer.
28
+ */
29
+ export declare function usePrefersReducedMotion(): boolean;