@underpin/ui 0.0.0 → 2.1.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 (277) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +44 -1
  3. package/components/autocomplete.d.ts +25 -0
  4. package/components/autocomplete.js +71 -0
  5. package/components/autocomplete.js.map +1 -0
  6. package/components/avatar.d.ts +5 -0
  7. package/components/avatar.js +26 -0
  8. package/components/avatar.js.map +1 -0
  9. package/components/badge.d.ts +36 -0
  10. package/components/badge.js +140 -0
  11. package/components/badge.js.map +1 -0
  12. package/components/bar-list.d.ts +133 -0
  13. package/components/bar-list.js +204 -0
  14. package/components/bar-list.js.map +1 -0
  15. package/components/breakdown-card.d.ts +30 -0
  16. package/components/breakdown-card.js +43 -0
  17. package/components/breakdown-card.js.map +1 -0
  18. package/components/bulk-action-bar.d.ts +21 -0
  19. package/components/bulk-action-bar.js +38 -0
  20. package/components/bulk-action-bar.js.map +1 -0
  21. package/components/button-group.d.ts +21 -0
  22. package/components/button-group.js +32 -0
  23. package/components/button-group.js.map +1 -0
  24. package/components/button.d.ts +39 -0
  25. package/components/button.js +145 -0
  26. package/components/button.js.map +1 -0
  27. package/components/calendar.d.ts +27 -0
  28. package/components/calendar.js +95 -0
  29. package/components/calendar.js.map +1 -0
  30. package/components/callout.d.ts +26 -0
  31. package/components/callout.js +71 -0
  32. package/components/callout.js.map +1 -0
  33. package/components/card.d.ts +55 -0
  34. package/components/card.js +96 -0
  35. package/components/card.js.map +1 -0
  36. package/components/chart.d.ts +32 -0
  37. package/components/chart.js +43 -0
  38. package/components/chart.js.map +1 -0
  39. package/components/checkbox.d.ts +15 -0
  40. package/components/checkbox.js +42 -0
  41. package/components/checkbox.js.map +1 -0
  42. package/components/code-block.d.ts +21 -0
  43. package/components/code-block.js +35 -0
  44. package/components/code-block.js.map +1 -0
  45. package/components/collapse.d.ts +14 -0
  46. package/components/collapse.js +25 -0
  47. package/components/collapse.js.map +1 -0
  48. package/components/combobox.d.ts +71 -0
  49. package/components/combobox.js +155 -0
  50. package/components/combobox.js.map +1 -0
  51. package/components/copy-button.d.ts +29 -0
  52. package/components/copy-button.js +100 -0
  53. package/components/copy-button.js.map +1 -0
  54. package/components/copy-input.d.ts +15 -0
  55. package/components/copy-input.js +51 -0
  56. package/components/copy-input.js.map +1 -0
  57. package/components/data-table.d.ts +120 -0
  58. package/components/data-table.js +336 -0
  59. package/components/data-table.js.map +1 -0
  60. package/components/date-picker-trigger.d.ts +12 -0
  61. package/components/date-picker-trigger.js +30 -0
  62. package/components/date-picker-trigger.js.map +1 -0
  63. package/components/date-picker.d.ts +36 -0
  64. package/components/date-picker.js +70 -0
  65. package/components/date-picker.js.map +1 -0
  66. package/components/detail-row.d.ts +51 -0
  67. package/components/detail-row.js +77 -0
  68. package/components/detail-row.js.map +1 -0
  69. package/components/dialog.d.ts +121 -0
  70. package/components/dialog.js +327 -0
  71. package/components/dialog.js.map +1 -0
  72. package/components/disabled-reason.d.ts +31 -0
  73. package/components/disabled-reason.js +67 -0
  74. package/components/disabled-reason.js.map +1 -0
  75. package/components/empty-state.d.ts +41 -0
  76. package/components/empty-state.js +84 -0
  77. package/components/empty-state.js.map +1 -0
  78. package/components/entity-avatar.d.ts +54 -0
  79. package/components/entity-avatar.js +68 -0
  80. package/components/entity-avatar.js.map +1 -0
  81. package/components/form-section.d.ts +22 -0
  82. package/components/form-section.js +38 -0
  83. package/components/form-section.js.map +1 -0
  84. package/components/form.d.ts +199 -0
  85. package/components/form.js +456 -0
  86. package/components/form.js.map +1 -0
  87. package/components/formatted-number.d.ts +21 -0
  88. package/components/formatted-number.js +13 -0
  89. package/components/formatted-number.js.map +1 -0
  90. package/components/heading.d.ts +23 -0
  91. package/components/heading.js +44 -0
  92. package/components/heading.js.map +1 -0
  93. package/components/icon-swap.d.ts +15 -0
  94. package/components/icon-swap.js +29 -0
  95. package/components/icon-swap.js.map +1 -0
  96. package/components/inline-action.d.ts +21 -0
  97. package/components/inline-action.js +36 -0
  98. package/components/inline-action.js.map +1 -0
  99. package/components/input.d.ts +51 -0
  100. package/components/input.js +52 -0
  101. package/components/input.js.map +1 -0
  102. package/components/kbd.d.ts +17 -0
  103. package/components/kbd.js +34 -0
  104. package/components/kbd.js.map +1 -0
  105. package/components/label.d.ts +10 -0
  106. package/components/label.js +20 -0
  107. package/components/label.js.map +1 -0
  108. package/components/menu.d.ts +77 -0
  109. package/components/menu.js +189 -0
  110. package/components/menu.js.map +1 -0
  111. package/components/nav-button.d.ts +34 -0
  112. package/components/nav-button.js +71 -0
  113. package/components/nav-button.js.map +1 -0
  114. package/components/nav.d.ts +39 -0
  115. package/components/nav.js +68 -0
  116. package/components/nav.js.map +1 -0
  117. package/components/number-input.d.ts +16 -0
  118. package/components/number-input.js +25 -0
  119. package/components/number-input.js.map +1 -0
  120. package/components/page.d.ts +14 -0
  121. package/components/page.js +23 -0
  122. package/components/page.js.map +1 -0
  123. package/components/pagination.d.ts +73 -0
  124. package/components/pagination.js +212 -0
  125. package/components/pagination.js.map +1 -0
  126. package/components/ping.d.ts +38 -0
  127. package/components/ping.js +50 -0
  128. package/components/ping.js.map +1 -0
  129. package/components/popover.d.ts +5 -0
  130. package/components/popover.js +25 -0
  131. package/components/popover.js.map +1 -0
  132. package/components/radio-group.d.ts +35 -0
  133. package/components/radio-group.js +81 -0
  134. package/components/radio-group.js.map +1 -0
  135. package/components/relative-time.d.ts +25 -0
  136. package/components/relative-time.js +51 -0
  137. package/components/relative-time.js.map +1 -0
  138. package/components/saved-mark.d.ts +15 -0
  139. package/components/saved-mark.js +45 -0
  140. package/components/saved-mark.js.map +1 -0
  141. package/components/search-input.d.ts +13 -0
  142. package/components/search-input.js +44 -0
  143. package/components/search-input.js.map +1 -0
  144. package/components/section-header.d.ts +83 -0
  145. package/components/section-header.js +170 -0
  146. package/components/section-header.js.map +1 -0
  147. package/components/segmented-control.d.ts +24 -0
  148. package/components/segmented-control.js +70 -0
  149. package/components/segmented-control.js.map +1 -0
  150. package/components/select.d.ts +28 -0
  151. package/components/select.js +129 -0
  152. package/components/select.js.map +1 -0
  153. package/components/shortcut-keys.d.ts +14 -0
  154. package/components/shortcut-keys.js +32 -0
  155. package/components/shortcut-keys.js.map +1 -0
  156. package/components/shortcuts-dialog.d.ts +10 -0
  157. package/components/shortcuts-dialog.js +92 -0
  158. package/components/shortcuts-dialog.js.map +1 -0
  159. package/components/skeleton.d.ts +8 -0
  160. package/components/skeleton.js +23 -0
  161. package/components/skeleton.js.map +1 -0
  162. package/components/sparkline.d.ts +25 -0
  163. package/components/sparkline.js +70 -0
  164. package/components/sparkline.js.map +1 -0
  165. package/components/stack.d.ts +21 -0
  166. package/components/stack.js +45 -0
  167. package/components/stack.js.map +1 -0
  168. package/components/stat-strip.d.ts +43 -0
  169. package/components/stat-strip.js +151 -0
  170. package/components/stat-strip.js.map +1 -0
  171. package/components/steps.d.ts +19 -0
  172. package/components/steps.js +25 -0
  173. package/components/steps.js.map +1 -0
  174. package/components/switch.d.ts +16 -0
  175. package/components/switch.js +29 -0
  176. package/components/switch.js.map +1 -0
  177. package/components/table-toolbar.d.ts +55 -0
  178. package/components/table-toolbar.js +119 -0
  179. package/components/table-toolbar.js.map +1 -0
  180. package/components/table.d.ts +276 -0
  181. package/components/table.js +572 -0
  182. package/components/table.js.map +1 -0
  183. package/components/tabs.d.ts +36 -0
  184. package/components/tabs.js +120 -0
  185. package/components/tabs.js.map +1 -0
  186. package/components/text-link.d.ts +16 -0
  187. package/components/text-link.js +32 -0
  188. package/components/text-link.js.map +1 -0
  189. package/components/textarea.d.ts +10 -0
  190. package/components/textarea.js +23 -0
  191. package/components/textarea.js.map +1 -0
  192. package/components/theme.d.ts +28 -0
  193. package/components/theme.js +158 -0
  194. package/components/theme.js.map +1 -0
  195. package/components/time-series-chart.d.ts +122 -0
  196. package/components/time-series-chart.js +722 -0
  197. package/components/time-series-chart.js.map +1 -0
  198. package/components/toaster.d.ts +3 -0
  199. package/components/toaster.js +44 -0
  200. package/components/toaster.js.map +1 -0
  201. package/components/tooltip.d.ts +64 -0
  202. package/components/tooltip.js +126 -0
  203. package/components/tooltip.js.map +1 -0
  204. package/components/view-picker.d.ts +20 -0
  205. package/components/view-picker.js +24 -0
  206. package/components/view-picker.js.map +1 -0
  207. package/fonts/inter-OFL.txt +93 -0
  208. package/fonts/inter-cyrillic-ext.woff2 +0 -0
  209. package/fonts/inter-cyrillic.woff2 +0 -0
  210. package/fonts/inter-greek-ext.woff2 +0 -0
  211. package/fonts/inter-greek.woff2 +0 -0
  212. package/fonts/inter-latin-ext.woff2 +0 -0
  213. package/fonts/inter-latin.woff2 +0 -0
  214. package/fonts/inter-vietnamese.woff2 +0 -0
  215. package/fonts.css +83 -0
  216. package/lib/animation.d.ts +14 -0
  217. package/lib/animation.js +20 -0
  218. package/lib/animation.js.map +1 -0
  219. package/lib/aria.d.ts +5 -0
  220. package/lib/aria.js +12 -0
  221. package/lib/aria.js.map +1 -0
  222. package/lib/chart-curve.d.ts +13 -0
  223. package/lib/chart-curve.js +79 -0
  224. package/lib/chart-curve.js.map +1 -0
  225. package/lib/classes.d.ts +134 -0
  226. package/lib/classes.js +152 -0
  227. package/lib/classes.js.map +1 -0
  228. package/lib/color.d.ts +25 -0
  229. package/lib/color.js +149 -0
  230. package/lib/color.js.map +1 -0
  231. package/lib/data-table-state.d.ts +87 -0
  232. package/lib/data-table-state.js +92 -0
  233. package/lib/data-table-state.js.map +1 -0
  234. package/lib/day.d.ts +9 -0
  235. package/lib/day.js +20 -0
  236. package/lib/day.js.map +1 -0
  237. package/lib/design-tokens.d.ts +56 -0
  238. package/lib/design-tokens.js +196 -0
  239. package/lib/design-tokens.js.map +1 -0
  240. package/lib/icon.d.ts +17 -0
  241. package/lib/icon.js +34 -0
  242. package/lib/icon.js.map +1 -0
  243. package/lib/icons.d.ts +29 -0
  244. package/lib/icons.js +34 -0
  245. package/lib/icons.js.map +1 -0
  246. package/lib/interactive.d.ts +21 -0
  247. package/lib/interactive.js +31 -0
  248. package/lib/interactive.js.map +1 -0
  249. package/lib/load-more.d.ts +14 -0
  250. package/lib/load-more.js +27 -0
  251. package/lib/load-more.js.map +1 -0
  252. package/lib/media.d.ts +58 -0
  253. package/lib/media.js +116 -0
  254. package/lib/media.js.map +1 -0
  255. package/lib/segmented.d.ts +57 -0
  256. package/lib/segmented.js +83 -0
  257. package/lib/segmented.js.map +1 -0
  258. package/lib/shortcuts.d.ts +94 -0
  259. package/lib/shortcuts.js +271 -0
  260. package/lib/shortcuts.js.map +1 -0
  261. package/lib/slot.d.ts +9 -0
  262. package/lib/slot.js +18 -0
  263. package/lib/slot.js.map +1 -0
  264. package/lib/time-series.d.ts +100 -0
  265. package/lib/time-series.js +144 -0
  266. package/lib/time-series.js.map +1 -0
  267. package/lib/tone.d.ts +6 -0
  268. package/lib/tone.js +0 -0
  269. package/lib/variants.d.ts +12 -0
  270. package/lib/variants.js +14 -0
  271. package/lib/variants.js.map +1 -0
  272. package/package.json +122 -3
  273. package/styles.css +630 -0
  274. package/tokens.d.ts +104 -0
  275. package/tokens.js +108 -0
  276. package/tokens.js.map +1 -0
  277. package/publish.log +0 -1
@@ -0,0 +1,34 @@
1
+ import { VariantProps } from "../lib/variants.js";
2
+ import { Button } from "./button.js";
3
+ import { navItem } from "./nav.js";
4
+ import { ComponentProps, ReactNode } from "react";
5
+ type NavButtonVariant = Exclude<NonNullable<VariantProps<typeof navItem>["variant"]>, "link">;
6
+ type NavButtonShellProps = Omit<ComponentProps<typeof Button>, "variant"> & {
7
+ leading: ReactNode;
8
+ variant?: NavButtonVariant;
9
+ };
10
+ /** The nav trigger's frame around any leading mark, for a row that is not an entity. */
11
+ declare function NavButtonShell({ leading, variant, children, className, ...props }: NavButtonShellProps): import("react").JSX.Element;
12
+ type NavButtonProps = NavButtonShellProps & {
13
+ /** The row's text, and the name its avatar takes initials from. */
14
+ label: string;
15
+ avatar?: string;
16
+ };
17
+ /**
18
+ * Compact nav trigger: a 20px avatar, one line of text and whatever `suffix` the caller
19
+ * passes (usually a chevron). Secondary text belongs in the menu it opens.
20
+ */
21
+ declare function NavButton({ avatar, label, ...props }: Omit<NavButtonProps, "leading" | "children">): import("react").JSX.Element;
22
+ declare function NavButtonSkeleton({ variant, ...props }: Omit<NavButtonShellProps, "leading" | "children">): import("react").JSX.Element;
23
+ type NavIdentityProps = ComponentProps<"div"> & {
24
+ name: ReactNode;
25
+ /**
26
+ * The muted second line under the name: an email, a workspace slug.
27
+ */
28
+ detail: ReactNode;
29
+ };
30
+ /**
31
+ * Name over a muted detail line — the identity stack a nav menu's items and headers share.
32
+ */
33
+ declare function NavIdentity({ name, detail, className, ...props }: NavIdentityProps): import("react").JSX.Element;
34
+ export { NavButton, NavButtonShell, NavButtonSkeleton, NavIdentity };
@@ -0,0 +1,71 @@
1
+ import { cn } from "../lib/variants.js";
2
+ import { Button } from "./button.js";
3
+ import { EntityAvatar } from "./entity-avatar.js";
4
+ import { navItem } from "./nav.js";
5
+ import { Skeleton } from "./skeleton.js";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ // src/components/nav-button.tsx
8
+ /** The nav trigger's frame around any leading mark, for a row that is not an entity. */
9
+ function NavButtonShell({ leading, variant = "flat", children, className, ...props }) {
10
+ return /* @__PURE__ */ jsx(Button, {
11
+ size: variant === "outline" ? "md" : "sm",
12
+ variant: "ghost",
13
+ bordered: variant === "outline",
14
+ prefix: leading,
15
+ className: navItem({
16
+ variant,
17
+ className
18
+ }),
19
+ ...props,
20
+ children: /* @__PURE__ */ jsx("span", {
21
+ className: "font-medium text-control",
22
+ children
23
+ })
24
+ });
25
+ }
26
+ /**
27
+ * Compact nav trigger: a 20px avatar, one line of text and whatever `suffix` the caller
28
+ * passes (usually a chevron). Secondary text belongs in the menu it opens.
29
+ */
30
+ function NavButton({ avatar, label, ...props }) {
31
+ return /* @__PURE__ */ jsx(NavButtonShell, {
32
+ leading: /* @__PURE__ */ jsx(EntityAvatar, {
33
+ size: "sm",
34
+ src: avatar,
35
+ name: label
36
+ }),
37
+ ...props,
38
+ children: label
39
+ });
40
+ }
41
+ function NavButtonSkeleton({ variant, ...props }) {
42
+ return /* @__PURE__ */ jsx(NavButtonShell, {
43
+ disabled: true,
44
+ variant,
45
+ leading: /* @__PURE__ */ jsx(Skeleton, { className: "size-5 rounded-sm" }),
46
+ ...props,
47
+ children: /* @__PURE__ */ jsx(Skeleton, {
48
+ className: "w-28",
49
+ children: "\xA0"
50
+ })
51
+ });
52
+ }
53
+ /**
54
+ * Name over a muted detail line — the identity stack a nav menu's items and headers share.
55
+ */
56
+ function NavIdentity({ name, detail, className, ...props }) {
57
+ return /* @__PURE__ */ jsxs("div", {
58
+ className: cn("flex min-w-0 flex-col", className),
59
+ ...props,
60
+ children: [/* @__PURE__ */ jsx("span", {
61
+ className: "truncate font-medium text-control",
62
+ children: name
63
+ }), /* @__PURE__ */ jsx("span", {
64
+ className: "truncate text-ink-muted text-xs",
65
+ children: detail
66
+ })]
67
+ });
68
+ }
69
+ export { NavButton, NavButtonShell, NavButtonSkeleton, NavIdentity };
70
+
71
+ //# sourceMappingURL=nav-button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nav-button.js","names":[],"sources":["../../src/components/nav-button.tsx"],"sourcesContent":["import type { ComponentProps, ReactNode } from \"react\"\nimport { cn, type VariantProps } from \"../lib/variants\"\nimport { Button } from \"./button\"\nimport { EntityAvatar } from \"./entity-avatar\"\nimport { navItem } from \"./nav\"\nimport { Skeleton } from \"./skeleton\"\n\ntype NavButtonVariant = Exclude<NonNullable<VariantProps<typeof navItem>[\"variant\"]>, \"link\">\n\ntype NavButtonShellProps = Omit<ComponentProps<typeof Button>, \"variant\"> & {\n leading: ReactNode\n variant?: NavButtonVariant\n}\n\n/** The nav trigger's frame around any leading mark, for a row that is not an entity. */\nfunction NavButtonShell({\n leading,\n variant = \"flat\",\n children,\n className,\n ...props\n}: NavButtonShellProps) {\n return (\n <Button\n size={variant === \"outline\" ? \"md\" : \"sm\"}\n variant=\"ghost\"\n bordered={variant === \"outline\"}\n prefix={leading}\n className={navItem({ variant, className })}\n {...props}\n >\n <span className=\"font-medium text-control\">{children}</span>\n </Button>\n )\n}\n\ntype NavButtonProps = NavButtonShellProps & {\n /** The row's text, and the name its avatar takes initials from. */\n label: string\n avatar?: string\n}\n\n/**\n * Compact nav trigger: a 20px avatar, one line of text and whatever `suffix` the caller\n * passes (usually a chevron). Secondary text belongs in the menu it opens.\n */\nfunction NavButton({ avatar, label, ...props }: Omit<NavButtonProps, \"leading\" | \"children\">) {\n return (\n <NavButtonShell leading={<EntityAvatar size=\"sm\" src={avatar} name={label} />} {...props}>\n {label}\n </NavButtonShell>\n )\n}\n\nfunction NavButtonSkeleton({\n variant,\n ...props\n}: Omit<NavButtonShellProps, \"leading\" | \"children\">) {\n return (\n <NavButtonShell\n disabled\n variant={variant}\n leading={<Skeleton className=\"size-5 rounded-sm\" />}\n {...props}\n >\n <Skeleton className=\"w-28\">&nbsp;</Skeleton>\n </NavButtonShell>\n )\n}\n\ntype NavIdentityProps = ComponentProps<\"div\"> & {\n name: ReactNode\n\n /**\n * The muted second line under the name: an email, a workspace slug.\n */\n detail: ReactNode\n}\n\n/**\n * Name over a muted detail line — the identity stack a nav menu's items and headers share.\n */\nfunction NavIdentity({ name, detail, className, ...props }: NavIdentityProps) {\n return (\n <div className={cn(\"flex min-w-0 flex-col\", className)} {...props}>\n <span className=\"truncate font-medium text-control\">{name}</span>\n <span className=\"truncate text-ink-muted text-xs\">{detail}</span>\n </div>\n )\n}\n\nexport { NavButton, NavButtonShell, NavButtonSkeleton, NavIdentity }\n"],"mappings":";;;;;;;;AAeA,SAAS,eAAe,EACtB,SACA,UAAU,QACV,UACA,WACA,GAAG,SACmB;CACtB,OACE,oBAAC,QAAD;EACE,MAAM,YAAY,YAAY,OAAO;EACrC,SAAQ;EACR,UAAU,YAAY;EACtB,QAAQ;EACR,WAAW,QAAQ;GAAE;GAAS;EAAU,CAAC;EACzC,GAAI;EAEJ,UAAA,oBAAC,QAAD;GAAM,WAAU;GAA4B;EAAe,CAAA;CACrD,CAAA;AAEZ;;;;;AAYA,SAAS,UAAU,EAAE,QAAQ,OAAO,GAAG,SAAuD;CAC5F,OACE,oBAAC,gBAAD;EAAgB,SAAS,oBAAC,cAAD;GAAc,MAAK;GAAK,KAAK;GAAQ,MAAM;EAAQ,CAAA;EAAG,GAAI;EAChF,UAAA;CACa,CAAA;AAEpB;AAEA,SAAS,kBAAkB,EACzB,SACA,GAAG,SACiD;CACpD,OACE,oBAAC,gBAAD;EACE,UAAA;EACS;EACT,SAAS,oBAAC,UAAD,EAAU,WAAU,oBAAqB,CAAA;EAClD,GAAI;EAEJ,UAAA,oBAAC,UAAD;GAAU,WAAU;GAAO,UAAA;EAAgB,CAAA;CAC7B,CAAA;AAEpB;;;;AAcA,SAAS,YAAY,EAAE,MAAM,QAAQ,WAAW,GAAG,SAA2B;CAC5E,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,yBAAyB,SAAS;EAAG,GAAI;EAA5D,UAAA,CACE,oBAAC,QAAD;GAAM,WAAU;GAAqC,UAAA;EAAW,CAAA,GAChE,oBAAC,QAAD;GAAM,WAAU;GAAmC,UAAA;EAAa,CAAA,CAC7D;;AAET"}
@@ -0,0 +1,39 @@
1
+ import { ComponentProps } from "react";
2
+ export declare function Nav({ className, ...props }: ComponentProps<"nav">): import("react").JSX.Element;
3
+ /**
4
+ * Muted group label above a run of nav links, in sentence case. It starts on the rows' own inset,
5
+ * so the label sits over the rows' leading column rather than hanging off it.
6
+ */
7
+ export declare function NavLabel({ className, ...props }: ComponentProps<"p">): import("react").JSX.Element;
8
+ /**
9
+ * The hairline between two runs of nav links. It spans the whole rail, edge to edge, so it
10
+ * reads as a boundary between regions of the rail and meets the rail's own border, as a
11
+ * menu's separator spans its popup.
12
+ */
13
+ export declare function NavSeparator({ className, ...props }: ComponentProps<"hr">): import("react").JSX.Element;
14
+ /**
15
+ * The one nav row, applied to a `ghost` `Button`: every item starts from the same width, inset
16
+ * and gap, and each variant is the shape on top of it. A `link` or `flat` row is 32px tall; the
17
+ * `outline` row is the 32px control height, so it lines up with the toolbar controls. Both
18
+ * heights are fixed rather than padded, so a row leading with a taller visual keeps its size.
19
+ *
20
+ * `link`: a nav link or a settings tab, muted at rest, the subtle fill on hover, and a raised
21
+ * key with dark text when active. A coarse pointer grows the row to 36px, a finger-sized target
22
+ * that keeps the rail compact.
23
+ * The label is the control size, set here so it survives the merge with the Button's own text
24
+ * class. The active state keys off `aria-current="page"`, which router links set on their own
25
+ * and a plain button sets by hand, so the row a screen reader hears as current is the one that
26
+ * looks it.
27
+ *
28
+ * `outline`: an edged row on a card surface, for a row that leads with its own visual and
29
+ * opens a menu, with the hover of a secondary button.
30
+ *
31
+ * `flat`: the same row without the border or the surface.
32
+ */
33
+ export declare const navItem: import("tailwind-variants").TVReturnType<{
34
+ variant: {
35
+ link: string[];
36
+ outline: string;
37
+ flat: string;
38
+ };
39
+ }, undefined, string[], undefined, undefined, undefined>;
@@ -0,0 +1,68 @@
1
+ import { eyebrowClasses } from "../lib/classes.js";
2
+ import { cn, variants } from "../lib/variants.js";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/nav.tsx
5
+ function Nav({ className, ...props }) {
6
+ return /* @__PURE__ */ jsx("nav", {
7
+ className: cn("flex flex-col gap-0.5 px-3 py-2", className),
8
+ ...props
9
+ });
10
+ }
11
+ /**
12
+ * Muted group label above a run of nav links, in sentence case. It starts on the rows' own inset,
13
+ * so the label sits over the rows' leading column rather than hanging off it.
14
+ */
15
+ function NavLabel({ className, ...props }) {
16
+ return /* @__PURE__ */ jsx("p", {
17
+ className: cn("px-2 pt-1.5 pb-1", eyebrowClasses, className),
18
+ ...props
19
+ });
20
+ }
21
+ /**
22
+ * The hairline between two runs of nav links. It spans the whole rail, edge to edge, so it
23
+ * reads as a boundary between regions of the rail and meets the rail's own border, as a
24
+ * menu's separator spans its popup.
25
+ */
26
+ function NavSeparator({ className, ...props }) {
27
+ return /* @__PURE__ */ jsx("hr", {
28
+ className: cn("border-t", className),
29
+ ...props
30
+ });
31
+ }
32
+ /**
33
+ * The one nav row, applied to a `ghost` `Button`: every item starts from the same width, inset
34
+ * and gap, and each variant is the shape on top of it. A `link` or `flat` row is 32px tall; the
35
+ * `outline` row is the 32px control height, so it lines up with the toolbar controls. Both
36
+ * heights are fixed rather than padded, so a row leading with a taller visual keeps its size.
37
+ *
38
+ * `link`: a nav link or a settings tab, muted at rest, the subtle fill on hover, and a raised
39
+ * key with dark text when active. A coarse pointer grows the row to 36px, a finger-sized target
40
+ * that keeps the rail compact.
41
+ * The label is the control size, set here so it survives the merge with the Button's own text
42
+ * class. The active state keys off `aria-current="page"`, which router links set on their own
43
+ * and a plain button sets by hand, so the row a screen reader hears as current is the one that
44
+ * looks it.
45
+ *
46
+ * `outline`: an edged row on a card surface, for a row that leads with its own visual and
47
+ * opens a menu, with the hover of a secondary button.
48
+ *
49
+ * `flat`: the same row without the border or the surface.
50
+ */
51
+ const navItem = variants({
52
+ base: ["w-full justify-start gap-2 px-2 active:not-disabled:not-aria-disabled:translate-y-0 active:not-disabled:not-aria-disabled:bg-fill", "[&>*:first-child]:ml-0 [&>*:last-child]:mr-0"],
53
+ variants: { variant: {
54
+ link: [
55
+ "h-8 pointer-coarse:h-9 border border-transparent text-ink-muted hover:text-ink",
56
+ "text-control",
57
+ "[&>svg]:size-5 [&>svg]:shrink-0 [&>svg]:p-0.5",
58
+ "aria-[current=page]:border-edge-strong aria-[current=page]:bg-surface aria-[current=page]:font-medium aria-[current=page]:text-ink aria-[current=page]:shadow-control",
59
+ "aria-[current=page]:hover:not-aria-disabled:bg-surface"
60
+ ],
61
+ outline: "h-control py-0 bg-surface",
62
+ flat: "h-8"
63
+ } },
64
+ defaultVariants: { variant: "link" }
65
+ });
66
+ export { Nav, NavLabel, NavSeparator, navItem };
67
+
68
+ //# sourceMappingURL=nav.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nav.js","names":[],"sources":["../../src/components/nav.tsx"],"sourcesContent":["import type { ComponentProps } from \"react\"\nimport { eyebrowClasses } from \"../lib/classes\"\nimport { cn, variants } from \"../lib/variants\"\n\nexport function Nav({ className, ...props }: ComponentProps<\"nav\">) {\n return <nav className={cn(\"flex flex-col gap-0.5 px-3 py-2\", className)} {...props} />\n}\n\n/**\n * Muted group label above a run of nav links, in sentence case. It starts on the rows' own inset,\n * so the label sits over the rows' leading column rather than hanging off it.\n */\nexport function NavLabel({ className, ...props }: ComponentProps<\"p\">) {\n return <p className={cn(\"px-2 pt-1.5 pb-1\", eyebrowClasses, className)} {...props} />\n}\n\n/**\n * The hairline between two runs of nav links. It spans the whole rail, edge to edge, so it\n * reads as a boundary between regions of the rail and meets the rail's own border, as a\n * menu's separator spans its popup.\n */\nexport function NavSeparator({ className, ...props }: ComponentProps<\"hr\">) {\n return <hr className={cn(\"border-t\", className)} {...props} />\n}\n\n/**\n * Every nav row leads with a 20px column: the 20px avatar of a row that has one, or the 16px\n * icon of a row that does not, centred in the same box. The Button's optical pull-in on the\n * first and last child is zeroed, so the column starts on the row's own inset and every label\n * in the rail begins on one line.\n */\nconst navAffixClasses = \"[&>*:first-child]:ml-0 [&>*:last-child]:mr-0\"\n\n/**\n * The one nav row, applied to a `ghost` `Button`: every item starts from the same width, inset\n * and gap, and each variant is the shape on top of it. A `link` or `flat` row is 32px tall; the\n * `outline` row is the 32px control height, so it lines up with the toolbar controls. Both\n * heights are fixed rather than padded, so a row leading with a taller visual keeps its size.\n *\n * `link`: a nav link or a settings tab, muted at rest, the subtle fill on hover, and a raised\n * key with dark text when active. A coarse pointer grows the row to 36px, a finger-sized target\n * that keeps the rail compact.\n * The label is the control size, set here so it survives the merge with the Button's own text\n * class. The active state keys off `aria-current=\"page\"`, which router links set on their own\n * and a plain button sets by hand, so the row a screen reader hears as current is the one that\n * looks it.\n *\n * `outline`: an edged row on a card surface, for a row that leads with its own visual and\n * opens a menu, with the hover of a secondary button.\n *\n * `flat`: the same row without the border or the surface.\n */\nexport const navItem = variants({\n // A row runs the rail's full width, so the Button's press would read as the layout moving;\n // the fill is the press feedback here.\n base: [\n \"w-full justify-start gap-2 px-2 active:not-disabled:not-aria-disabled:translate-y-0 active:not-disabled:not-aria-disabled:bg-fill\",\n navAffixClasses,\n ],\n\n variants: {\n variant: {\n link: [\n \"h-8 pointer-coarse:h-9 border border-transparent text-ink-muted hover:text-ink\",\n \"text-control\",\n // A 16px glyph drawn inside the 20px column an avatar fills.\n \"[&>svg]:size-5 [&>svg]:shrink-0 [&>svg]:p-0.5\",\n // The current page is a raised key, the way a segmented control marks its chosen option,\n // and keeps it under the pointer: the longer selector outranks the ghost hover, so a\n // hovered row never looks current and hovering where you are never looks like leaving it.\n \"aria-[current=page]:border-edge-strong aria-[current=page]:bg-surface aria-[current=page]:font-medium aria-[current=page]:text-ink aria-[current=page]:shadow-control\",\n \"aria-[current=page]:hover:not-aria-disabled:bg-surface\",\n ],\n outline: \"h-control py-0 bg-surface\",\n flat: \"h-8\",\n },\n },\n\n defaultVariants: {\n variant: \"link\",\n },\n})\n"],"mappings":";;;;AAIA,SAAgB,IAAI,EAAE,WAAW,GAAG,SAAgC;CAClE,OAAO,oBAAC,OAAD;EAAK,WAAW,GAAG,mCAAmC,SAAS;EAAG,GAAI;CAAQ,CAAA;AACvF;;;;;AAMA,SAAgB,SAAS,EAAE,WAAW,GAAG,SAA8B;CACrE,OAAO,oBAAC,KAAD;EAAG,WAAW,GAAG,oBAAoB,gBAAgB,SAAS;EAAG,GAAI;CAAQ,CAAA;AACtF;;;;;;AAOA,SAAgB,aAAa,EAAE,WAAW,GAAG,SAA+B;CAC1E,OAAO,oBAAC,MAAD;EAAI,WAAW,GAAG,YAAY,SAAS;EAAG,GAAI;CAAQ,CAAA;AAC/D;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,UAAU,SAAS;CAG9B,MAAM,CACJ,qIACA,8CACF;CAEA,UAAU,EACR,SAAS;EACP,MAAM;GACJ;GACA;GAEA;GAIA;GACA;EACF;EACA,SAAS;EACT,MAAM;CACR,EACF;CAEA,iBAAiB,EACf,SAAS,OACX;AACF,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { Input } from "./input.js";
2
+ import { ComponentProps } from "react";
3
+ type NumberInputProps = Omit<ComponentProps<typeof Input>, "value" | "onChange" | "type"> & {
4
+ value: number | null | undefined;
5
+ onValueChange: (value: number | null | undefined) => void;
6
+ integer?: boolean;
7
+ nullable?: boolean;
8
+ };
9
+ /**
10
+ * A numeric input with a typed value. A cleared input yields `undefined` (validates as
11
+ * required instead of "expected number, received NaN"), or `null` when `nullable`, for an
12
+ * optional constraint edited via a partial patch where undefined means "leave unchanged" and
13
+ * only null clears the stored value.
14
+ */
15
+ export declare function NumberInput({ value, onValueChange, integer, nullable, ...props }: NumberInputProps): import("react").JSX.Element;
16
+ export {};
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { Input } from "./input.js";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/number-input.tsx
5
+ /**
6
+ * A numeric input with a typed value. A cleared input yields `undefined` (validates as
7
+ * required instead of "expected number, received NaN"), or `null` when `nullable`, for an
8
+ * optional constraint edited via a partial patch where undefined means "leave unchanged" and
9
+ * only null clears the stored value.
10
+ */
11
+ function NumberInput({ value, onValueChange, integer, nullable, ...props }) {
12
+ function parse(raw) {
13
+ if (raw === "") return nullable ? null : void 0;
14
+ return integer ? Number.parseInt(raw, 10) : Number.parseFloat(raw);
15
+ }
16
+ return /* @__PURE__ */ jsx(Input, {
17
+ type: "number",
18
+ value: value ?? "",
19
+ onChange: (event) => onValueChange(parse(event.target.value)),
20
+ ...props
21
+ });
22
+ }
23
+ export { NumberInput };
24
+
25
+ //# sourceMappingURL=number-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number-input.js","names":[],"sources":["../../src/components/number-input.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ComponentProps } from \"react\"\nimport { Input } from \"./input\"\n\ntype NumberInputProps = Omit<ComponentProps<typeof Input>, \"value\" | \"onChange\" | \"type\"> & {\n value: number | null | undefined\n onValueChange: (value: number | null | undefined) => void\n integer?: boolean\n nullable?: boolean\n}\n\n/**\n * A numeric input with a typed value. A cleared input yields `undefined` (validates as\n * required instead of \"expected number, received NaN\"), or `null` when `nullable`, for an\n * optional constraint edited via a partial patch where undefined means \"leave unchanged\" and\n * only null clears the stored value.\n */\nexport function NumberInput({\n value,\n onValueChange,\n integer,\n nullable,\n ...props\n}: NumberInputProps) {\n function parse(raw: string) {\n if (raw === \"\") return nullable ? null : undefined\n return integer ? Number.parseInt(raw, 10) : Number.parseFloat(raw)\n }\n\n return (\n <Input\n type=\"number\"\n value={value ?? \"\"}\n onChange={event => onValueChange(parse(event.target.value))}\n {...props}\n />\n )\n}\n"],"mappings":";;;;;;;;;;AAkBA,SAAgB,YAAY,EAC1B,OACA,eACA,SACA,UACA,GAAG,SACgB;CACnB,SAAS,MAAM,KAAa;EAC1B,IAAI,QAAQ,IAAI,OAAO,WAAW,OAAO,KAAA;EACzC,OAAO,UAAU,OAAO,SAAS,KAAK,EAAE,IAAI,OAAO,WAAW,GAAG;CACnE;CAEA,OACE,oBAAC,OAAD;EACE,MAAK;EACL,OAAO,SAAS;EAChB,WAAU,UAAS,cAAc,MAAM,MAAM,OAAO,KAAK,CAAC;EAC1D,GAAI;CACL,CAAA;AAEL"}
@@ -0,0 +1,14 @@
1
+ import { VariantProps } from "../lib/variants.js";
2
+ import { ComponentProps } from "react";
3
+ declare const pageVariants: import("tailwind-variants").TVReturnType<{
4
+ width: {
5
+ narrow: string;
6
+ };
7
+ }, undefined, "flex w-full flex-col gap-5", undefined, undefined, undefined>;
8
+ type PageProps = ComponentProps<"div"> & VariantProps<typeof pageVariants>;
9
+ /**
10
+ * The root of a workspace route: owns the vertical rhythm between the page header and its
11
+ * content, so no page sets its own top margins or gaps.
12
+ */
13
+ export declare function Page({ className, width, ...props }: PageProps): import("react").JSX.Element;
14
+ export {};
@@ -0,0 +1,23 @@
1
+ import { variants } from "../lib/variants.js";
2
+ import { jsx } from "react/jsx-runtime";
3
+ // src/components/page.tsx
4
+ const pageVariants = variants({
5
+ base: "flex w-full flex-col gap-5",
6
+ variants: { width: { narrow: "max-w-3xl" } }
7
+ });
8
+ /**
9
+ * The root of a workspace route: owns the vertical rhythm between the page header and its
10
+ * content, so no page sets its own top margins or gaps.
11
+ */
12
+ function Page({ className, width, ...props }) {
13
+ return /* @__PURE__ */ jsx("div", {
14
+ className: pageVariants({
15
+ width,
16
+ className
17
+ }),
18
+ ...props
19
+ });
20
+ }
21
+ export { Page };
22
+
23
+ //# sourceMappingURL=page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page.js","names":[],"sources":["../../src/components/page.tsx"],"sourcesContent":["import type { ComponentProps } from \"react\"\nimport { variants, type VariantProps } from \"../lib/variants\"\n\nconst pageVariants = variants({\n // One rhythm for every workspace page: the header, then each block, 20px apart.\n base: \"flex w-full flex-col gap-5\",\n\n variants: {\n width: {\n // Single-column forms and settings. Left off, the page runs full width: dashboards,\n // lists, detail pages.\n narrow: \"max-w-3xl\",\n },\n },\n})\n\ntype PageProps = ComponentProps<\"div\"> & VariantProps<typeof pageVariants>\n\n/**\n * The root of a workspace route: owns the vertical rhythm between the page header and its\n * content, so no page sets its own top margins or gaps.\n */\nexport function Page({ className, width, ...props }: PageProps) {\n return <div className={pageVariants({ width, className })} {...props} />\n}\n"],"mappings":";;;AAGA,MAAM,eAAe,SAAS;CAE5B,MAAM;CAEN,UAAU,EACR,OAAO,EAGL,QAAQ,YACV,EACF;AACF,CAAC;;;;;AAQD,SAAgB,KAAK,EAAE,WAAW,OAAO,GAAG,SAAoB;CAC9D,OAAO,oBAAC,OAAD;EAAK,WAAW,aAAa;GAAE;GAAO;EAAU,CAAC;EAAG,GAAI;CAAQ,CAAA;AACzE"}
@@ -0,0 +1,73 @@
1
+ import { ComponentProps, ReactNode } from "react";
2
+ /** The figures a count label places, each formatted and styled already. */
3
+ export interface PaginationRange {
4
+ from: ReactNode;
5
+ to: ReactNode;
6
+ total: ReactNode;
7
+ }
8
+ /** The figures of the page label. */
9
+ export interface PaginationPage {
10
+ page: ReactNode;
11
+ pageCount: ReactNode;
12
+ }
13
+ /**
14
+ * The words of the paged band, each a prop so a product can translate them. A label that holds
15
+ * figures is a function of them, so a language can put them in its own order.
16
+ */
17
+ export interface PaginationLabels {
18
+ /** The count: "Showing 26–50 of 1,204". */
19
+ range: (range: PaginationRange) => ReactNode;
20
+ /** The count on a phone: "26–50 of 1,204". */
21
+ rangeShort: (range: PaginationRange) => ReactNode;
22
+ /** "Page 2 of 49". */
23
+ pageOf: (page: PaginationPage) => ReactNode;
24
+ perPage: string;
25
+ firstPage: string;
26
+ previousPage: string;
27
+ nextPage: string;
28
+ lastPage: string;
29
+ }
30
+ interface PaginationProps extends Omit<ComponentProps<"div">, "children"> {
31
+ page: number;
32
+ pageCount: number;
33
+ total: number;
34
+ perPage: number;
35
+ onPageChange: (page: number) => void;
36
+ /** The page sizes the reader picks from. Left out, the band has no per-page select. */
37
+ perPageOptions?: number[];
38
+ onPerPageChange?: (perPage: number) => void;
39
+ /** While a page loads: every control is disabled, and the caller dims the old rows. */
40
+ loading?: boolean;
41
+ /** Formats each figure in the reader's locale. */
42
+ format?: (value: number) => string;
43
+ /** The band's words, English by default. */
44
+ labels?: Partial<PaginationLabels>;
45
+ }
46
+ /**
47
+ * The footer band of a paged table: "Showing 26–50 of 1,204", an optional per-page select,
48
+ * "Page 2 of 49" and the joined first, previous, next and last buttons. A single page keeps the
49
+ * count and drops the controls; an empty table has no band. On a phone the count drops
50
+ * "Showing", and the per-page select and the first and last buttons go. Presentational and
51
+ * router-agnostic: the caller wires `onPageChange` to its search params.
52
+ */
53
+ export declare function Pagination({ page, pageCount, total, perPage, onPageChange, perPageOptions, onPerPageChange, loading, format, labels: labelsProp, className, ...props }: PaginationProps): import("react").JSX.Element | null;
54
+ interface PaginationInfiniteProps extends Omit<ComponentProps<"div">, "children"> {
55
+ /** The count at the start, formatted by the caller: "120 of 4,300 events". */
56
+ count: ReactNode;
57
+ hasMore: boolean;
58
+ loading: boolean;
59
+ onLoadMore: () => void;
60
+ /** False after a failed page: a sentinel still on screen would ask for it again at once. */
61
+ enabled?: boolean;
62
+ /** How far below the viewport the next page starts loading, in pixels. */
63
+ ahead?: number;
64
+ loadingLabel?: ReactNode;
65
+ endLabel?: ReactNode;
66
+ }
67
+ /**
68
+ * The footer band of a table that loads as it scrolls: the count, then "Loading more…" while the
69
+ * next batch loads and "End of list" once there is none. The band itself is the trigger: the
70
+ * next page loads as it nears the viewport. Pass `onLoadMore` a stable callback.
71
+ */
72
+ export declare function PaginationInfinite({ count, hasMore, loading, onLoadMore, enabled, ahead, loadingLabel, endLabel, className, ...props }: PaginationInfiniteProps): import("react").JSX.Element;
73
+ export {};
@@ -0,0 +1,212 @@
1
+ "use client";
2
+ import { ChevronLeftIcon, ChevronRightIcon, ChevronsLeftIcon, ChevronsRightIcon } from "../lib/icons.js";
3
+ import { useLoadMore } from "../lib/load-more.js";
4
+ import { cn } from "../lib/variants.js";
5
+ import { Button } from "./button.js";
6
+ import { ButtonGroup } from "./button-group.js";
7
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./select.js";
8
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
+ import { useId, useState } from "react";
10
+ // src/components/pagination.tsx
11
+ /**
12
+ * 1-based row range shown on the current page, e.g. "26–50 of 42" → { from: 26, to: 42 }.
13
+ */
14
+ function getPageRange(page, perPage, total) {
15
+ if (total === 0) return {
16
+ from: 0,
17
+ to: 0
18
+ };
19
+ const to = Math.min(page * perPage, total);
20
+ return {
21
+ from: Math.min((page - 1) * perPage + 1, to),
22
+ to
23
+ };
24
+ }
25
+ /**
26
+ * The band under a table's rows: a hairline above, the count at the start, the controls at the
27
+ * end. 48px, so the pager's 28px buttons sit 10px from each edge.
28
+ */
29
+ const BAND_CLASSES = "flex h-12 shrink-0 items-center justify-between gap-4 border-t border-edge-subtle pr-3 pl-5 text-ink-muted text-xs tabular-nums";
30
+ /** Figures in the band are ink, the words around them muted. */
31
+ const FIGURE_CLASSES = "text-ink";
32
+ const PAGINATION_LABELS = {
33
+ range: ({ from, to, total }) => /* @__PURE__ */ jsxs(Fragment, { children: [
34
+ "Showing ",
35
+ from,
36
+ "–",
37
+ to,
38
+ " of ",
39
+ total
40
+ ] }),
41
+ rangeShort: ({ from, to, total }) => /* @__PURE__ */ jsxs(Fragment, { children: [
42
+ from,
43
+ "–",
44
+ to,
45
+ " of ",
46
+ total
47
+ ] }),
48
+ pageOf: ({ page, pageCount }) => /* @__PURE__ */ jsxs(Fragment, { children: [
49
+ "Page ",
50
+ page,
51
+ " of ",
52
+ pageCount
53
+ ] }),
54
+ perPage: "Per page",
55
+ firstPage: "First page",
56
+ previousPage: "Previous page",
57
+ nextPage: "Next page",
58
+ lastPage: "Last page"
59
+ };
60
+ /**
61
+ * The footer band of a paged table: "Showing 26–50 of 1,204", an optional per-page select,
62
+ * "Page 2 of 49" and the joined first, previous, next and last buttons. A single page keeps the
63
+ * count and drops the controls; an empty table has no band. On a phone the count drops
64
+ * "Showing", and the per-page select and the first and last buttons go. Presentational and
65
+ * router-agnostic: the caller wires `onPageChange` to its search params.
66
+ */
67
+ function Pagination({ page, pageCount, total, perPage, onPageChange, perPageOptions, onPerPageChange, loading = false, format = String, labels: labelsProp, className, ...props }) {
68
+ const perPageLabelId = useId();
69
+ const labels = {
70
+ ...PAGINATION_LABELS,
71
+ ...labelsProp
72
+ };
73
+ if (total === 0) return null;
74
+ const { from, to } = getPageRange(page, perPage, total);
75
+ const range = {
76
+ from: /* @__PURE__ */ jsx("span", {
77
+ className: FIGURE_CLASSES,
78
+ children: format(from)
79
+ }),
80
+ to: /* @__PURE__ */ jsx("span", {
81
+ className: FIGURE_CLASSES,
82
+ children: format(to)
83
+ }),
84
+ total: /* @__PURE__ */ jsx("span", {
85
+ className: FIGURE_CLASSES,
86
+ children: format(total)
87
+ })
88
+ };
89
+ const first = page <= 1;
90
+ const last = page >= pageCount;
91
+ return /* @__PURE__ */ jsxs("div", {
92
+ "aria-busy": loading || void 0,
93
+ className: cn(BAND_CLASSES, className),
94
+ ...props,
95
+ children: [/* @__PURE__ */ jsxs("p", {
96
+ className: "truncate",
97
+ children: [/* @__PURE__ */ jsx("span", {
98
+ className: "max-sm:hidden",
99
+ children: labels.range(range)
100
+ }), /* @__PURE__ */ jsx("span", {
101
+ className: "sm:hidden",
102
+ children: labels.rangeShort(range)
103
+ })]
104
+ }), pageCount > 1 && /* @__PURE__ */ jsxs("div", {
105
+ className: "flex items-center gap-4",
106
+ children: [
107
+ perPageOptions && onPerPageChange && /* @__PURE__ */ jsxs("div", {
108
+ className: "flex items-center gap-2 max-sm:hidden",
109
+ children: [/* @__PURE__ */ jsx("span", {
110
+ id: perPageLabelId,
111
+ children: labels.perPage
112
+ }), /* @__PURE__ */ jsxs(Select, {
113
+ value: perPage,
114
+ disabled: loading,
115
+ onValueChange: (value) => {
116
+ if (value !== null) onPerPageChange(value);
117
+ },
118
+ children: [/* @__PURE__ */ jsx(SelectTrigger, {
119
+ size: "sm",
120
+ "aria-labelledby": perPageLabelId,
121
+ className: "w-18",
122
+ children: /* @__PURE__ */ jsx(SelectValue, {})
123
+ }), /* @__PURE__ */ jsx(SelectContent, { children: perPageOptions.map((option) => /* @__PURE__ */ jsx(SelectItem, {
124
+ value: option,
125
+ children: format(option)
126
+ }, option)) })]
127
+ })]
128
+ }),
129
+ /* @__PURE__ */ jsx("p", {
130
+ className: "whitespace-nowrap",
131
+ children: labels.pageOf({
132
+ page: /* @__PURE__ */ jsx("span", {
133
+ className: FIGURE_CLASSES,
134
+ children: format(page)
135
+ }),
136
+ pageCount: /* @__PURE__ */ jsx("span", {
137
+ className: FIGURE_CLASSES,
138
+ children: format(pageCount)
139
+ })
140
+ })
141
+ }),
142
+ /* @__PURE__ */ jsxs(ButtonGroup, { children: [
143
+ /* @__PURE__ */ jsx(Button, {
144
+ variant: "secondary",
145
+ size: "sm",
146
+ "aria-label": labels.firstPage,
147
+ prefix: /* @__PURE__ */ jsx(ChevronsLeftIcon, {}),
148
+ disabled: loading || first,
149
+ className: "max-sm:hidden",
150
+ onClick: () => onPageChange(1)
151
+ }),
152
+ /* @__PURE__ */ jsx(Button, {
153
+ variant: "secondary",
154
+ size: "sm",
155
+ "aria-label": labels.previousPage,
156
+ prefix: /* @__PURE__ */ jsx(ChevronLeftIcon, {}),
157
+ disabled: loading || first,
158
+ className: "max-sm:rounded-l-md! max-sm:border-l!",
159
+ onClick: () => onPageChange(page - 1)
160
+ }),
161
+ /* @__PURE__ */ jsx(Button, {
162
+ variant: "secondary",
163
+ size: "sm",
164
+ "aria-label": labels.nextPage,
165
+ prefix: /* @__PURE__ */ jsx(ChevronRightIcon, {}),
166
+ disabled: loading || last,
167
+ className: "max-sm:rounded-r-md!",
168
+ onClick: () => onPageChange(page + 1)
169
+ }),
170
+ /* @__PURE__ */ jsx(Button, {
171
+ variant: "secondary",
172
+ size: "sm",
173
+ "aria-label": labels.lastPage,
174
+ prefix: /* @__PURE__ */ jsx(ChevronsRightIcon, {}),
175
+ disabled: loading || last,
176
+ className: "max-sm:hidden",
177
+ onClick: () => onPageChange(pageCount)
178
+ })
179
+ ] })
180
+ ]
181
+ })]
182
+ });
183
+ }
184
+ /**
185
+ * The footer band of a table that loads as it scrolls: the count, then "Loading more…" while the
186
+ * next batch loads and "End of list" once there is none. The band itself is the trigger: the
187
+ * next page loads as it nears the viewport. Pass `onLoadMore` a stable callback.
188
+ */
189
+ function PaginationInfinite({ count, hasMore, loading, onLoadMore, enabled = true, ahead, loadingLabel = "Loading more…", endLabel = "End of list", className, ...props }) {
190
+ const [sentinel, setSentinel] = useState(null);
191
+ useLoadMore(sentinel, {
192
+ enabled: enabled && hasMore && !loading,
193
+ onLoad: onLoadMore,
194
+ ahead
195
+ });
196
+ return /* @__PURE__ */ jsxs("div", {
197
+ ref: setSentinel,
198
+ "aria-busy": loading || void 0,
199
+ className: cn(BAND_CLASSES, className),
200
+ ...props,
201
+ children: [/* @__PURE__ */ jsx("p", {
202
+ className: "truncate",
203
+ children: count
204
+ }), /* @__PURE__ */ jsx("output", {
205
+ className: "whitespace-nowrap",
206
+ children: loading ? loadingLabel : hasMore ? null : endLabel
207
+ })]
208
+ });
209
+ }
210
+ export { Pagination, PaginationInfinite };
211
+
212
+ //# sourceMappingURL=pagination.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.js","names":[],"sources":["../../src/components/pagination.tsx"],"sourcesContent":["\"use client\"\n\nimport { type ComponentProps, type ReactNode, useId, useState } from \"react\"\nimport {\n ChevronLeftIcon,\n ChevronRightIcon,\n ChevronsLeftIcon,\n ChevronsRightIcon,\n} from \"../lib/icons\"\nimport { useLoadMore } from \"../lib/load-more\"\nimport { cn } from \"../lib/variants\"\nimport { Button } from \"./button\"\nimport { ButtonGroup } from \"./button-group\"\nimport { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from \"./select\"\n\n/**\n * 1-based row range shown on the current page, e.g. \"26–50 of 42\" → { from: 26, to: 42 }.\n */\nfunction getPageRange(page: number, perPage: number, total: number) {\n if (total === 0) return { from: 0, to: 0 }\n const to = Math.min(page * perPage, total)\n // A page past the end (a stale link, rows deleted since) reads as the last row, not \"51–50\".\n return { from: Math.min((page - 1) * perPage + 1, to), to }\n}\n\n/**\n * The band under a table's rows: a hairline above, the count at the start, the controls at the\n * end. 48px, so the pager's 28px buttons sit 10px from each edge.\n */\nconst BAND_CLASSES =\n \"flex h-12 shrink-0 items-center justify-between gap-4 border-t border-edge-subtle pr-3 pl-5 text-ink-muted text-xs tabular-nums\"\n\n/** Figures in the band are ink, the words around them muted. */\nconst FIGURE_CLASSES = \"text-ink\"\n\n/** The figures a count label places, each formatted and styled already. */\nexport interface PaginationRange {\n from: ReactNode\n to: ReactNode\n total: ReactNode\n}\n\n/** The figures of the page label. */\nexport interface PaginationPage {\n page: ReactNode\n pageCount: ReactNode\n}\n\n/**\n * The words of the paged band, each a prop so a product can translate them. A label that holds\n * figures is a function of them, so a language can put them in its own order.\n */\nexport interface PaginationLabels {\n /** The count: \"Showing 26–50 of 1,204\". */\n range: (range: PaginationRange) => ReactNode\n /** The count on a phone: \"26–50 of 1,204\". */\n rangeShort: (range: PaginationRange) => ReactNode\n /** \"Page 2 of 49\". */\n pageOf: (page: PaginationPage) => ReactNode\n perPage: string\n firstPage: string\n previousPage: string\n nextPage: string\n lastPage: string\n}\n\nconst PAGINATION_LABELS: PaginationLabels = {\n range: ({ from, to, total }) => (\n <>\n Showing {from}–{to} of {total}\n </>\n ),\n rangeShort: ({ from, to, total }) => (\n <>\n {from}–{to} of {total}\n </>\n ),\n pageOf: ({ page, pageCount }) => (\n <>\n Page {page} of {pageCount}\n </>\n ),\n perPage: \"Per page\",\n firstPage: \"First page\",\n previousPage: \"Previous page\",\n nextPage: \"Next page\",\n lastPage: \"Last page\",\n}\n\ninterface PaginationProps extends Omit<ComponentProps<\"div\">, \"children\"> {\n page: number\n pageCount: number\n total: number\n perPage: number\n onPageChange: (page: number) => void\n /** The page sizes the reader picks from. Left out, the band has no per-page select. */\n perPageOptions?: number[]\n onPerPageChange?: (perPage: number) => void\n /** While a page loads: every control is disabled, and the caller dims the old rows. */\n loading?: boolean\n /** Formats each figure in the reader's locale. */\n format?: (value: number) => string\n /** The band's words, English by default. */\n labels?: Partial<PaginationLabels>\n}\n\n/**\n * The footer band of a paged table: \"Showing 26–50 of 1,204\", an optional per-page select,\n * \"Page 2 of 49\" and the joined first, previous, next and last buttons. A single page keeps the\n * count and drops the controls; an empty table has no band. On a phone the count drops\n * \"Showing\", and the per-page select and the first and last buttons go. Presentational and\n * router-agnostic: the caller wires `onPageChange` to its search params.\n */\nexport function Pagination({\n page,\n pageCount,\n total,\n perPage,\n onPageChange,\n perPageOptions,\n onPerPageChange,\n loading = false,\n format = String,\n labels: labelsProp,\n className,\n ...props\n}: PaginationProps) {\n const perPageLabelId = useId()\n const labels = { ...PAGINATION_LABELS, ...labelsProp }\n if (total === 0) return null\n\n const { from, to } = getPageRange(page, perPage, total)\n const range = {\n from: <span className={FIGURE_CLASSES}>{format(from)}</span>,\n to: <span className={FIGURE_CLASSES}>{format(to)}</span>,\n total: <span className={FIGURE_CLASSES}>{format(total)}</span>,\n }\n const first = page <= 1\n const last = page >= pageCount\n\n return (\n <div aria-busy={loading || undefined} className={cn(BAND_CLASSES, className)} {...props}>\n <p className=\"truncate\">\n <span className=\"max-sm:hidden\">{labels.range(range)}</span>\n <span className=\"sm:hidden\">{labels.rangeShort(range)}</span>\n </p>\n\n {pageCount > 1 && (\n <div className=\"flex items-center gap-4\">\n {perPageOptions && onPerPageChange && (\n <div className=\"flex items-center gap-2 max-sm:hidden\">\n <span id={perPageLabelId}>{labels.perPage}</span>\n <Select\n value={perPage}\n disabled={loading}\n onValueChange={value => {\n if (value !== null) onPerPageChange(value)\n }}\n >\n <SelectTrigger size=\"sm\" aria-labelledby={perPageLabelId} className=\"w-18\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {perPageOptions.map(option => (\n <SelectItem key={option} value={option}>\n {format(option)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n )}\n\n <p className=\"whitespace-nowrap\">\n {labels.pageOf({\n page: <span className={FIGURE_CLASSES}>{format(page)}</span>,\n pageCount: <span className={FIGURE_CLASSES}>{format(pageCount)}</span>,\n })}\n </p>\n\n <ButtonGroup>\n <Button\n variant=\"secondary\"\n size=\"sm\"\n aria-label={labels.firstPage}\n prefix={<ChevronsLeftIcon />}\n disabled={loading || first}\n className=\"max-sm:hidden\"\n onClick={() => onPageChange(1)}\n />\n {/* On a phone the first and last buttons are gone, so the inner two take the\n group's ends: their outer corners and the left edge the group drops. Marked\n important, since the group's rules for its members outrank a member's own. */}\n <Button\n variant=\"secondary\"\n size=\"sm\"\n aria-label={labels.previousPage}\n prefix={<ChevronLeftIcon />}\n disabled={loading || first}\n className=\"max-sm:rounded-l-md! max-sm:border-l!\"\n onClick={() => onPageChange(page - 1)}\n />\n <Button\n variant=\"secondary\"\n size=\"sm\"\n aria-label={labels.nextPage}\n prefix={<ChevronRightIcon />}\n disabled={loading || last}\n className=\"max-sm:rounded-r-md!\"\n onClick={() => onPageChange(page + 1)}\n />\n <Button\n variant=\"secondary\"\n size=\"sm\"\n aria-label={labels.lastPage}\n prefix={<ChevronsRightIcon />}\n disabled={loading || last}\n className=\"max-sm:hidden\"\n onClick={() => onPageChange(pageCount)}\n />\n </ButtonGroup>\n </div>\n )}\n </div>\n )\n}\n\ninterface PaginationInfiniteProps extends Omit<ComponentProps<\"div\">, \"children\"> {\n /** The count at the start, formatted by the caller: \"120 of 4,300 events\". */\n count: ReactNode\n hasMore: boolean\n loading: boolean\n onLoadMore: () => void\n /** False after a failed page: a sentinel still on screen would ask for it again at once. */\n enabled?: boolean\n /** How far below the viewport the next page starts loading, in pixels. */\n ahead?: number\n loadingLabel?: ReactNode\n endLabel?: ReactNode\n}\n\n/**\n * The footer band of a table that loads as it scrolls: the count, then \"Loading more…\" while the\n * next batch loads and \"End of list\" once there is none. The band itself is the trigger: the\n * next page loads as it nears the viewport. Pass `onLoadMore` a stable callback.\n */\nexport function PaginationInfinite({\n count,\n hasMore,\n loading,\n onLoadMore,\n enabled = true,\n ahead,\n loadingLabel = \"Loading more…\",\n endLabel = \"End of list\",\n className,\n ...props\n}: PaginationInfiniteProps) {\n const [sentinel, setSentinel] = useState<HTMLDivElement | null>(null)\n\n useLoadMore(sentinel, { enabled: enabled && hasMore && !loading, onLoad: onLoadMore, ahead })\n\n return (\n <div\n ref={setSentinel}\n aria-busy={loading || undefined}\n className={cn(BAND_CLASSES, className)}\n {...props}\n >\n <p className=\"truncate\">{count}</p>\n <output className=\"whitespace-nowrap\">\n {loading ? loadingLabel : hasMore ? null : endLabel}\n </output>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;;AAkBA,SAAS,aAAa,MAAc,SAAiB,OAAe;CAClE,IAAI,U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