@slashsuite/ui-react 0.12.1 → 0.13.1

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 (385) hide show
  1. package/MIGRATING.md +386 -8
  2. package/README.md +89 -44
  3. package/agent-docs/components/app-shell.md +9 -6
  4. package/agent-docs/components/article-layout.md +140 -0
  5. package/agent-docs/components/audio.md +42 -0
  6. package/agent-docs/components/badge.md +2 -1
  7. package/agent-docs/components/body-text.md +26 -15
  8. package/agent-docs/components/bottom-sheet.md +27 -17
  9. package/agent-docs/components/breadcrumbs.md +10 -6
  10. package/agent-docs/components/button.md +2 -2
  11. package/agent-docs/components/call-to-action.md +59 -0
  12. package/agent-docs/components/callout.md +4 -3
  13. package/agent-docs/components/card-grid.md +15 -7
  14. package/agent-docs/components/card.md +33 -18
  15. package/agent-docs/components/cart-button.md +63 -0
  16. package/agent-docs/components/chat-composer.md +4 -3
  17. package/agent-docs/components/checkbox.md +11 -5
  18. package/agent-docs/components/cluster.md +10 -8
  19. package/agent-docs/components/code-example.md +2 -2
  20. package/agent-docs/components/code.md +7 -5
  21. package/agent-docs/components/colour-scheme-toggle.md +12 -6
  22. package/agent-docs/components/colour-swatch.md +41 -0
  23. package/agent-docs/components/combobox.md +88 -0
  24. package/agent-docs/components/confirm-dialog.md +98 -0
  25. package/agent-docs/components/container.md +2 -1
  26. package/agent-docs/components/copy-button.md +7 -5
  27. package/agent-docs/components/copy-line.md +6 -5
  28. package/agent-docs/components/date-field.md +14 -11
  29. package/agent-docs/components/date-range-picker.md +16 -9
  30. package/agent-docs/components/date-time-field.md +73 -0
  31. package/agent-docs/components/dialog.md +22 -68
  32. package/agent-docs/components/disclosure.md +4 -0
  33. package/agent-docs/components/docs-layout.md +10 -6
  34. package/agent-docs/components/drawer.md +13 -4
  35. package/agent-docs/components/embed-frame.md +48 -0
  36. package/agent-docs/components/empty-state.md +4 -1
  37. package/agent-docs/components/field-dialog.md +6 -5
  38. package/agent-docs/components/field.md +10 -7
  39. package/agent-docs/components/fieldset.md +4 -4
  40. package/agent-docs/components/flow-diagram.md +87 -0
  41. package/agent-docs/components/form-layout.md +4 -1
  42. package/agent-docs/components/form-row.md +7 -7
  43. package/agent-docs/components/full-bleed-layout.md +0 -2
  44. package/agent-docs/components/headings.md +13 -7
  45. package/agent-docs/components/hero.md +11 -2
  46. package/agent-docs/components/icon-button.md +1 -3
  47. package/agent-docs/components/icon.md +6 -13
  48. package/agent-docs/components/image.md +24 -14
  49. package/agent-docs/components/input.md +8 -7
  50. package/agent-docs/components/key-value-list.md +4 -1
  51. package/agent-docs/components/lightbox.md +1 -1
  52. package/agent-docs/components/list-layout.md +5 -7
  53. package/agent-docs/components/list-row.md +37 -34
  54. package/agent-docs/components/loading.md +2 -2
  55. package/agent-docs/components/markdown.md +13 -13
  56. package/agent-docs/components/media-tile.md +8 -4
  57. package/agent-docs/components/menu.md +19 -12
  58. package/agent-docs/components/meta-list.md +2 -2
  59. package/agent-docs/components/morph.md +11 -5
  60. package/agent-docs/components/navigation-progress.md +2 -2
  61. package/agent-docs/components/number-field.md +75 -0
  62. package/agent-docs/components/outline-region.md +19 -8
  63. package/agent-docs/components/page-fade.md +2 -1
  64. package/agent-docs/components/pill.md +7 -6
  65. package/agent-docs/components/popover.md +63 -0
  66. package/agent-docs/components/price.md +49 -0
  67. package/agent-docs/components/product-tile.md +78 -0
  68. package/agent-docs/components/promo-banner.md +46 -0
  69. package/agent-docs/components/prose-layout.md +1 -1
  70. package/agent-docs/components/radio-group.md +9 -6
  71. package/agent-docs/components/scroll-strip.md +3 -3
  72. package/agent-docs/components/segmented-control.md +4 -2
  73. package/agent-docs/components/select.md +8 -3
  74. package/agent-docs/components/show.md +2 -2
  75. package/agent-docs/components/side-column.md +13 -9
  76. package/agent-docs/components/sidebar-layout.md +1 -1
  77. package/agent-docs/components/site-footer.md +4 -4
  78. package/agent-docs/components/site-search.md +21 -9
  79. package/agent-docs/components/slider.md +59 -0
  80. package/agent-docs/components/sortable-list.md +15 -10
  81. package/agent-docs/components/stack.md +3 -3
  82. package/agent-docs/components/stacked-bar.md +7 -4
  83. package/agent-docs/components/state-machine.md +95 -0
  84. package/agent-docs/components/status-pages.md +13 -6
  85. package/agent-docs/components/stepper.md +54 -0
  86. package/agent-docs/components/switch.md +4 -4
  87. package/agent-docs/components/table-of-contents.md +78 -0
  88. package/agent-docs/components/table.md +35 -24
  89. package/agent-docs/components/tabs.md +24 -26
  90. package/agent-docs/components/text-link.md +12 -7
  91. package/agent-docs/components/textarea.md +4 -2
  92. package/agent-docs/components/toast.md +19 -14
  93. package/agent-docs/components/video.md +7 -2
  94. package/agent-docs/llms.txt +22 -3
  95. package/dist/AppShell.d.ts +25 -9
  96. package/dist/AppShell.js +67 -33
  97. package/dist/AppShellMenu.d.ts +31 -18
  98. package/dist/AppShellMenu.js +72 -45
  99. package/dist/ArticleLayout.d.ts +36 -0
  100. package/dist/ArticleLayout.js +27 -0
  101. package/dist/Audio.d.ts +16 -0
  102. package/dist/Audio.js +11 -0
  103. package/dist/Badge.d.ts +2 -1
  104. package/dist/Badge.js +3 -2
  105. package/dist/BottomSheet.d.ts +17 -6
  106. package/dist/BottomSheet.js +62 -11
  107. package/dist/Breadcrumbs.d.ts +8 -6
  108. package/dist/Breadcrumbs.js +17 -7
  109. package/dist/Button.d.ts +4 -2
  110. package/dist/Button.js +9 -87
  111. package/dist/CallToAction.d.ts +25 -0
  112. package/dist/CallToAction.js +17 -0
  113. package/dist/Callout.d.ts +2 -2
  114. package/dist/Callout.js +2 -2
  115. package/dist/Card.d.ts +88 -31
  116. package/dist/Card.js +55 -92
  117. package/dist/CardBody.d.ts +2 -0
  118. package/dist/CardBody.js +33 -3
  119. package/dist/CardGrid.d.ts +32 -4
  120. package/dist/CardGrid.js +42 -8
  121. package/dist/CardParts.d.ts +7 -1
  122. package/dist/CardParts.js +7 -2
  123. package/dist/CartButton.d.ts +33 -0
  124. package/dist/CartButton.js +18 -0
  125. package/dist/ChatComposer.d.ts +10 -4
  126. package/dist/ChatComposer.js +35 -13
  127. package/dist/Checkbox.d.ts +21 -3
  128. package/dist/Checkbox.js +66 -20
  129. package/dist/Chevron.js +1 -1
  130. package/dist/Cluster.d.ts +28 -15
  131. package/dist/Cluster.js +21 -4
  132. package/dist/Code.d.ts +15 -3
  133. package/dist/Code.js +23 -3
  134. package/dist/CodeBlock.d.ts +4 -4
  135. package/dist/CodeBlock.js +2 -2
  136. package/dist/CodeBody.d.ts +1 -1
  137. package/dist/CodeBody.js +4 -10
  138. package/dist/CodeExample.d.ts +1 -1
  139. package/dist/CodeExample.js +3 -2
  140. package/dist/ColourSchemeToggle.d.ts +21 -5
  141. package/dist/ColourSchemeToggle.js +15 -9
  142. package/dist/ColourSwatch.d.ts +15 -0
  143. package/dist/ColourSwatch.js +14 -0
  144. package/dist/Combobox.d.ts +42 -0
  145. package/dist/Combobox.js +43 -0
  146. package/dist/ConfirmDialog.d.ts +40 -0
  147. package/dist/ConfirmDialog.js +36 -0
  148. package/dist/Container.d.ts +3 -3
  149. package/dist/Container.js +1 -1
  150. package/dist/CopyButton.d.ts +8 -2
  151. package/dist/CopyButton.js +38 -28
  152. package/dist/CopyLine.d.ts +4 -2
  153. package/dist/CopyLine.js +4 -4
  154. package/dist/DateCalendar.d.ts +2 -0
  155. package/dist/DateCalendar.js +11 -9
  156. package/dist/DateField.d.ts +52 -21
  157. package/dist/DateField.js +73 -37
  158. package/dist/DateFieldCalendar.d.ts +12 -8
  159. package/dist/DateFieldCalendar.js +37 -18
  160. package/dist/DateRangePicker.d.ts +23 -3
  161. package/dist/DateRangePicker.js +10 -8
  162. package/dist/DateTimeField.d.ts +31 -0
  163. package/dist/DateTimeField.js +19 -0
  164. package/dist/Dialog.d.ts +42 -6
  165. package/dist/Dialog.js +50 -12
  166. package/dist/Disclosure.js +9 -1
  167. package/dist/DocsLayout.d.ts +13 -5
  168. package/dist/DocsLayout.js +11 -9
  169. package/dist/Drawer.d.ts +22 -7
  170. package/dist/Drawer.js +89 -8
  171. package/dist/EmbedFrame.d.ts +36 -0
  172. package/dist/EmbedFrame.js +18 -0
  173. package/dist/Field.d.ts +41 -4
  174. package/dist/Field.js +61 -25
  175. package/dist/FieldDialog.d.ts +8 -3
  176. package/dist/FieldDialog.js +19 -9
  177. package/dist/Fieldset.d.ts +3 -3
  178. package/dist/Fieldset.js +7 -9
  179. package/dist/FileDrop.js +2 -1
  180. package/dist/FlowDiagram.d.ts +92 -0
  181. package/dist/FlowDiagram.js +100 -0
  182. package/dist/FormRow.d.ts +6 -4
  183. package/dist/FormRow.js +11 -9
  184. package/dist/Hero.d.ts +30 -7
  185. package/dist/Hero.js +23 -9
  186. package/dist/Icon.d.ts +1 -1
  187. package/dist/Icon.js +1 -1
  188. package/dist/IconButton.js +1 -1
  189. package/dist/Image.d.ts +33 -9
  190. package/dist/Image.js +61 -16
  191. package/dist/Input.d.ts +1 -1
  192. package/dist/Input.js +4 -4
  193. package/dist/InputShell.d.ts +7 -0
  194. package/dist/InputShell.js +18 -3
  195. package/dist/KeyValueList.d.ts +2 -2
  196. package/dist/Lightbox.js +5 -3
  197. package/dist/ListRow.d.ts +4 -5
  198. package/dist/ListRow.js +36 -26
  199. package/dist/Mark.d.ts +10 -0
  200. package/dist/Mark.js +9 -0
  201. package/dist/Markdown.d.ts +18 -4
  202. package/dist/Markdown.js +176 -37
  203. package/dist/MediaTile.d.ts +9 -3
  204. package/dist/MediaTile.js +8 -4
  205. package/dist/Menu.d.ts +19 -8
  206. package/dist/Menu.js +13 -11
  207. package/dist/MetaList.d.ts +4 -3
  208. package/dist/MetaList.js +12 -4
  209. package/dist/Morph.d.ts +15 -1
  210. package/dist/Morph.js +70 -22
  211. package/dist/NavigationProgress.d.ts +2 -2
  212. package/dist/NavigationProgress.js +7 -5
  213. package/dist/NumberField.d.ts +66 -0
  214. package/dist/NumberField.js +68 -0
  215. package/dist/OutlineRegion.d.ts +41 -10
  216. package/dist/OutlineRegion.js +31 -6
  217. package/dist/PageFade.d.ts +9 -5
  218. package/dist/PageFade.js +39 -8
  219. package/dist/PageLayouts.d.ts +15 -5
  220. package/dist/PageLayouts.js +3 -3
  221. package/dist/Pill.d.ts +9 -4
  222. package/dist/Pill.js +15 -6
  223. package/dist/Popover.d.ts +31 -0
  224. package/dist/Popover.js +43 -0
  225. package/dist/Price.d.ts +21 -0
  226. package/dist/Price.js +34 -0
  227. package/dist/ProductTile.d.ts +36 -0
  228. package/dist/ProductTile.js +31 -0
  229. package/dist/ProgressBar.js +4 -2
  230. package/dist/PromoBanner.d.ts +25 -0
  231. package/dist/PromoBanner.js +16 -0
  232. package/dist/RadioGroup.d.ts +18 -8
  233. package/dist/RadioGroup.js +42 -18
  234. package/dist/ScrollStrip.d.ts +1 -1
  235. package/dist/ScrollStrip.js +1 -1
  236. package/dist/SearchInput.d.ts +17 -2
  237. package/dist/SearchInput.js +72 -13
  238. package/dist/SegmentedField.d.ts +15 -0
  239. package/dist/SegmentedField.js +15 -0
  240. package/dist/Select.js +5 -4
  241. package/dist/Show.d.ts +1 -1
  242. package/dist/Show.js +1 -1
  243. package/dist/SideColumn.d.ts +42 -15
  244. package/dist/SideColumn.js +45 -19
  245. package/dist/SiteFooter.d.ts +3 -3
  246. package/dist/SiteFooter.js +4 -3
  247. package/dist/SiteSearch.d.ts +57 -27
  248. package/dist/SiteSearch.js +13 -93
  249. package/dist/Slider.d.ts +27 -0
  250. package/dist/Slider.js +58 -0
  251. package/dist/SortableList.d.ts +19 -35
  252. package/dist/SortableList.js +36 -88
  253. package/dist/Stack.d.ts +4 -4
  254. package/dist/StackedBar.d.ts +13 -4
  255. package/dist/StackedBar.js +12 -7
  256. package/dist/StateMachine.d.ts +65 -0
  257. package/dist/StateMachine.js +116 -0
  258. package/dist/StatusPages.d.ts +28 -10
  259. package/dist/StatusPages.js +10 -10
  260. package/dist/Stepper.d.ts +21 -0
  261. package/dist/Stepper.js +33 -0
  262. package/dist/Steps.js +4 -3
  263. package/dist/Switch.d.ts +3 -3
  264. package/dist/Switch.js +18 -14
  265. package/dist/Table.d.ts +32 -9
  266. package/dist/Table.js +50 -20
  267. package/dist/TableCells.d.ts +24 -21
  268. package/dist/TableCells.js +68 -27
  269. package/dist/TableEditCell.d.ts +1 -1
  270. package/dist/TableOfContents.d.ts +34 -0
  271. package/dist/TableOfContents.js +23 -0
  272. package/dist/Tabs.d.ts +31 -16
  273. package/dist/Tabs.js +97 -22
  274. package/dist/TextLink.d.ts +18 -5
  275. package/dist/TextLink.js +19 -6
  276. package/dist/Textarea.d.ts +12 -1
  277. package/dist/Textarea.js +15 -2
  278. package/dist/ToastRegion.d.ts +17 -9
  279. package/dist/ToastRegion.js +70 -13
  280. package/dist/Tooltip.d.ts +10 -2
  281. package/dist/Tooltip.js +32 -11
  282. package/dist/Video.d.ts +19 -4
  283. package/dist/Video.js +15 -5
  284. package/dist/cardContext.d.ts +7 -0
  285. package/dist/cardContext.js +14 -0
  286. package/dist/cardControl.d.ts +15 -0
  287. package/dist/cardControl.js +32 -0
  288. package/dist/cardForm.d.ts +39 -0
  289. package/dist/cardForm.js +81 -0
  290. package/dist/cardWait.js +2 -1
  291. package/dist/colourScheme.d.ts +12 -2
  292. package/dist/colourScheme.js +32 -6
  293. package/dist/control.d.ts +30 -8
  294. package/dist/control.js +74 -7
  295. package/dist/copyScript.d.ts +7 -8
  296. package/dist/copyScript.js +8 -9
  297. package/dist/core/button.d.ts +33 -0
  298. package/dist/core/button.js +89 -0
  299. package/dist/core/control.d.ts +15 -0
  300. package/dist/core/control.js +14 -0
  301. package/dist/core/fixtures/button.d.ts +26 -0
  302. package/dist/core/fixtures/button.js +52 -0
  303. package/dist/core/fixtures/types.d.ts +13 -0
  304. package/dist/core/fixtures/types.js +10 -0
  305. package/dist/core/focus.d.ts +7 -0
  306. package/dist/core/focus.js +7 -0
  307. package/dist/core/index.d.ts +12 -0
  308. package/dist/core/index.js +12 -0
  309. package/dist/core/parity.d.ts +22 -0
  310. package/dist/core/parity.js +53 -0
  311. package/dist/core/themeNative.d.ts +62 -0
  312. package/dist/core/themeNative.js +290 -0
  313. package/dist/cx.d.ts +17 -5
  314. package/dist/cx.js +18 -5
  315. package/dist/dateLocale.d.ts +17 -0
  316. package/dist/dateLocale.js +30 -0
  317. package/dist/density.d.ts +17 -3
  318. package/dist/density.js +30 -19
  319. package/dist/emptySlot.d.ts +1 -0
  320. package/dist/fieldAnnounce.d.ts +11 -0
  321. package/dist/fieldAnnounce.js +36 -0
  322. package/dist/fieldControl.d.ts +7 -2
  323. package/dist/fieldControl.js +6 -2
  324. package/dist/fieldWait.d.ts +3 -3
  325. package/dist/fieldWait.js +3 -4
  326. package/dist/flowLayout.d.ts +68 -0
  327. package/dist/flowLayout.js +105 -0
  328. package/dist/focus.d.ts +2 -0
  329. package/dist/focus.js +9 -0
  330. package/dist/fromXState.d.ts +73 -0
  331. package/dist/fromXState.js +110 -0
  332. package/dist/icons.d.ts +1 -1
  333. package/dist/icons.js +15 -0
  334. package/dist/index.d.ts +37 -11
  335. package/dist/index.js +24 -2
  336. package/dist/isoDate.d.ts +8 -1
  337. package/dist/isoDate.js +20 -1
  338. package/dist/labelWords.d.ts +16 -7
  339. package/dist/labelWords.js +14 -12
  340. package/dist/listRowProps.d.ts +17 -15
  341. package/dist/modal.d.ts +5 -0
  342. package/dist/modal.js +21 -1
  343. package/dist/navFold.js +6 -3
  344. package/dist/optionCard.d.ts +18 -0
  345. package/dist/optionCard.js +16 -0
  346. package/dist/scrollBody.d.ts +16 -0
  347. package/dist/scrollBody.js +15 -0
  348. package/dist/scrollEdges.d.ts +7 -0
  349. package/dist/scrollEdges.js +39 -5
  350. package/dist/scrollStop.d.ts +6 -2
  351. package/dist/scrollStop.js +24 -8
  352. package/dist/shownDate.d.ts +28 -10
  353. package/dist/shownDate.js +41 -22
  354. package/dist/siteSearchBody.d.ts +34 -0
  355. package/dist/siteSearchBody.js +117 -0
  356. package/dist/size.d.ts +7 -1
  357. package/dist/sortableDrop.d.ts +44 -0
  358. package/dist/sortableDrop.js +78 -0
  359. package/dist/sortableSlide.d.ts +9 -0
  360. package/dist/sortableSlide.js +70 -0
  361. package/dist/sortableTitle.d.ts +10 -0
  362. package/dist/sortableTitle.js +48 -0
  363. package/dist/stateMachineDots.d.ts +77 -0
  364. package/dist/stateMachineDots.js +188 -0
  365. package/dist/stickyColumn.d.ts +2 -2
  366. package/dist/stickyColumn.js +2 -2
  367. package/dist/switcher.d.ts +10 -5
  368. package/dist/switcher.js +7 -5
  369. package/dist/tableColumns.d.ts +17 -0
  370. package/dist/tableColumns.js +30 -2
  371. package/dist/tableEmpty.js +5 -5
  372. package/dist/tableRow.d.ts +26 -2
  373. package/dist/tableRow.js +23 -1
  374. package/dist/tableSort.d.ts +10 -5
  375. package/dist/tableSort.js +15 -4
  376. package/dist/target.d.ts +12 -0
  377. package/dist/target.js +12 -0
  378. package/dist/textBox.js +1 -1
  379. package/dist/truncated.d.ts +31 -0
  380. package/dist/truncated.js +51 -0
  381. package/dist/typography.d.ts +19 -11
  382. package/dist/typography.js +11 -13
  383. package/dist/useFlowLayout.d.ts +38 -0
  384. package/dist/useFlowLayout.js +122 -0
  385. package/package.json +5 -3
package/dist/isoDate.d.ts CHANGED
@@ -1,5 +1,12 @@
1
- import { CalendarDate } from "@internationalized/date";
1
+ import { CalendarDate, CalendarDateTime } from "@internationalized/date";
2
2
  /** `"1990-05-17"` for `CalendarDate(1990, 5, 17)`; `""` for no date, so it drops into a form field. */
3
3
  export declare function toISODate(date: CalendarDate | null | undefined): string;
4
4
  /** The `CalendarDate` of a `"YYYY-MM-DD"` string; `null` for an empty, malformed or impossible one. */
5
5
  export declare function fromISODate(iso: string | null | undefined): CalendarDate | null;
6
+ /** `"2026-11-29T14:30"` for `CalendarDateTime(2026, 11, 29, 14, 30)`, seconds dropped; `""` for none. */
7
+ export declare function toISODateTime(value: CalendarDateTime | null | undefined): string;
8
+ /**
9
+ * The `CalendarDateTime` of a `"YYYY-MM-DDTHH:mm"` string; `null` for an empty, malformed or
10
+ * impossible one (a day the month does not have, an hour past 23).
11
+ */
12
+ export declare function fromISODateTime(iso: string | null | undefined): CalendarDateTime | null;
package/dist/isoDate.js CHANGED
@@ -1,4 +1,4 @@
1
- import { CalendarDate } from "@internationalized/date";
1
+ import { CalendarDate, CalendarDateTime } from "@internationalized/date";
2
2
  const ISO_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
3
3
  /** `"1990-05-17"` for `CalendarDate(1990, 5, 17)`; `""` for no date, so it drops into a form field. */
4
4
  export function toISODate(date) {
@@ -14,3 +14,22 @@ export function fromISODate(iso) {
14
14
  // CalendarDate constrains 1990-02-31 to 1990-02-28; a string that does not survive is impossible.
15
15
  return date.toString() === iso ? date : null;
16
16
  }
17
+ const ISO_DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/;
18
+ /** `"2026-11-29T14:30"` for `CalendarDateTime(2026, 11, 29, 14, 30)`, seconds dropped; `""` for none. */
19
+ export function toISODateTime(value) {
20
+ return value ? value.toString().slice(0, 16) : "";
21
+ }
22
+ /**
23
+ * The `CalendarDateTime` of a `"YYYY-MM-DDTHH:mm"` string; `null` for an empty, malformed or
24
+ * impossible one (a day the month does not have, an hour past 23).
25
+ */
26
+ export function fromISODateTime(iso) {
27
+ const match = ISO_DATE_TIME.exec(iso ?? "");
28
+ if (!match)
29
+ return null;
30
+ const [year, month, day, hour, minute] = [1, 2, 3, 4, 5].map((at) => Number(match[at]));
31
+ if (Number(hour) > 23 || Number(minute) > 59)
32
+ return null;
33
+ const value = new CalendarDateTime(Number(year), Number(month), Number(day), Number(hour), Number(minute));
34
+ return toISODateTime(value) === iso ? value : null;
35
+ }
@@ -1,20 +1,29 @@
1
1
  import { type ReactNode } from "react";
2
+ /** The ids of a choice's two note lines. */
3
+ export type NoteIds = {
4
+ hint: string;
5
+ error: string;
6
+ };
2
7
  /**
3
- * The label, with its note under it when there is one: the error (`role="alert"`, red) when set,
4
- * else the muted hint.
8
+ * The label, with its notes under it when there are any: the muted hint, and under it the error
9
+ * (an alert icon and red text, announced politely) when set. The hint stays while the error shows.
5
10
  */
6
- export declare function Words({ label, hint, error, id, }: {
11
+ export declare function Words({ label, hint, error, ids, }: {
7
12
  label: ReactNode;
8
13
  hint: ReactNode;
9
14
  error: ReactNode;
10
- id: string | undefined;
15
+ ids: NoteIds | undefined;
11
16
  }): ReactNode;
12
17
  /**
13
- * The note's id (none without a hint or an error), the control's whole `aria-describedby`, and
14
- * whether it is invalid (an error is set). The error replaces the hint, as in a `Field`.
18
+ * The notes' ids (none without a hint or an error), the control's whole `aria-describedby` (the
19
+ * caller's, then the hint, then the error), and whether it is invalid (an error is set), as in a
20
+ * `Field`.
15
21
  */
16
22
  export declare function useNote(hint: ReactNode, error: ReactNode, describedBy: string | undefined): {
17
- noteId: string | undefined;
23
+ ids: {
24
+ hint: string;
25
+ error: string;
26
+ } | undefined;
18
27
  describedIds: string;
19
28
  invalid: boolean;
20
29
  };
@@ -1,28 +1,30 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useId } from "react";
3
+ import { ErrorLine, Hint, noteDescribedBy } from "./Field.js";
3
4
  /** Whether a note is set: `null`, `undefined`, `false` and `""` draw nothing. */
4
5
  const given = (note) => note != null && note !== false && note !== "";
5
6
  /**
6
- * The label, with its note under it when there is one: the error (`role="alert"`, red) when set,
7
- * else the muted hint.
7
+ * The label, with its notes under it when there are any: the muted hint, and under it the error
8
+ * (an alert icon and red text, announced politely) when set. The hint stays while the error shows.
8
9
  */
9
- export function Words({ label, hint, error, id, }) {
10
- if (id === undefined)
10
+ export function Words({ label, hint, error, ids, }) {
11
+ if (ids === undefined)
11
12
  return label;
12
- const failed = given(error);
13
- return (_jsxs("span", { className: "flex flex-col gap-0.5", children: [_jsx("span", { children: label }), _jsx("span", { id: id, role: failed ? "alert" : undefined, className: failed ? "text-xs text-red-700" : "text-xs text-slate-500", children: failed ? error : hint })] }));
13
+ return (_jsxs("span", { className: "flex flex-col gap-0.5", children: [_jsx("span", { children: label }), given(hint) ? _jsx(Hint, { id: ids.hint, children: hint }) : null, given(error) ? _jsx(ErrorLine, { id: ids.error, error: error }) : null] }));
14
14
  }
15
15
  /**
16
- * The note's id (none without a hint or an error), the control's whole `aria-describedby`, and
17
- * whether it is invalid (an error is set). The error replaces the hint, as in a `Field`.
16
+ * The notes' ids (none without a hint or an error), the control's whole `aria-describedby` (the
17
+ * caller's, then the hint, then the error), and whether it is invalid (an error is set), as in a
18
+ * `Field`.
18
19
  */
19
20
  export function useNote(hint, error, describedBy) {
20
- const generatedId = useId();
21
+ const own = { hint: useId(), error: useId() };
21
22
  const invalid = given(error);
22
- const noteId = invalid || given(hint) ? generatedId : undefined;
23
+ const ids = invalid || given(hint) ? own : undefined;
24
+ const notes = noteDescribedBy(given(hint), invalid, own);
23
25
  return {
24
- noteId,
25
- describedIds: [describedBy, noteId].filter(Boolean).join(" "),
26
+ ids,
27
+ describedIds: [describedBy, notes].filter(Boolean).join(" "),
26
28
  invalid,
27
29
  };
28
30
  }
@@ -1,7 +1,8 @@
1
1
  import type { ComponentPropsWithoutRef, MouseEventHandler, PointerEventHandler, ReactNode } from "react";
2
- import type { Unstyled } from "./props.js";
2
+ import type { Passthrough, Unstyled } from "./props.js";
3
3
  import type { Size } from "./size.js";
4
4
  import type { LoadingProps } from "./skeleton.js";
5
+ import type { TextTone } from "./typography.js";
5
6
  type Shared = LoadingProps & {
6
7
  /**
7
8
  * `sm` is dense padding, `lg` one step roomier than `md`. A `Button`, `IconButton` or `Pill` in a
@@ -9,8 +10,6 @@ type Shared = LoadingProps & {
9
10
  * @default md
10
11
  */
11
12
  size?: Size | undefined;
12
- /** A hairline above the row: set it on every row after the first. */
13
- divided?: boolean | undefined;
14
13
  /** Content before the label: an Avatar, a thumbnail, an icon. */
15
14
  leading?: ReactNode | undefined;
16
15
  /** A second, muted line under the label (a date, a note), like `TableCell`'s `secondary`. */
@@ -31,8 +30,7 @@ type Shared = LoadingProps & {
31
30
  /**
32
31
  * Marks the row a list follows with the pointer and the keyboard alike (set it from
33
32
  * `onPointerEnter` and `onFocus`): a fill one step deeper than hover, so it shows on a white card
34
- * and on a tinted panel alike. On a static row it shows the fill without `revealOnHover`, and
35
- * shows `actions` that `revealOnHover` hides. `selected` wins.
33
+ * and on a tinted panel alike. It is the only fill a static row takes. `selected` wins.
36
34
  *
37
35
  * Clear it from `onPointerLeave`.
38
36
  */
@@ -44,11 +42,15 @@ type Shared = LoadingProps & {
44
42
  * For a row that shows a screenshot.
45
43
  */
46
44
  leadingWidth?: "thumbnail" | undefined;
45
+ /**
46
+ * The row's status, as a stripe on its leading edge in this tone, as a `Table` row's `stripe`. The
47
+ * colour says it to the eye only, so the row's words say it too (a `Pill`, a status in `trailing`).
48
+ */
49
+ stripe?: Exclude<TextTone, "neutral"> | undefined;
47
50
  children: ReactNode;
48
51
  };
49
52
  type NotStatic = {
50
53
  actions?: undefined;
51
- revealOnHover?: undefined;
52
54
  panel?: undefined;
53
55
  };
54
56
  export type ListRowButtonProps = Shared & NotStatic & {
@@ -81,21 +83,19 @@ export type ListRowLinkProps = Shared & NotStatic & {
81
83
  href: string;
82
84
  };
83
85
  /**
84
- * A row with no `href` and no `onClick`: a `<div>` with no click target and no hover fill (unless
85
- * `revealOnHover`), for one that holds its own controls, taking `actions` as well.
86
+ * A row with no `href` and no `onClick`: a `<div>` with no click target and no hover fill, for one
87
+ * that holds its own controls, taking `actions` as well.
86
88
  */
87
89
  export type ListRowStaticProps = Shared & {
88
- /** Buttons for this row, after `trailing`: `Button size="sm"`, `IconButton`. */
89
- actions?: ReactNode | undefined;
90
90
  /**
91
- * Hides `actions` until the row is hovered or something in it has focus, so a long list is not a
92
- * wall of buttons. A touch screen has no hover, so they are always shown there.
91
+ * Buttons for this row, after `trailing`: `Button size="sm"`, `IconButton`, a `Menu`. Always
92
+ * shown: an action that shows only on hover is one a touch or keyboard user cannot find.
93
93
  */
94
- revealOnHover?: boolean | undefined;
94
+ actions?: ReactNode | undefined;
95
95
  /**
96
96
  * Content under the row, lined up with the label rather than the row's edge (past `leading`): the
97
97
  * panel of a row that opens in place, such as a conversation under its chat. It sits inside the
98
- * row, so `divided`, the fill and `revealOnHover` cover it too. Only a row that is neither a
98
+ * row, so the fill and a `Stack divided` line cover it too. Only a row that is neither a
99
99
  * button nor a link takes it.
100
100
  */
101
101
  panel?: ReactNode | undefined;
@@ -103,6 +103,8 @@ export type ListRowStaticProps = Shared & {
103
103
  onClick?: undefined;
104
104
  disabledReason?: undefined;
105
105
  href?: undefined;
106
- } & Unstyled<Omit<ComponentPropsWithoutRef<"div">, "children" | "onClick">>;
106
+ } & Passthrough &
107
+ /** What sets and clears `highlighted`; focus events bubble up from the row's own controls. */
108
+ Pick<ComponentPropsWithoutRef<"div">, "onPointerEnter" | "onPointerLeave" | "onFocus" | "onBlur">;
107
109
  export type ListRowProps = ListRowButtonProps | ListRowLinkProps | ListRowStaticProps;
108
110
  export {};
package/dist/modal.d.ts CHANGED
@@ -1,4 +1,9 @@
1
1
  import { type RefObject } from "react";
2
+ /**
3
+ * Whether a `Dialog`, `Drawer` or `Lightbox` is open. `ToastRegion` holds its toasts back while one
4
+ * is: the page behind a modal is inert, so a toast there could be neither read nor reached.
5
+ */
6
+ export declare function useModalOpen(): boolean;
2
7
  /**
3
8
  * Opens the `<dialog>` with `showModal()` on mount and closes it on unmount. Closing on unmount
4
9
  * (not just on Esc or the backdrop) hands focus back to the opener and drops the inert page behind
package/dist/modal.js CHANGED
@@ -1,4 +1,4 @@
1
- import { useLayoutEffect, useRef } from "react";
1
+ import { useLayoutEffect, useRef, useSyncExternalStore } from "react";
2
2
  /** Resolves when the transitions running on the dialog (and its backdrop) have ended. */
3
3
  async function exitTransitions(dialog) {
4
4
  // A browser without the Web Animations API (or jsdom) has nothing to wait for.
@@ -7,6 +7,24 @@ async function exitTransitions(dialog) {
7
7
  const running = dialog.getAnimations({ subtree: true }).filter((a) => "transitionProperty" in a);
8
8
  await Promise.allSettled(running.map((a) => a.finished));
9
9
  }
10
+ /** How many of the library's modals are open, and who wants to hear when that changes. */
11
+ let openModals = 0;
12
+ const watchers = new Set();
13
+ const opened = (by) => {
14
+ openModals += by;
15
+ for (const watcher of watchers)
16
+ watcher();
17
+ };
18
+ /**
19
+ * Whether a `Dialog`, `Drawer` or `Lightbox` is open. `ToastRegion` holds its toasts back while one
20
+ * is: the page behind a modal is inert, so a toast there could be neither read nor reached.
21
+ */
22
+ export function useModalOpen() {
23
+ return useSyncExternalStore((watcher) => {
24
+ watchers.add(watcher);
25
+ return () => watchers.delete(watcher);
26
+ }, () => openModals > 0, () => false);
27
+ }
10
28
  /**
11
29
  * Opens the `<dialog>` with `showModal()` on mount and closes it on unmount. Closing on unmount
12
30
  * (not just on Esc or the backdrop) hands focus back to the opener and drops the inert page behind
@@ -22,9 +40,11 @@ export function useModal(dialog, onClose) {
22
40
  const el = dialog.current;
23
41
  mounted.current = true;
24
42
  el?.showModal();
43
+ opened(1);
25
44
  return () => {
26
45
  mounted.current = false;
27
46
  el?.close();
47
+ opened(-1);
28
48
  };
29
49
  }, [dialog]);
30
50
  return () => {
package/dist/navFold.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { useEffect, useRef, useState } from "react";
2
+ import { observeItems } from "./scrollEdges.js";
2
3
  // AppShell's `md` step: below it the nav is always in the Menu, so nothing is measured there.
3
4
  const WIDE = "(width >= 48rem)";
4
5
  /**
@@ -23,6 +24,8 @@ export function useNavFold(row, enabled) {
23
24
  return undefined;
24
25
  const wide = window.matchMedia(WIDE);
25
26
  const check = () => {
27
+ // A slot hidden when the effect ran (the closed Menu below `md`) is picked up once shown.
28
+ observeItems(observer, row);
26
29
  if (!wide.matches)
27
30
  return;
28
31
  const now = state.current;
@@ -36,10 +39,10 @@ export function useNavFold(row, enabled) {
36
39
  };
37
40
  const observer = new ResizeObserver(check);
38
41
  // The row is the header's width, so it resizes only with the screen; its slots resize with
39
- // their content (a font swap, a label that changes), so they are watched too.
42
+ // their content (a font swap, a label that changes), so they are watched too, through the
43
+ // menu panel, which draws no box of its own in the row.
40
44
  observer.observe(row);
41
- for (const slot of row.children)
42
- observer.observe(slot);
45
+ observeItems(observer, row);
43
46
  return () => observer.disconnect();
44
47
  });
45
48
  return enabled && folded;
@@ -0,0 +1,18 @@
1
+ /** A choice's look: `plain` is the mark and its words; `card` puts them in a bordered box, the whole box the click target. */
2
+ export type ChoiceVariant = "plain" | "card";
3
+ /**
4
+ * The box of a `card` choice (a `Checkbox`, a `Radio`): full width, padded, the control's border
5
+ * colour, and the hover edge of a field. Its parent is `relative` (the touch target's), so the
6
+ * chosen edge below sits on it.
7
+ */
8
+ export declare const OPTION_CARD = "w-full rounded-lg border border-slate-300 bg-white p-3 transition";
9
+ /** A card's edge under the pointer, when it is enabled. */
10
+ export declare const OPTION_CARD_HOVER = "hover:border-violet-400";
11
+ /**
12
+ * The chosen card's edge: a 2px accent border drawn over the card's own, so the words do not move.
13
+ * It is shown by the caller (`visible` from the input's state), so a card that keeps its own state
14
+ * changes with no re-render.
15
+ */
16
+ export declare const OPTION_CARD_CHOSEN = "pointer-events-none absolute -inset-px rounded-lg border-2 border-violet-600";
17
+ /** The card's title: a step heavier than a plain choice's words, as a card's heading is. */
18
+ export declare const OPTION_CARD_TITLE = "font-medium text-slate-900";
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The box of a `card` choice (a `Checkbox`, a `Radio`): full width, padded, the control's border
3
+ * colour, and the hover edge of a field. Its parent is `relative` (the touch target's), so the
4
+ * chosen edge below sits on it.
5
+ */
6
+ export const OPTION_CARD = "w-full rounded-lg border border-slate-300 bg-white p-3 transition";
7
+ /** A card's edge under the pointer, when it is enabled. */
8
+ export const OPTION_CARD_HOVER = "hover:border-violet-400";
9
+ /**
10
+ * The chosen card's edge: a 2px accent border drawn over the card's own, so the words do not move.
11
+ * It is shown by the caller (`visible` from the input's state), so a card that keeps its own state
12
+ * changes with no re-render.
13
+ */
14
+ export const OPTION_CARD_CHOSEN = "pointer-events-none absolute -inset-px rounded-lg border-2 border-violet-600";
15
+ /** The card's title: a step heavier than a plain choice's words, as a card's heading is. */
16
+ export const OPTION_CARD_TITLE = "font-medium text-slate-900";
@@ -0,0 +1,16 @@
1
+ import type { ReactElement, ReactNode } from "react";
2
+ /**
3
+ * A box that scrolls (a `Drawer`'s or a `BottomSheet`'s body, a filled `Card`'s body, a
4
+ * `CodeExample`'s preview), with the keyboard side `useScrollStop` gives it: while it overflows and
5
+ * holds nothing the keyboard can reach, it takes a tab stop, a group named by `label` or
6
+ * `labelledBy`. Its ring is drawn inside it, since each of these sits in a frame that clips.
7
+ * Internal: `className` is the library's own.
8
+ */
9
+ export declare function ScrollBody({ axis, label, labelledBy, id, className, children, }: {
10
+ axis?: "x" | "y";
11
+ label?: string | undefined;
12
+ labelledBy?: string | undefined;
13
+ id?: string | undefined;
14
+ className: string;
15
+ children: ReactNode;
16
+ }): ReactElement;
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cx, insetFocusRing } from "./cx.js";
3
+ import { scrollStopProps, useScrollStop } from "./scrollStop.js";
4
+ /**
5
+ * A box that scrolls (a `Drawer`'s or a `BottomSheet`'s body, a filled `Card`'s body, a
6
+ * `CodeExample`'s preview), with the keyboard side `useScrollStop` gives it: while it overflows and
7
+ * holds nothing the keyboard can reach, it takes a tab stop, a group named by `label` or
8
+ * `labelledBy`. Its ring is drawn inside it, since each of these sits in a frame that clips.
9
+ * Internal: `className` is the library's own.
10
+ */
11
+ export function ScrollBody({ axis = "y", label, labelledBy, id, className, children, }) {
12
+ const { attach, stop } = useScrollStop(axis);
13
+ const { props } = scrollStopProps(stop, { label, labelledBy });
14
+ return (_jsx("div", { ref: attach, id: id, ...props, className: cx(className, stop && insetFocusRing), children: children }));
15
+ }
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Observes each child of `box` that draws a box and is not watched yet. A ResizeObserver never
3
+ * fires for a `display: contents` element (it has no box), so such a child is looked through and
4
+ * its own children are observed instead, down any depth. A hidden child is skipped; call it again
5
+ * once it may show (from the observer's callback), and only the new ones are added.
6
+ */
7
+ export declare function observeItems(observer: ResizeObserver, box: Element): void;
1
8
  /**
2
9
  * Marks a box that scrolls with which of its edges still has content past it, so the layout can fade
3
10
  * them: `data-more-start` (scrolled away from the start), `data-more-end` (more to scroll to) and
@@ -1,4 +1,28 @@
1
1
  import { useEffect } from "react";
2
+ // What each observer already watches. Observing an element again restarts it, which reports its
3
+ // size once more and, from inside the callback, would loop.
4
+ const watched = new WeakMap();
5
+ /**
6
+ * Observes each child of `box` that draws a box and is not watched yet. A ResizeObserver never
7
+ * fires for a `display: contents` element (it has no box), so such a child is looked through and
8
+ * its own children are observed instead, down any depth. A hidden child is skipped; call it again
9
+ * once it may show (from the observer's callback), and only the new ones are added.
10
+ */
11
+ export function observeItems(observer, box) {
12
+ const seen = watched.get(observer) ?? new WeakSet();
13
+ watched.set(observer, seen);
14
+ for (const child of box.children) {
15
+ const display = getComputedStyle(child).display;
16
+ if (display === "none")
17
+ continue;
18
+ if (display === "contents")
19
+ observeItems(observer, child);
20
+ else if (!seen.has(child)) {
21
+ seen.add(child);
22
+ observer.observe(child);
23
+ }
24
+ }
25
+ }
2
26
  /**
3
27
  * Marks a box that scrolls with which of its edges still has content past it, so the layout can fade
4
28
  * them: `data-more-start` (scrolled away from the start), `data-more-end` (more to scroll to) and
@@ -17,7 +41,8 @@ export function useScrollEdges(element, axis) {
17
41
  const el = element;
18
42
  const update = () => {
19
43
  const [position, scrollSize, clientSize] = axis === "x"
20
- ? [el.scrollLeft, el.scrollWidth, el.clientWidth]
44
+ ? // Right to left, scrollLeft runs from 0 at the start to negative at the end.
45
+ [Math.abs(el.scrollLeft), el.scrollWidth, el.clientWidth]
21
46
  : [el.scrollTop, el.scrollHeight, el.clientHeight];
22
47
  const start = position > 1;
23
48
  const end = scrollSize - clientSize - position > 1;
@@ -28,10 +53,19 @@ export function useScrollEdges(element, axis) {
28
53
  update();
29
54
  el.addEventListener("scroll", update, { passive: true });
30
55
  // jsdom (a consumer's own tests) has no ResizeObserver.
31
- const resize = typeof ResizeObserver === "undefined" ? undefined : new ResizeObserver(update);
32
- resize?.observe(el);
33
- for (const child of el.children)
34
- resize?.observe(child);
56
+ // Each resize looks for items again: one hidden when the effect ran (`display: none` below a
57
+ // breakpoint) is observed once it shows. Observing an item twice is a no-op.
58
+ const resize = typeof ResizeObserver === "undefined"
59
+ ? undefined
60
+ : new ResizeObserver(() => {
61
+ if (resize)
62
+ observeItems(resize, el);
63
+ update();
64
+ });
65
+ if (resize) {
66
+ resize.observe(el);
67
+ observeItems(resize, el);
68
+ }
35
69
  return () => {
36
70
  el.removeEventListener("scroll", update);
37
71
  resize?.disconnect();
@@ -11,13 +11,17 @@ export declare const TABBABLE = ":is(a[href], button, input:not([type=\"hidden\"
11
11
  * scrolls: "y" (down, the default) or "x" (sideways); overflow the other way is not measured,
12
12
  * since the box does not scroll that way. `measured` is false until the box has been measured once
13
13
  * and true after: a page rendered to HTML and never hydrated is never measured, and neither is a
14
- * box where `ResizeObserver` is missing (a consumer's jsdom tests with no stub).
14
+ * box where `ResizeObserver` is missing (a consumer's jsdom tests with no stub). `overflows` is
15
+ * whether the box overflowed when last measured. `wider`, for a box that may stop scrolling while it
16
+ * fits (a `Table`'s, which clips instead so its head can stick to the page), measures the overflow
17
+ * from the content instead of the box's own scroll width.
15
18
  */
16
- export declare function useScrollStop(axis?: "x" | "y"): {
19
+ export declare function useScrollStop(axis?: "x" | "y", wider?: (box: HTMLElement) => boolean): {
17
20
  element: HTMLElement | null;
18
21
  attach: (el: HTMLDivElement | null) => void;
19
22
  stop: boolean;
20
23
  measured: boolean;
24
+ overflows: boolean;
21
25
  };
22
26
  /**
23
27
  * The props a scroller takes while it holds the tab stop: focusable, ringed and, when the column
@@ -22,21 +22,31 @@ function holdsTabbable(scroller) {
22
22
  * scrolls: "y" (down, the default) or "x" (sideways); overflow the other way is not measured,
23
23
  * since the box does not scroll that way. `measured` is false until the box has been measured once
24
24
  * and true after: a page rendered to HTML and never hydrated is never measured, and neither is a
25
- * box where `ResizeObserver` is missing (a consumer's jsdom tests with no stub).
25
+ * box where `ResizeObserver` is missing (a consumer's jsdom tests with no stub). `overflows` is
26
+ * whether the box overflowed when last measured. `wider`, for a box that may stop scrolling while it
27
+ * fits (a `Table`'s, which clips instead so its head can stick to the page), measures the overflow
28
+ * from the content instead of the box's own scroll width.
26
29
  */
27
- export function useScrollStop(axis = "y") {
30
+ export function useScrollStop(axis = "y", wider) {
28
31
  const [element, setElement] = useState(null);
29
32
  const [stop, setStop] = useState(false);
30
33
  const [measured, setMeasured] = useState(false);
34
+ const [overflowing, setOverflowing] = useState(false);
31
35
  useEffect(() => {
32
36
  // jsdom (a consumer's own tests) has no ResizeObserver.
33
37
  if (!element || typeof ResizeObserver === "undefined")
34
38
  return undefined;
35
- const overflows = () => axis === "y"
36
- ? element.scrollHeight > element.clientHeight
37
- : element.scrollWidth > element.clientWidth;
39
+ const overflows = () => {
40
+ if (wider)
41
+ return wider(element);
42
+ return axis === "y"
43
+ ? element.scrollHeight > element.clientHeight
44
+ : element.scrollWidth > element.clientWidth;
45
+ };
38
46
  const measure = () => {
39
- setStop(overflows() && !holdsTabbable(element));
47
+ const over = overflows();
48
+ setOverflowing(over);
49
+ setStop(over && !holdsTabbable(element));
40
50
  setMeasured(true);
41
51
  };
42
52
  // Each observer reports once when it starts, and again when the box is resized, its content
@@ -56,8 +66,14 @@ export function useScrollStop(axis = "y") {
56
66
  resize.disconnect();
57
67
  change.disconnect();
58
68
  };
59
- }, [element, axis]);
60
- return { element, attach: setElement, stop: stop && element !== null, measured };
69
+ }, [element, axis, wider]);
70
+ return {
71
+ element,
72
+ attach: setElement,
73
+ stop: stop && element !== null,
74
+ measured,
75
+ overflows: overflowing && element !== null,
76
+ };
61
77
  }
62
78
  /**
63
79
  * The props a scroller takes while it holds the tab stop: focusable, ringed and, when the column
@@ -1,12 +1,28 @@
1
- import type { CalendarDate } from "@internationalized/date";
1
+ import { type CalendarDate, type CalendarDateTime, type DateValue } from "@internationalized/date";
2
2
  import { type FocusEvent, type ReactElement } from "react";
3
3
  import type { FieldProps, Read } from "./DateField.js";
4
- type ValueKeys = "value" | "defaultValue" | "onChange" | "minValue" | "maxValue" | "isRequired";
4
+ /** What a typed field holds: its value type, how it is written as ISO text, and how fine it is. */
5
+ export type Kind<T extends CalendarDate | CalendarDateTime> = {
6
+ granularity: "day" | "minute";
7
+ toISO: (value: T | null | undefined) => string;
8
+ fromISO: (iso: string) => T | null;
9
+ /** The field's value as this kind's own type. */
10
+ narrow: (value: DateValue | null) => T | null;
11
+ /** The message for a required field left partly typed. */
12
+ whole: string;
13
+ };
14
+ /** A day: `YYYY-MM-DD`. */
15
+ export declare const DATE: Kind<CalendarDate>;
16
+ /** A day and a time to the minute: `YYYY-MM-DDTHH:mm`. */
17
+ export declare const DATE_TIME: Kind<CalendarDateTime>;
5
18
  /** The value props, each of which may be passed as `undefined`. */
6
- type ValueProps = {
7
- [K in ValueKeys]?: (FieldProps & {
8
- isRequired?: boolean;
9
- })[K] | undefined;
19
+ type ValueProps<T> = {
20
+ value?: T | null | undefined;
21
+ defaultValue?: T | null | undefined;
22
+ onChange?: ((value: T | null) => void) | null | undefined;
23
+ minValue?: DateValue | null | undefined;
24
+ maxValue?: DateValue | null | undefined;
25
+ isRequired?: boolean | undefined;
10
26
  };
11
27
  /**
12
28
  * The value the field reports is always what it shows: the typed date when it is complete, exists
@@ -27,13 +43,13 @@ type ValueProps = {
27
43
  *
28
44
  * `shown` (`YYYY-MM-DD` or `""`) is what the hidden `name` input posts.
29
45
  */
30
- export declare function useShownDate(props: ValueProps): {
31
- inner: CalendarDate | null;
32
- setInner: import("react").Dispatch<import("react").SetStateAction<CalendarDate | null>>;
46
+ export declare function useShownDate<T extends CalendarDate | CalendarDateTime>(props: ValueProps<T>, kind: Kind<T>): {
47
+ inner: T | null;
48
+ setInner: import("react").Dispatch<import("react").SetStateAction<T | null>>;
33
49
  shown: string;
34
50
  impossible: string | null;
35
51
  onRead: (next: Read) => void;
36
- validate: () => "Enter the whole date." | null;
52
+ validate: () => string | null;
37
53
  leaving: boolean;
38
54
  onBlurCapture: (event: FocusEvent<HTMLElement>) => void;
39
55
  onLeft: () => void;
@@ -50,6 +66,8 @@ type RangeProps = {
50
66
  minValue?: FieldProps["minValue"] | undefined;
51
67
  maxValue?: FieldProps["maxValue"] | undefined;
52
68
  isRequired?: boolean | undefined;
69
+ /** The start and end side's names, which start an impossible day's message. */
70
+ labels: [string, string];
53
71
  };
54
72
  /**
55
73
  * `useShownDate` for a range: each side's segments are read on their own, and the range reported is