@thomasfosterau/components 0.0.0 → 0.2.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 (484) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +241 -56
  3. package/dist/canvas/VectorCanvas.svelte +320 -0
  4. package/dist/canvas/VectorCanvas.svelte.d.ts +105 -0
  5. package/dist/canvas/history.d.ts +105 -0
  6. package/dist/canvas/history.js +147 -0
  7. package/dist/canvas/index.d.ts +15 -0
  8. package/dist/canvas/index.js +14 -0
  9. package/dist/canvas/types.d.ts +91 -0
  10. package/dist/canvas/types.js +13 -0
  11. package/dist/canvas/utils.d.ts +66 -0
  12. package/dist/canvas/utils.js +114 -0
  13. package/dist/charts/Chart.svelte +300 -0
  14. package/dist/charts/Chart.svelte.d.ts +50 -0
  15. package/dist/charts/index.d.ts +11 -0
  16. package/dist/charts/index.js +10 -0
  17. package/dist/charts/types.d.ts +28 -0
  18. package/dist/charts/types.js +6 -0
  19. package/dist/citations/BookCitation.svelte +53 -0
  20. package/dist/citations/BookCitation.svelte.d.ts +41 -0
  21. package/dist/citations/ChapterCitation.svelte +38 -0
  22. package/dist/citations/ChapterCitation.svelte.d.ts +50 -0
  23. package/dist/citations/Citation.svelte +47 -0
  24. package/dist/citations/Citation.svelte.d.ts +24 -0
  25. package/dist/citations/CreditList.svelte +69 -0
  26. package/dist/citations/CreditList.svelte.d.ts +47 -0
  27. package/dist/citations/DOILink.svelte +28 -0
  28. package/dist/citations/DOILink.svelte.d.ts +19 -0
  29. package/dist/citations/Footnote.svelte +39 -0
  30. package/dist/citations/Footnote.svelte.d.ts +17 -0
  31. package/dist/citations/FootnoteList.svelte +36 -0
  32. package/dist/citations/FootnoteList.svelte.d.ts +21 -0
  33. package/dist/citations/ISBNLink.svelte +29 -0
  34. package/dist/citations/ISBNLink.svelte.d.ts +19 -0
  35. package/dist/citations/ISSNLink.svelte +29 -0
  36. package/dist/citations/ISSNLink.svelte.d.ts +19 -0
  37. package/dist/citations/Publisher.svelte +34 -0
  38. package/dist/citations/Publisher.svelte.d.ts +14 -0
  39. package/dist/citations/ReferenceList.svelte +53 -0
  40. package/dist/citations/ReferenceList.svelte.d.ts +21 -0
  41. package/dist/citations/ReportCitation.svelte +41 -0
  42. package/dist/citations/ReportCitation.svelte.d.ts +36 -0
  43. package/dist/citations/ScholarlyArticleCitation.svelte +64 -0
  44. package/dist/citations/ScholarlyArticleCitation.svelte.d.ts +41 -0
  45. package/dist/citations/ThesisCitation.svelte +35 -0
  46. package/dist/citations/ThesisCitation.svelte.d.ts +29 -0
  47. package/dist/citations/bibliography.svelte.d.ts +55 -0
  48. package/dist/citations/bibliography.svelte.js +78 -0
  49. package/dist/citations/citation.d.ts +71 -0
  50. package/dist/citations/citation.js +121 -0
  51. package/dist/citations/csl.d.ts +102 -0
  52. package/dist/citations/csl.js +20 -0
  53. package/dist/citations/index.d.ts +31 -0
  54. package/dist/citations/index.js +36 -0
  55. package/dist/citations/list-format.d.ts +34 -0
  56. package/dist/citations/list-format.js +40 -0
  57. package/dist/context.svelte.d.ts +46 -0
  58. package/dist/context.svelte.js +51 -0
  59. package/dist/data/ChatBubble.svelte +48 -0
  60. package/dist/data/ChatBubble.svelte.d.ts +33 -0
  61. package/dist/data/DataGrid.svelte +150 -0
  62. package/dist/data/DataGrid.svelte.d.ts +118 -0
  63. package/dist/data/DescriptionList.svelte +53 -0
  64. package/dist/data/DescriptionList.svelte.d.ts +26 -0
  65. package/dist/data/DescriptionRow.svelte +56 -0
  66. package/dist/data/DescriptionRow.svelte.d.ts +21 -0
  67. package/dist/data/DiffText.svelte +29 -0
  68. package/dist/data/DiffText.svelte.d.ts +19 -0
  69. package/dist/data/ItemList.svelte +80 -0
  70. package/dist/data/ItemList.svelte.d.ts +52 -0
  71. package/dist/data/LinkListItem.svelte +46 -0
  72. package/dist/data/LinkListItem.svelte.d.ts +21 -0
  73. package/dist/data/MessageThread.svelte +29 -0
  74. package/dist/data/MessageThread.svelte.d.ts +17 -0
  75. package/dist/data/Pagination.svelte +136 -0
  76. package/dist/data/Pagination.svelte.d.ts +79 -0
  77. package/dist/data/PaginationFooter.svelte +42 -0
  78. package/dist/data/PaginationFooter.svelte.d.ts +61 -0
  79. package/dist/data/ResultCount.svelte +27 -0
  80. package/dist/data/ResultCount.svelte.d.ts +18 -0
  81. package/dist/data/Table.svelte +151 -0
  82. package/dist/data/Table.svelte.d.ts +75 -0
  83. package/dist/data/TreeList.svelte +41 -0
  84. package/dist/data/TreeList.svelte.d.ts +17 -0
  85. package/dist/data/TreeListItem.svelte +29 -0
  86. package/dist/data/TreeListItem.svelte.d.ts +10 -0
  87. package/dist/data/description-context.d.ts +39 -0
  88. package/dist/data/description-context.js +36 -0
  89. package/dist/data/diff.d.ts +14 -0
  90. package/dist/data/diff.js +10 -0
  91. package/dist/data/index.d.ts +37 -0
  92. package/dist/data/index.js +37 -0
  93. package/dist/data/list-item.d.ts +30 -0
  94. package/dist/data/list-item.js +19 -0
  95. package/dist/data/pagination.d.ts +81 -0
  96. package/dist/data/pagination.js +79 -0
  97. package/dist/data/table-types.d.ts +71 -0
  98. package/dist/data/table-types.js +35 -0
  99. package/dist/feedback/ConfirmDialog.svelte +79 -0
  100. package/dist/feedback/ConfirmDialog.svelte.d.ts +82 -0
  101. package/dist/feedback/Dialog.svelte +47 -0
  102. package/dist/feedback/Dialog.svelte.d.ts +36 -0
  103. package/dist/feedback/DialogFrame.svelte +64 -0
  104. package/dist/feedback/DialogFrame.svelte.d.ts +23 -0
  105. package/dist/feedback/Drawer.svelte +43 -0
  106. package/dist/feedback/Drawer.svelte.d.ts +43 -0
  107. package/dist/feedback/LoadingBoundary.svelte +61 -0
  108. package/dist/feedback/LoadingBoundary.svelte.d.ts +34 -0
  109. package/dist/feedback/ProgressBar.svelte +46 -0
  110. package/dist/feedback/ProgressBar.svelte.d.ts +28 -0
  111. package/dist/feedback/SegmentBar.svelte +83 -0
  112. package/dist/feedback/SegmentBar.svelte.d.ts +37 -0
  113. package/dist/feedback/StatTile.svelte +77 -0
  114. package/dist/feedback/StatTile.svelte.d.ts +50 -0
  115. package/dist/feedback/Stats.svelte +18 -0
  116. package/dist/feedback/Stats.svelte.d.ts +16 -0
  117. package/dist/feedback/Steps.svelte +72 -0
  118. package/dist/feedback/Steps.svelte.d.ts +61 -0
  119. package/dist/feedback/Timeline.svelte +86 -0
  120. package/dist/feedback/Timeline.svelte.d.ts +55 -0
  121. package/dist/feedback/Toaster.svelte +78 -0
  122. package/dist/feedback/Toaster.svelte.d.ts +32 -0
  123. package/dist/feedback/index.d.ts +34 -0
  124. package/dist/feedback/index.js +29 -0
  125. package/dist/feedback/sizes.d.ts +41 -0
  126. package/dist/feedback/sizes.js +69 -0
  127. package/dist/feedback/toaster.d.ts +48 -0
  128. package/dist/feedback/toaster.js +29 -0
  129. package/dist/fields/Calendar.svelte +60 -0
  130. package/dist/fields/Calendar.svelte.d.ts +11 -0
  131. package/dist/fields/CalendarMonths.svelte +86 -0
  132. package/dist/fields/CalendarMonths.svelte.d.ts +30 -0
  133. package/dist/fields/Checkbox.svelte +33 -0
  134. package/dist/fields/Checkbox.svelte.d.ts +30 -0
  135. package/dist/fields/CheckboxGroup.svelte +41 -0
  136. package/dist/fields/CheckboxGroup.svelte.d.ts +40 -0
  137. package/dist/fields/Combobox.svelte +229 -0
  138. package/dist/fields/Combobox.svelte.d.ts +133 -0
  139. package/dist/fields/DateField.svelte +37 -0
  140. package/dist/fields/DateField.svelte.d.ts +20 -0
  141. package/dist/fields/DateInput.svelte +31 -0
  142. package/dist/fields/DateInput.svelte.d.ts +35 -0
  143. package/dist/fields/DatePicker.svelte +47 -0
  144. package/dist/fields/DatePicker.svelte.d.ts +25 -0
  145. package/dist/fields/DateRangePicker.svelte +70 -0
  146. package/dist/fields/DateRangePicker.svelte.d.ts +43 -0
  147. package/dist/fields/Dropzone.svelte +232 -0
  148. package/dist/fields/Dropzone.svelte.d.ts +103 -0
  149. package/dist/fields/FieldErrors.svelte +30 -0
  150. package/dist/fields/FieldErrors.svelte.d.ts +11 -0
  151. package/dist/fields/Fieldset.svelte +53 -0
  152. package/dist/fields/Fieldset.svelte.d.ts +27 -0
  153. package/dist/fields/FileInput.svelte +68 -0
  154. package/dist/fields/FileInput.svelte.d.ts +39 -0
  155. package/dist/fields/FormField.svelte +78 -0
  156. package/dist/fields/FormField.svelte.d.ts +29 -0
  157. package/dist/fields/ImageInput.svelte +87 -0
  158. package/dist/fields/ImageInput.svelte.d.ts +45 -0
  159. package/dist/fields/MultiSelect.svelte +112 -0
  160. package/dist/fields/MultiSelect.svelte.d.ts +75 -0
  161. package/dist/fields/NumberField.svelte +190 -0
  162. package/dist/fields/NumberField.svelte.d.ts +76 -0
  163. package/dist/fields/PasswordInput.svelte +95 -0
  164. package/dist/fields/PasswordInput.svelte.d.ts +58 -0
  165. package/dist/fields/PickerPopover.svelte +47 -0
  166. package/dist/fields/PickerPopover.svelte.d.ts +16 -0
  167. package/dist/fields/PinInput.svelte +83 -0
  168. package/dist/fields/PinInput.svelte.d.ts +66 -0
  169. package/dist/fields/PushToggle.svelte +93 -0
  170. package/dist/fields/PushToggle.svelte.d.ts +55 -0
  171. package/dist/fields/RadioGroup.svelte +88 -0
  172. package/dist/fields/RadioGroup.svelte.d.ts +41 -0
  173. package/dist/fields/RangeCalendar.svelte +51 -0
  174. package/dist/fields/RangeCalendar.svelte.d.ts +23 -0
  175. package/dist/fields/Rating.svelte +127 -0
  176. package/dist/fields/Rating.svelte.d.ts +86 -0
  177. package/dist/fields/SearchInput.svelte +58 -0
  178. package/dist/fields/SearchInput.svelte.d.ts +33 -0
  179. package/dist/fields/SegmentGroup.svelte +91 -0
  180. package/dist/fields/SegmentGroup.svelte.d.ts +20 -0
  181. package/dist/fields/Select.svelte +36 -0
  182. package/dist/fields/Select.svelte.d.ts +35 -0
  183. package/dist/fields/Slider.svelte +194 -0
  184. package/dist/fields/Slider.svelte.d.ts +100 -0
  185. package/dist/fields/TagsInput.svelte +256 -0
  186. package/dist/fields/TagsInput.svelte.d.ts +102 -0
  187. package/dist/fields/TextInput.svelte +26 -0
  188. package/dist/fields/TextInput.svelte.d.ts +36 -0
  189. package/dist/fields/Textarea.svelte +22 -0
  190. package/dist/fields/Textarea.svelte.d.ts +31 -0
  191. package/dist/fields/TimeField.svelte +30 -0
  192. package/dist/fields/TimeField.svelte.d.ts +19 -0
  193. package/dist/fields/Toggle.svelte +72 -0
  194. package/dist/fields/Toggle.svelte.d.ts +38 -0
  195. package/dist/fields/VideoInput.svelte +35 -0
  196. package/dist/fields/VideoInput.svelte.d.ts +46 -0
  197. package/dist/fields/calendar-props.d.ts +119 -0
  198. package/dist/fields/calendar-props.js +51 -0
  199. package/dist/fields/dates.d.ts +28 -0
  200. package/dist/fields/dates.js +26 -0
  201. package/dist/fields/field-types.d.ts +80 -0
  202. package/dist/fields/field-types.js +92 -0
  203. package/dist/fields/file-validation.d.ts +30 -0
  204. package/dist/fields/file-validation.js +51 -0
  205. package/dist/fields/index.d.ts +43 -0
  206. package/dist/fields/index.js +42 -0
  207. package/dist/fields/latest-search.svelte.d.ts +38 -0
  208. package/dist/fields/latest-search.svelte.js +85 -0
  209. package/dist/fields/number-format.d.ts +52 -0
  210. package/dist/fields/number-format.js +89 -0
  211. package/dist/fields/segmented-field.d.ts +128 -0
  212. package/dist/fields/segmented-field.js +52 -0
  213. package/dist/fields/slider-keys.d.ts +21 -0
  214. package/dist/fields/slider-keys.js +37 -0
  215. package/dist/formatting/Countdown.svelte +110 -0
  216. package/dist/formatting/Countdown.svelte.d.ts +35 -0
  217. package/dist/formatting/DateTime.svelte +35 -0
  218. package/dist/formatting/DateTime.svelte.d.ts +26 -0
  219. package/dist/formatting/Duration.svelte +18 -0
  220. package/dist/formatting/Duration.svelte.d.ts +20 -0
  221. package/dist/formatting/FormatList.svelte +31 -0
  222. package/dist/formatting/FormatList.svelte.d.ts +46 -0
  223. package/dist/formatting/Highlight.svelte +51 -0
  224. package/dist/formatting/Highlight.svelte.d.ts +19 -0
  225. package/dist/formatting/Number.svelte +35 -0
  226. package/dist/formatting/Number.svelte.d.ts +43 -0
  227. package/dist/formatting/RelativeTime.svelte +69 -0
  228. package/dist/formatting/RelativeTime.svelte.d.ts +26 -0
  229. package/dist/formatting/Year.svelte +39 -0
  230. package/dist/formatting/Year.svelte.d.ts +21 -0
  231. package/dist/formatting/duration.d.ts +44 -0
  232. package/dist/formatting/duration.js +125 -0
  233. package/dist/formatting/index.d.ts +15 -0
  234. package/dist/formatting/index.js +17 -0
  235. package/dist/forms/EntityForm.svelte +185 -0
  236. package/dist/forms/EntityForm.svelte.d.ts +66 -0
  237. package/dist/forms/FormActions.svelte +29 -0
  238. package/dist/forms/FormActions.svelte.d.ts +37 -0
  239. package/dist/forms/FormErrors.svelte +21 -0
  240. package/dist/forms/FormErrors.svelte.d.ts +16 -0
  241. package/dist/forms/HiddenField.svelte +22 -0
  242. package/dist/forms/HiddenField.svelte.d.ts +11 -0
  243. package/dist/forms/SearchForm.svelte +43 -0
  244. package/dist/forms/SearchForm.svelte.d.ts +36 -0
  245. package/dist/forms/entity-form.d.ts +12 -0
  246. package/dist/forms/entity-form.js +12 -0
  247. package/dist/forms/index.d.ts +14 -0
  248. package/dist/forms/index.js +14 -0
  249. package/dist/hotkeys/HotkeyBadge.svelte +39 -0
  250. package/dist/hotkeys/HotkeyBadge.svelte.d.ts +25 -0
  251. package/dist/hotkeys/HotkeyHelpDialog.svelte +68 -0
  252. package/dist/hotkeys/HotkeyHelpDialog.svelte.d.ts +35 -0
  253. package/dist/hotkeys/HotkeyProvider.svelte +92 -0
  254. package/dist/hotkeys/HotkeyProvider.svelte.d.ts +4 -0
  255. package/dist/hotkeys/context.svelte.d.ts +47 -0
  256. package/dist/hotkeys/context.svelte.js +72 -0
  257. package/dist/hotkeys/index.d.ts +28 -0
  258. package/dist/hotkeys/index.js +27 -0
  259. package/dist/hotkeys/match.d.ts +65 -0
  260. package/dist/hotkeys/match.js +135 -0
  261. package/dist/hotkeys/registry.svelte.d.ts +55 -0
  262. package/dist/hotkeys/registry.svelte.js +110 -0
  263. package/dist/hotkeys/types.d.ts +74 -0
  264. package/dist/hotkeys/types.js +18 -0
  265. package/dist/index.d.ts +37 -0
  266. package/dist/index.js +37 -0
  267. package/dist/infobox/Infobox.svelte +79 -0
  268. package/dist/infobox/Infobox.svelte.d.ts +33 -0
  269. package/dist/infobox/InfoboxHeader.svelte +35 -0
  270. package/dist/infobox/InfoboxHeader.svelte.d.ts +18 -0
  271. package/dist/infobox/InfoboxImage.svelte +38 -0
  272. package/dist/infobox/InfoboxImage.svelte.d.ts +21 -0
  273. package/dist/infobox/InfoboxRow.svelte +50 -0
  274. package/dist/infobox/InfoboxRow.svelte.d.ts +25 -0
  275. package/dist/infobox/InfoboxSection.svelte +24 -0
  276. package/dist/infobox/InfoboxSection.svelte.d.ts +12 -0
  277. package/dist/infobox/index.d.ts +21 -0
  278. package/dist/infobox/index.js +20 -0
  279. package/dist/infobox/types.d.ts +86 -0
  280. package/dist/infobox/types.js +27 -0
  281. package/dist/layout/AppShell.svelte +50 -0
  282. package/dist/layout/AppShell.svelte.d.ts +28 -0
  283. package/dist/layout/Breadcrumbs.svelte +52 -0
  284. package/dist/layout/Breadcrumbs.svelte.d.ts +18 -0
  285. package/dist/layout/Cluster.svelte +28 -0
  286. package/dist/layout/Cluster.svelte.d.ts +27 -0
  287. package/dist/layout/DetailLayout.svelte +50 -0
  288. package/dist/layout/DetailLayout.svelte.d.ts +19 -0
  289. package/dist/layout/FilterBar.svelte +40 -0
  290. package/dist/layout/FilterBar.svelte.d.ts +12 -0
  291. package/dist/layout/Fits.svelte +27 -0
  292. package/dist/layout/Fits.svelte.d.ts +13 -0
  293. package/dist/layout/Flow.svelte +46 -0
  294. package/dist/layout/Flow.svelte.d.ts +16 -0
  295. package/dist/layout/Footer.svelte +32 -0
  296. package/dist/layout/Footer.svelte.d.ts +12 -0
  297. package/dist/layout/Grid.svelte +23 -0
  298. package/dist/layout/Grid.svelte.d.ts +26 -0
  299. package/dist/layout/HStack.svelte +12 -0
  300. package/dist/layout/HStack.svelte.d.ts +34 -0
  301. package/dist/layout/Hero.svelte +76 -0
  302. package/dist/layout/Hero.svelte.d.ts +36 -0
  303. package/dist/layout/Main.svelte +30 -0
  304. package/dist/layout/Main.svelte.d.ts +15 -0
  305. package/dist/layout/Navbar.svelte +68 -0
  306. package/dist/layout/Navbar.svelte.d.ts +31 -0
  307. package/dist/layout/PageHeader.svelte +77 -0
  308. package/dist/layout/PageHeader.svelte.d.ts +33 -0
  309. package/dist/layout/Section.svelte +72 -0
  310. package/dist/layout/Section.svelte.d.ts +40 -0
  311. package/dist/layout/Sidebar.svelte +54 -0
  312. package/dist/layout/Sidebar.svelte.d.ts +27 -0
  313. package/dist/layout/Spacer.svelte +12 -0
  314. package/dist/layout/Spacer.svelte.d.ts +6 -0
  315. package/dist/layout/Tabs.svelte +85 -0
  316. package/dist/layout/Tabs.svelte.d.ts +42 -0
  317. package/dist/layout/VStack.svelte +12 -0
  318. package/dist/layout/VStack.svelte.d.ts +29 -0
  319. package/dist/layout/index.d.ts +38 -0
  320. package/dist/layout/index.js +38 -0
  321. package/dist/layout/space.d.ts +44 -0
  322. package/dist/layout/space.js +76 -0
  323. package/dist/layout/types.d.ts +52 -0
  324. package/dist/layout/types.js +27 -0
  325. package/dist/links/ContextLinks.svelte +28 -0
  326. package/dist/links/ContextLinks.svelte.d.ts +20 -0
  327. package/dist/links/EmailLink.svelte +26 -0
  328. package/dist/links/EmailLink.svelte.d.ts +20 -0
  329. package/dist/links/index.d.ts +7 -0
  330. package/dist/links/index.js +7 -0
  331. package/dist/media/Figure.svelte +26 -0
  332. package/dist/media/Figure.svelte.d.ts +12 -0
  333. package/dist/media/Image.svelte +76 -0
  334. package/dist/media/Image.svelte.d.ts +41 -0
  335. package/dist/media/Video.svelte +65 -0
  336. package/dist/media/Video.svelte.d.ts +29 -0
  337. package/dist/media/image-dimensions.d.ts +28 -0
  338. package/dist/media/image-dimensions.js +34 -0
  339. package/dist/media/index.d.ts +10 -0
  340. package/dist/media/index.js +10 -0
  341. package/dist/search/CommandPalette.svelte +257 -0
  342. package/dist/search/CommandPalette.svelte.d.ts +59 -0
  343. package/dist/search/index.d.ts +13 -0
  344. package/dist/search/index.js +13 -0
  345. package/dist/search/types.d.ts +40 -0
  346. package/dist/search/types.js +20 -0
  347. package/dist/seo/Head.svelte +190 -0
  348. package/dist/seo/Head.svelte.d.ts +86 -0
  349. package/dist/seo/JsonLd.svelte +30 -0
  350. package/dist/seo/JsonLd.svelte.d.ts +20 -0
  351. package/dist/seo/index.d.ts +18 -0
  352. package/dist/seo/index.js +17 -0
  353. package/dist/seo/json-ld.d.ts +33 -0
  354. package/dist/seo/json-ld.js +29 -0
  355. package/dist/seo/og-image.d.ts +72 -0
  356. package/dist/seo/og-image.js +82 -0
  357. package/dist/seo/types.d.ts +43 -0
  358. package/dist/seo/types.js +6 -0
  359. package/dist/theme.css +161 -0
  360. package/dist/tips/PopoverTip.svelte +80 -0
  361. package/dist/tips/PopoverTip.svelte.d.ts +33 -0
  362. package/dist/tips/Tip.svelte +91 -0
  363. package/dist/tips/Tip.svelte.d.ts +25 -0
  364. package/dist/tips/index.d.ts +15 -0
  365. package/dist/tips/index.js +14 -0
  366. package/dist/tips/tip-stack.d.ts +26 -0
  367. package/dist/tips/tip-stack.js +37 -0
  368. package/dist/tips/tip-store.svelte.d.ts +75 -0
  369. package/dist/tips/tip-store.svelte.js +158 -0
  370. package/dist/tips/types.d.ts +46 -0
  371. package/dist/tips/types.js +6 -0
  372. package/dist/ui/Accordion.svelte +75 -0
  373. package/dist/ui/Accordion.svelte.d.ts +50 -0
  374. package/dist/ui/AccordionItem.svelte +73 -0
  375. package/dist/ui/AccordionItem.svelte.d.ts +18 -0
  376. package/dist/ui/Alert.svelte +61 -0
  377. package/dist/ui/Alert.svelte.d.ts +37 -0
  378. package/dist/ui/Badge.svelte +39 -0
  379. package/dist/ui/Badge.svelte.d.ts +32 -0
  380. package/dist/ui/Button.svelte +44 -0
  381. package/dist/ui/Button.svelte.d.ts +29 -0
  382. package/dist/ui/ButtonGroup.svelte +24 -0
  383. package/dist/ui/ButtonGroup.svelte.d.ts +17 -0
  384. package/dist/ui/Card.svelte +49 -0
  385. package/dist/ui/Card.svelte.d.ts +44 -0
  386. package/dist/ui/Chip.svelte +58 -0
  387. package/dist/ui/Chip.svelte.d.ts +21 -0
  388. package/dist/ui/ConfirmButton.svelte +75 -0
  389. package/dist/ui/ConfirmButton.svelte.d.ts +48 -0
  390. package/dist/ui/ContextMenu.svelte +75 -0
  391. package/dist/ui/ContextMenu.svelte.d.ts +25 -0
  392. package/dist/ui/Disclosure.svelte +46 -0
  393. package/dist/ui/Disclosure.svelte.d.ts +22 -0
  394. package/dist/ui/Divider.svelte +47 -0
  395. package/dist/ui/Divider.svelte.d.ts +28 -0
  396. package/dist/ui/DropdownMenu.svelte +44 -0
  397. package/dist/ui/DropdownMenu.svelte.d.ts +30 -0
  398. package/dist/ui/EmptyState.svelte +37 -0
  399. package/dist/ui/EmptyState.svelte.d.ts +22 -0
  400. package/dist/ui/ExternalLink.svelte +38 -0
  401. package/dist/ui/ExternalLink.svelte.d.ts +34 -0
  402. package/dist/ui/Heading.svelte +58 -0
  403. package/dist/ui/Heading.svelte.d.ts +22 -0
  404. package/dist/ui/Link.svelte +34 -0
  405. package/dist/ui/Link.svelte.d.ts +20 -0
  406. package/dist/ui/LinkButton.svelte +51 -0
  407. package/dist/ui/LinkButton.svelte.d.ts +33 -0
  408. package/dist/ui/Menu.svelte +24 -0
  409. package/dist/ui/Menu.svelte.d.ts +13 -0
  410. package/dist/ui/MenuCheckboxItem.svelte +33 -0
  411. package/dist/ui/MenuCheckboxItem.svelte.d.ts +20 -0
  412. package/dist/ui/MenuItem.svelte +73 -0
  413. package/dist/ui/MenuItem.svelte.d.ts +21 -0
  414. package/dist/ui/MenuRadioGroup.svelte +25 -0
  415. package/dist/ui/MenuRadioGroup.svelte.d.ts +20 -0
  416. package/dist/ui/MenuRadioItem.svelte +20 -0
  417. package/dist/ui/MenuRadioItem.svelte.d.ts +15 -0
  418. package/dist/ui/MenuSeparator.svelte +27 -0
  419. package/dist/ui/MenuSeparator.svelte.d.ts +8 -0
  420. package/dist/ui/MenuSub.svelte +24 -0
  421. package/dist/ui/MenuSub.svelte.d.ts +15 -0
  422. package/dist/ui/Popover.svelte +63 -0
  423. package/dist/ui/Popover.svelte.d.ts +40 -0
  424. package/dist/ui/ShareButton.svelte +64 -0
  425. package/dist/ui/ShareButton.svelte.d.ts +39 -0
  426. package/dist/ui/Skeleton.svelte +43 -0
  427. package/dist/ui/Skeleton.svelte.d.ts +22 -0
  428. package/dist/ui/Spinner.svelte +41 -0
  429. package/dist/ui/Spinner.svelte.d.ts +35 -0
  430. package/dist/ui/Stack.svelte +36 -0
  431. package/dist/ui/Stack.svelte.d.ts +48 -0
  432. package/dist/ui/ThemeToggle.svelte +65 -0
  433. package/dist/ui/ThemeToggle.svelte.d.ts +24 -0
  434. package/dist/ui/ToggleButton.svelte +58 -0
  435. package/dist/ui/ToggleButton.svelte.d.ts +45 -0
  436. package/dist/ui/ToggleGroup.svelte +142 -0
  437. package/dist/ui/ToggleGroup.svelte.d.ts +86 -0
  438. package/dist/ui/Toolbar.svelte +40 -0
  439. package/dist/ui/Toolbar.svelte.d.ts +20 -0
  440. package/dist/ui/ToolbarButton.svelte +29 -0
  441. package/dist/ui/ToolbarButton.svelte.d.ts +21 -0
  442. package/dist/ui/ToolbarLink.svelte +21 -0
  443. package/dist/ui/ToolbarLink.svelte.d.ts +12 -0
  444. package/dist/ui/ToolbarSeparator.svelte +22 -0
  445. package/dist/ui/ToolbarSeparator.svelte.d.ts +12 -0
  446. package/dist/ui/ToolbarToggleGroup.svelte +66 -0
  447. package/dist/ui/ToolbarToggleGroup.svelte.d.ts +52 -0
  448. package/dist/ui/Tooltip.svelte +54 -0
  449. package/dist/ui/Tooltip.svelte.d.ts +35 -0
  450. package/dist/ui/VisuallyHidden.svelte +23 -0
  451. package/dist/ui/VisuallyHidden.svelte.d.ts +10 -0
  452. package/dist/ui/accordion-context.d.ts +26 -0
  453. package/dist/ui/accordion-context.js +23 -0
  454. package/dist/ui/colour-token.d.ts +41 -0
  455. package/dist/ui/colour-token.js +49 -0
  456. package/dist/ui/context-menu.d.ts +13 -0
  457. package/dist/ui/context-menu.js +13 -0
  458. package/dist/ui/index.d.ts +63 -0
  459. package/dist/ui/index.js +62 -0
  460. package/dist/ui/menu-context.d.ts +20 -0
  461. package/dist/ui/menu-context.js +22 -0
  462. package/dist/ui/menu-parts/CheckboxItemPart.svelte +26 -0
  463. package/dist/ui/menu-parts/CheckboxItemPart.svelte.d.ts +5 -0
  464. package/dist/ui/menu-parts/ItemPart.svelte +29 -0
  465. package/dist/ui/menu-parts/ItemPart.svelte.d.ts +5 -0
  466. package/dist/ui/menu-parts/RadioGroupPart.svelte +24 -0
  467. package/dist/ui/menu-parts/RadioGroupPart.svelte.d.ts +5 -0
  468. package/dist/ui/menu-parts/RadioItemPart.svelte +22 -0
  469. package/dist/ui/menu-parts/RadioItemPart.svelte.d.ts +5 -0
  470. package/dist/ui/menu-parts/SeparatorPart.svelte +16 -0
  471. package/dist/ui/menu-parts/SeparatorPart.svelte.d.ts +5 -0
  472. package/dist/ui/menu-parts/SubPart.svelte +28 -0
  473. package/dist/ui/menu-parts/SubPart.svelte.d.ts +5 -0
  474. package/dist/ui/menu-parts/menu-parts.d.ts +104 -0
  475. package/dist/ui/menu-parts/menu-parts.js +31 -0
  476. package/dist/ui/menu-parts/parts.d.ts +12 -0
  477. package/dist/ui/menu-parts/parts.js +27 -0
  478. package/dist/ui/slug.d.ts +19 -0
  479. package/dist/ui/slug.js +25 -0
  480. package/dist/ui/toggle-classes.d.ts +39 -0
  481. package/dist/ui/toggle-classes.js +36 -0
  482. package/dist/ui/tones.d.ts +103 -0
  483. package/dist/ui/tones.js +240 -0
  484. package/package.json +41 -25
@@ -0,0 +1,121 @@
1
+ /**
2
+ * The citation vocabulary and its formatter.
3
+ *
4
+ * The shape a `Citation` carries is deliberately not any particular app's
5
+ * publication model: this package is app-agnostic and presentational, and a
6
+ * component that imported a models package would put the whole model layer
7
+ * into every consumer's bundle for the sake of a title and a year. The app
8
+ * maps its resource onto this shape at its own seam, which is also what lets
9
+ * a Storybook story or a test render one from a literal.
10
+ *
11
+ * ## Why the formatter is a pure function here
12
+ *
13
+ * Formatting inside the component recomputes on every re-render and cannot
14
+ * be tested without mounting a component. Pulling it out fixes both — the
15
+ * caller can memoise, the list derives once — and a citation style is a pile
16
+ * of conditional punctuation, which is exactly the kind of code that is
17
+ * wrong in the fourth branch and never noticed by eye.
18
+ *
19
+ * The style is a compact author–date one. It is not CSL: a full CSL
20
+ * implementation is a dependency and a style-file pipeline, and most
21
+ * consumers need one readable rendering rather than eleven switchable ones.
22
+ *
23
+ * @module
24
+ */
25
+ // Absence is the empty string throughout the helpers below, not `T | undefined`.
26
+ // Every one of them feeds a join whose contract is already "skip the empty
27
+ // parts", so a missing clause genuinely IS "print nothing here".
28
+ /**
29
+ * The author phrase a compact style prints: one name, two joined by `&`, or
30
+ * the first followed by `et al.` A four-author paper printed in full is what
31
+ * makes a reference list unreadable, and the full byline is on the
32
+ * publication's own page.
33
+ */
34
+ const authorPhrase = (authors) => {
35
+ const [first, second] = authors;
36
+ if (first === undefined)
37
+ return '';
38
+ if (authors.length === 1)
39
+ return first;
40
+ if (authors.length === 2)
41
+ return `${first} & ${second}`;
42
+ return `${first} et al.`;
43
+ };
44
+ /** Join the non-empty parts of a clause with `separator`. */
45
+ const joinPresent = (parts, separator) => parts.filter((part) => part !== '').join(separator);
46
+ // The detail clause is the one part of a citation that differs by kind, and
47
+ // the eleven kinds collapse into FIVE shapes. Each shape is its own function
48
+ // below rather than an arm of one switch: the arms do not share a line of
49
+ // logic, and a single switch over eleven labels with a nested ternary in
50
+ // three of them is the shape that is wrong in the fourth branch and never
51
+ // noticed by eye.
52
+ /** A serial's clause: container, volume(issue), pages. Articles, journals, conference papers. */
53
+ const serialClause = (citation) => {
54
+ if (citation.container === undefined)
55
+ return '';
56
+ const volume = citation.volume === undefined
57
+ ? ''
58
+ : citation.issue === undefined
59
+ ? `, ${citation.volume}`
60
+ : `, ${citation.volume}(${citation.issue})`;
61
+ const pages = citation.pages === undefined ? '' : `, ${citation.pages}`;
62
+ return `${citation.container}${volume}${pages}`;
63
+ };
64
+ /** A chapter's clause: the volume it is in, and where in it. */
65
+ const chapterClause = (citation) => joinPresent([
66
+ citation.container === undefined ? '' : `In: ${citation.container}`,
67
+ citation.pages === undefined ? '' : `pp. ${citation.pages}`,
68
+ ], ', ');
69
+ /**
70
+ * An imprint clause: `place: publisher` when both are known, whichever one is
71
+ * known alone otherwise — the shape every compact style prints for a book, a
72
+ * thesis or a report.
73
+ */
74
+ const imprintClause = (citation) => joinPresent([citation.place ?? '', citation.publisher ?? ''], ': ');
75
+ /**
76
+ * A web source's clause. The access date is the whole point of citing one: it
77
+ * says which version of a mutable page the claim rests on.
78
+ */
79
+ const webClause = (citation) => {
80
+ if (citation.url === undefined)
81
+ return '';
82
+ const accessed = citation.accessed === undefined
83
+ ? ''
84
+ : ` (accessed ${citation.accessed.toISOString().slice(0, 10)})`;
85
+ return `Available at: ${citation.url}${accessed}`;
86
+ };
87
+ /** A hosted artefact's clause: whichever of publisher / repository is known. */
88
+ const hostClause = (citation) => citation.publisher ?? citation.container ?? '';
89
+ /** Kind → the shape its detail clause takes. Exhaustive over {@link CitationKind}. */
90
+ const DETAIL_CLAUSES = {
91
+ article: serialClause,
92
+ periodical: serialClause,
93
+ conference: serialClause,
94
+ chapter: chapterClause,
95
+ book: imprintClause,
96
+ thesis: imprintClause,
97
+ report: imprintClause,
98
+ web: webClause,
99
+ dataset: hostClause,
100
+ software: hostClause,
101
+ media: hostClause,
102
+ };
103
+ /** The publication-detail clause for a citation's kind. */
104
+ const detailClause = (citation) => DETAIL_CLAUSES[citation.kind](citation);
105
+ /**
106
+ * Render a citation as one formatted string.
107
+ *
108
+ * Pure and total: every branch is reachable from real data and none throws on
109
+ * a citation carrying nothing but a title, which is a state the corpus can
110
+ * genuinely be in (an ingested reference awaiting enrichment).
111
+ */
112
+ export const formatCitation = (citation) => {
113
+ const parts = joinPresent([
114
+ citation.authors === undefined ? '' : authorPhrase(citation.authors),
115
+ citation.year === undefined ? '' : `(${citation.year})`,
116
+ `“${citation.title}”`,
117
+ detailClause(citation),
118
+ citation.doi === undefined ? '' : `DOI: ${citation.doi}`,
119
+ ], '. ');
120
+ return `${parts}.`;
121
+ };
@@ -0,0 +1,102 @@
1
+ /**
2
+ * The record shapes the CSL-type citation renderers (`BookCitation`,
3
+ * `ChapterCitation`, `ScholarlyArticleCitation`, `ThesisCitation`,
4
+ * `ReportCitation`, `Publisher`) take.
5
+ *
6
+ * Defined HERE, locally, because the bibliographic model they will align with
7
+ * — `@thomasfosterau/biblio`. When it is, these types are
8
+ * expected to become structural subsets of its records (or re-exports of
9
+ * them), so an app maps once, at the seam, from its resource to these shapes.
10
+ * Until then they are deliberately plain: every contributor arm is already
11
+ * RESOLVED (a `Credit` with a name, not a linkage ref), every member is
12
+ * optional except what a reference cannot be written without, and nothing
13
+ * here knows about JSON:API, Effect or any app's resource vocabulary.
14
+ *
15
+ * Names follow Schema.org (`datePublished`, `numberOfPages`, `pageStart`),
16
+ * which is what the renderers emit as microdata.
17
+ *
18
+ * @module
19
+ */
20
+ import type { Credit } from './CreditList.svelte';
21
+ /** A year, or an instant whose UTC year is the one cited. See `formatting/Year`. */
22
+ export type CitationDate = Date | number | string;
23
+ /** A publisher (or awarding institution): a Person for a self-published work, usually an Organization. */
24
+ export interface PublisherRecord {
25
+ readonly name: string;
26
+ /** The Schema.org type. Default `Organization`. */
27
+ readonly itemtype?: 'Person' | 'Organization' | undefined;
28
+ /** Rendered as a PostalAddress before the name ("Oxford, UK: …"); only present parts. */
29
+ readonly address?: {
30
+ readonly locality?: string | undefined;
31
+ readonly region?: string | undefined;
32
+ readonly country?: string | undefined;
33
+ } | undefined;
34
+ }
35
+ /** The credited contributors a record carries, in credit order. Order is meaning; the renderers never re-sort. */
36
+ export interface CreditedRecord {
37
+ readonly authors?: readonly Credit[] | undefined;
38
+ readonly editors?: readonly Credit[] | undefined;
39
+ readonly translators?: readonly Credit[] | undefined;
40
+ }
41
+ /** A book (CSL `book`). */
42
+ export interface BookRecord extends CreditedRecord {
43
+ readonly title?: string | undefined;
44
+ readonly datePublished?: CitationDate | undefined;
45
+ /** The edition as written: `3rd`, `Revised`. */
46
+ readonly edition?: string | undefined;
47
+ readonly numberOfPages?: number | undefined;
48
+ readonly isbn?: string | undefined;
49
+ readonly url?: string | undefined;
50
+ readonly publisher?: PublisherRecord | undefined;
51
+ /** The series it is part of — rendered as a Schema.org BookSeries. */
52
+ readonly series?: {
53
+ readonly name: string;
54
+ } | undefined;
55
+ }
56
+ /** A chapter in a book (CSL `chapter`). */
57
+ export interface ChapterRecord {
58
+ readonly title?: string | undefined;
59
+ readonly authors?: readonly Credit[] | undefined;
60
+ readonly chapterNumber?: string | number | undefined;
61
+ readonly pageStart?: string | number | undefined;
62
+ readonly pageEnd?: string | number | undefined;
63
+ /** The containing book, when resolved — rendered as a nested `BookCitation`. */
64
+ readonly book?: BookRecord | undefined;
65
+ }
66
+ /** A journal article (CSL `article-journal`). */
67
+ export interface ScholarlyArticleRecord {
68
+ readonly title?: string | undefined;
69
+ readonly authors?: readonly Credit[] | undefined;
70
+ /** Usually the issue's publication year. */
71
+ readonly datePublished?: CitationDate | undefined;
72
+ readonly periodical?: {
73
+ readonly title?: string | undefined;
74
+ readonly issn?: string | undefined;
75
+ } | undefined;
76
+ readonly volumeNumber?: string | number | undefined;
77
+ readonly issueNumber?: string | number | undefined;
78
+ readonly pageStart?: string | number | undefined;
79
+ readonly pageEnd?: string | number | undefined;
80
+ readonly doi?: string | undefined;
81
+ readonly url?: string | undefined;
82
+ }
83
+ /** A thesis (CSL `thesis`). */
84
+ export interface ThesisRecord {
85
+ readonly title?: string | undefined;
86
+ readonly authors?: readonly Credit[] | undefined;
87
+ readonly datePublished?: CitationDate | undefined;
88
+ /** The degree, as written: `PhD`, `MSc`. */
89
+ readonly degree?: string | undefined;
90
+ /** The awarding institution. */
91
+ readonly institution?: PublisherRecord | undefined;
92
+ readonly url?: string | undefined;
93
+ }
94
+ /** A report (CSL `report`). */
95
+ export interface ReportRecord extends CreditedRecord {
96
+ readonly title?: string | undefined;
97
+ readonly datePublished?: CitationDate | undefined;
98
+ readonly numberOfPages?: number | undefined;
99
+ readonly url?: string | undefined;
100
+ /** Usually the issuing Organization. */
101
+ readonly publisher?: PublisherRecord | undefined;
102
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The record shapes the CSL-type citation renderers (`BookCitation`,
3
+ * `ChapterCitation`, `ScholarlyArticleCitation`, `ThesisCitation`,
4
+ * `ReportCitation`, `Publisher`) take.
5
+ *
6
+ * Defined HERE, locally, because the bibliographic model they will align with
7
+ * — `@thomasfosterau/biblio`. When it is, these types are
8
+ * expected to become structural subsets of its records (or re-exports of
9
+ * them), so an app maps once, at the seam, from its resource to these shapes.
10
+ * Until then they are deliberately plain: every contributor arm is already
11
+ * RESOLVED (a `Credit` with a name, not a linkage ref), every member is
12
+ * optional except what a reference cannot be written without, and nothing
13
+ * here knows about JSON:API, Effect or any app's resource vocabulary.
14
+ *
15
+ * Names follow Schema.org (`datePublished`, `numberOfPages`, `pageStart`),
16
+ * which is what the renderers emit as microdata.
17
+ *
18
+ * @module
19
+ */
20
+ export {};
@@ -0,0 +1,31 @@
1
+ /**
2
+ * `@thomasfosterau/components/citations` — a separate entry point so it never sits on
3
+ * the always-loaded path of a consumer that does not use it.
4
+ *
5
+ * A page's `<Citation>` and `<Footnote>` markers register into a shared
6
+ * `BibliographyManager` (provided by `setupBibliography`); `<ReferenceList>`
7
+ * and `<FootnoteList>` render what accumulated. `<CreditList>` renders a
8
+ * locale-joined byline for one role (authors, editors, translators, or a
9
+ * caller's own). `formatCitation` is the pure formatter the lists use, and
10
+ * `DOILink` / `ISBNLink` / `ISSNLink` render the three identifiers a
11
+ * citation commonly carries as resolvable links.
12
+ *
13
+ * @module
14
+ */
15
+ export { BibliographyManager, getBibliographyContext, setupBibliography, type BibliographyEntry, } from './bibliography.svelte.ts';
16
+ export { formatCitation, type Citation as CitationData, type CitationKind, type Footnote as FootnoteData, } from './citation.ts';
17
+ export { default as Citation } from './Citation.svelte';
18
+ export { default as CreditList, type Credit } from './CreditList.svelte';
19
+ export { default as DOILink } from './DOILink.svelte';
20
+ export { default as Footnote } from './Footnote.svelte';
21
+ export { default as FootnoteList } from './FootnoteList.svelte';
22
+ export { default as ISBNLink } from './ISBNLink.svelte';
23
+ export { default as ISSNLink } from './ISSNLink.svelte';
24
+ export { default as ReferenceList } from './ReferenceList.svelte';
25
+ export { default as BookCitation } from './BookCitation.svelte';
26
+ export { default as ChapterCitation } from './ChapterCitation.svelte';
27
+ export { default as ScholarlyArticleCitation } from './ScholarlyArticleCitation.svelte';
28
+ export { default as ThesisCitation } from './ThesisCitation.svelte';
29
+ export { default as ReportCitation } from './ReportCitation.svelte';
30
+ export { default as Publisher } from './Publisher.svelte';
31
+ export type { BookRecord, ChapterRecord, CitationDate, CreditedRecord, PublisherRecord, ReportRecord, ScholarlyArticleRecord, ThesisRecord, } from './csl.ts';
@@ -0,0 +1,36 @@
1
+ /**
2
+ * `@thomasfosterau/components/citations` — a separate entry point so it never sits on
3
+ * the always-loaded path of a consumer that does not use it.
4
+ *
5
+ * A page's `<Citation>` and `<Footnote>` markers register into a shared
6
+ * `BibliographyManager` (provided by `setupBibliography`); `<ReferenceList>`
7
+ * and `<FootnoteList>` render what accumulated. `<CreditList>` renders a
8
+ * locale-joined byline for one role (authors, editors, translators, or a
9
+ * caller's own). `formatCitation` is the pure formatter the lists use, and
10
+ * `DOILink` / `ISBNLink` / `ISSNLink` render the three identifiers a
11
+ * citation commonly carries as resolvable links.
12
+ *
13
+ * @module
14
+ */
15
+ export { BibliographyManager, getBibliographyContext, setupBibliography, } from "./bibliography.svelte.js";
16
+ // The two data shapes are re-exported under `*Data` names: `Citation` and
17
+ // `Footnote` are already taken by the components below, and a module cannot
18
+ // export a type and a Svelte component under one identifier (the
19
+ // component's binding is a value in the same declaration space).
20
+ export { formatCitation, } from "./citation.js";
21
+ export { default as Citation } from './Citation.svelte';
22
+ export { default as CreditList } from './CreditList.svelte';
23
+ export { default as DOILink } from './DOILink.svelte';
24
+ export { default as Footnote } from './Footnote.svelte';
25
+ export { default as FootnoteList } from './FootnoteList.svelte';
26
+ export { default as ISBNLink } from './ISBNLink.svelte';
27
+ export { default as ISSNLink } from './ISSNLink.svelte';
28
+ export { default as ReferenceList } from './ReferenceList.svelte';
29
+ // The CSL-type renderers, over the local record shapes in `./csl.ts` (which
30
+ // will align with `@thomasfosterau/biblio` once that is published).
31
+ export { default as BookCitation } from './BookCitation.svelte';
32
+ export { default as ChapterCitation } from './ChapterCitation.svelte';
33
+ export { default as ScholarlyArticleCitation } from './ScholarlyArticleCitation.svelte';
34
+ export { default as ThesisCitation } from './ThesisCitation.svelte';
35
+ export { default as ReportCitation } from './ReportCitation.svelte';
36
+ export { default as Publisher } from './Publisher.svelte';
@@ -0,0 +1,34 @@
1
+ /**
2
+ * A small `Intl.ListFormat` helper for `CreditList`.
3
+ *
4
+ * `CreditList` needs to interleave real markup (a name, possibly a link)
5
+ * between a locale's list separators ("A, B and C") — exactly what
6
+ * `Intl.ListFormat.formatToParts` is for. This is a deliberately independent
7
+ * implementation rather than a dependency on the `formatting/` family's
8
+ * `FormatList`: that family is owned by a different part of this build, and
9
+ * this is a handful of lines, not a shared abstraction worth a cross-family
10
+ * edge for.
11
+ *
12
+ * @module
13
+ */
14
+ /** One piece of a formatted list: an item from the input, or literal separator text. */
15
+ export type ListFormatPart<T> = {
16
+ readonly kind: 'item';
17
+ readonly value: T;
18
+ } | {
19
+ readonly kind: 'separator';
20
+ readonly value: string;
21
+ };
22
+ /** The `Intl.ListFormat` options `formatListParts` takes; omitted fields use the runtime defaults. */
23
+ export interface ListFormatOptions {
24
+ readonly locales?: string | readonly string[] | undefined;
25
+ readonly style?: Intl.ListFormatOptions['style'] | undefined;
26
+ readonly type?: Intl.ListFormatOptions['type'] | undefined;
27
+ }
28
+ /**
29
+ * Interleave `items` with the given locale's list punctuation, without
30
+ * losing each item's identity — `formatToParts` only ever hands back
31
+ * strings, so this maps its "element" parts back to the original items by
32
+ * the index it was asked to format.
33
+ */
34
+ export declare const formatListParts: <T>(items: readonly T[], options?: ListFormatOptions) => readonly ListFormatPart<T>[];
@@ -0,0 +1,40 @@
1
+ /**
2
+ * A small `Intl.ListFormat` helper for `CreditList`.
3
+ *
4
+ * `CreditList` needs to interleave real markup (a name, possibly a link)
5
+ * between a locale's list separators ("A, B and C") — exactly what
6
+ * `Intl.ListFormat.formatToParts` is for. This is a deliberately independent
7
+ * implementation rather than a dependency on the `formatting/` family's
8
+ * `FormatList`: that family is owned by a different part of this build, and
9
+ * this is a handful of lines, not a shared abstraction worth a cross-family
10
+ * edge for.
11
+ *
12
+ * @module
13
+ */
14
+ /**
15
+ * Interleave `items` with the given locale's list punctuation, without
16
+ * losing each item's identity — `formatToParts` only ever hands back
17
+ * strings, so this maps its "element" parts back to the original items by
18
+ * the index it was asked to format.
19
+ */
20
+ export const formatListParts = (items, options = {}) => {
21
+ // A mutable copy: TS6's `Intl.ListFormat` (svelte-check) takes no readonly array.
22
+ const { locales } = options;
23
+ const format = new Intl.ListFormat(typeof locales === 'object' ? [...locales] : locales, {
24
+ style: options.style ?? 'long',
25
+ type: options.type ?? 'conjunction',
26
+ });
27
+ const indices = items.map((_, index) => String(index));
28
+ return format.formatToParts(indices).map((part) => {
29
+ if (part.type !== 'element')
30
+ return { kind: 'separator', value: part.value };
31
+ // `formatToParts` only ever hands back the index strings this function
32
+ // itself generated one line up, one per `items` entry — the lookup
33
+ // cannot miss.
34
+ const index = Number.parseInt(part.value, 10);
35
+ const value = items[index];
36
+ if (value === undefined)
37
+ throw new Error(`formatListParts: no item at index ${index}`);
38
+ return { kind: 'item', value };
39
+ });
40
+ };
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The app-integration seam.
3
+ *
4
+ * A component here must not import `$app/*`: that would tie the package to
5
+ * SvelteKit and make it untestable outside one. The four things an app has
6
+ * to supply — how a path becomes an href, how to navigate, which href is the
7
+ * current page, and which locale `Intl` should format for — are read from
8
+ * this injected context instead. It carries NO copy: every user-facing
9
+ * string a component renders is a prop with an English default, so an i18n
10
+ * app passes its own messages at the call site.
11
+ *
12
+ * The app calls {@link setComponentsContext} once in its root layout. When
13
+ * no provider is mounted — unit tests, Storybook, a plain Svelte app —
14
+ * {@link defaultComponentsContext} supplies identity hrefs, `window.location`
15
+ * for navigation and the current-page check, and the runtime's default
16
+ * locale, so every component works unwired.
17
+ *
18
+ * @module
19
+ */
20
+ /** What an app supplies through `setComponentsContext`: link resolution, navigation, the current-page check and the formatting locale. */
21
+ export interface ComponentsContext {
22
+ /**
23
+ * The locale(s) `Intl` formatters use when a component is given none.
24
+ * `undefined` means the runtime default. A function, not a value, so a
25
+ * reactive i18n runtime is re-read on every render.
26
+ */
27
+ readonly locale: () => string | readonly string[] | undefined;
28
+ /** Resolve an app-relative path (`/books/1`) to the href to render. */
29
+ readonly href: (path: string) => string;
30
+ /** Client-side navigation (SvelteKit's `goto` in an app). */
31
+ readonly navigate: (url: string) => Promise<void> | void;
32
+ /** Whether `href` is the page currently shown — drives `aria-current="page"`. */
33
+ readonly isCurrent: (href: string) => boolean;
34
+ }
35
+ /** The context used when no provider is mounted. */
36
+ export declare const defaultComponentsContext: ComponentsContext;
37
+ /**
38
+ * Provide the app-integration context. Call once, high in the tree (the root
39
+ * layout). Omitted members — or members passed as `undefined` — fall back to
40
+ * {@link defaultComponentsContext} individually.
41
+ */
42
+ export declare function setComponentsContext(context: {
43
+ readonly [K in keyof ComponentsContext]?: ComponentsContext[K] | undefined;
44
+ }): void;
45
+ /** Read the app-integration context, falling back to {@link defaultComponentsContext}. */
46
+ export declare function getComponentsContext(): ComponentsContext;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The app-integration seam.
3
+ *
4
+ * A component here must not import `$app/*`: that would tie the package to
5
+ * SvelteKit and make it untestable outside one. The four things an app has
6
+ * to supply — how a path becomes an href, how to navigate, which href is the
7
+ * current page, and which locale `Intl` should format for — are read from
8
+ * this injected context instead. It carries NO copy: every user-facing
9
+ * string a component renders is a prop with an English default, so an i18n
10
+ * app passes its own messages at the call site.
11
+ *
12
+ * The app calls {@link setComponentsContext} once in its root layout. When
13
+ * no provider is mounted — unit tests, Storybook, a plain Svelte app —
14
+ * {@link defaultComponentsContext} supplies identity hrefs, `window.location`
15
+ * for navigation and the current-page check, and the runtime's default
16
+ * locale, so every component works unwired.
17
+ *
18
+ * @module
19
+ */
20
+ import { getContext, setContext } from 'svelte';
21
+ const hasWindow = () => typeof globalThis.window !== 'undefined';
22
+ /** The pathname of the document currently shown, or `''` off the client. */
23
+ const currentPathname = () => (hasWindow() ? globalThis.window.location.pathname : '');
24
+ /** The context used when no provider is mounted. */
25
+ export const defaultComponentsContext = {
26
+ locale: () => undefined,
27
+ href: (path) => path,
28
+ navigate: (url) => {
29
+ if (hasWindow())
30
+ globalThis.window.location.assign(url);
31
+ },
32
+ isCurrent: (href) => href !== '' && href === currentPathname(),
33
+ };
34
+ const CONTEXT_KEY = Symbol('@thomasfosterau/components:context');
35
+ /**
36
+ * Provide the app-integration context. Call once, high in the tree (the root
37
+ * layout). Omitted members — or members passed as `undefined` — fall back to
38
+ * {@link defaultComponentsContext} individually.
39
+ */
40
+ export function setComponentsContext(context) {
41
+ setContext(CONTEXT_KEY, {
42
+ locale: context.locale ?? defaultComponentsContext.locale,
43
+ href: context.href ?? defaultComponentsContext.href,
44
+ navigate: context.navigate ?? defaultComponentsContext.navigate,
45
+ isCurrent: context.isCurrent ?? defaultComponentsContext.isCurrent,
46
+ });
47
+ }
48
+ /** Read the app-integration context, falling back to {@link defaultComponentsContext}. */
49
+ export function getComponentsContext() {
50
+ return getContext(CONTEXT_KEY) ?? defaultComponentsContext;
51
+ }
@@ -0,0 +1,48 @@
1
+ <!-- @component
2
+ One message of a `MessageThread`: author, time, avatar, the body and a status line, as a daisyUI `chat` bubble.
3
+ -->
4
+ <!--
5
+ ChatBubble — an `<li>` holding an `<article>` named by its header, so a
6
+ reader moves message to message and hears "Ada Lovelace, 3 minutes ago"
7
+ before the body. The time is a real `<time datetime>` (`DateTime`, or
8
+ `RelativeTime` with the absolute instant in `title`). The avatar is
9
+ decorative (`aria-hidden`): the author's name is already text.
10
+
11
+ `side` is visual only: messages from the viewer sit at the end, and the
12
+ author string ("You") is what says whose they are, never the position or
13
+ the colour. The `<article>` is the daisyUI `chat` grid itself, so its
14
+ image / header / bubble / footer are its direct children, as
15
+ `chat.css` requires.
16
+ -->
17
+ <script lang="ts">import DateTime from "../formatting/DateTime.svelte";
18
+ import RelativeTime from "../formatting/RelativeTime.svelte";
19
+ import { chatBubbleTone } from "../ui/tones.js";
20
+ let { author, sentAt, side = "start", tone, relative = false, locales, avatar, footer, children, class: className, ...rest } = $props();
21
+ const uid = $props.id();
22
+ const headerId = `${uid}-header`;
23
+ const sideClass = {
24
+ start: "chat-start",
25
+ end: "chat-end"
26
+ };
27
+ </script>
28
+
29
+ <li>
30
+ <article {...rest} aria-labelledby={headerId} class={['chat', sideClass[side], className]}>
31
+ {#if avatar}
32
+ <div class="chat-image avatar" aria-hidden="true">{@render avatar()}</div>
33
+ {/if}
34
+ <div class="chat-header" id={headerId}>
35
+ {author}{#if sentAt !== undefined}<span class="sr-only">,</span>
36
+ {#if relative}
37
+ <RelativeTime value={sentAt} {locales} class="text-xs opacity-60" />
38
+ {:else}
39
+ <DateTime value={sentAt} {locales} dateStyle="medium" timeStyle="short" class="text-xs opacity-60" />
40
+ {/if}
41
+ {/if}
42
+ </div>
43
+ <div class={['chat-bubble', tone !== undefined && chatBubbleTone[tone]]}>{@render children()}</div>
44
+ {#if footer}
45
+ <div class="chat-footer opacity-60">{@render footer()}</div>
46
+ {/if}
47
+ </article>
48
+ </li>
@@ -0,0 +1,33 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { type Tone } from '../ui/tones.ts';
4
+ interface Props extends Omit<HTMLAttributes<HTMLElement>, 'children'> {
5
+ /** Display name of the author; part of the message's accessible name. */
6
+ author: string;
7
+ /** When it was sent: a `Date`, epoch milliseconds or an ISO string. */
8
+ sentAt?: Date | number | string | undefined;
9
+ /**
10
+ * `'end'` for the viewer's own messages.
11
+ * @defaultValue `'start'`
12
+ */
13
+ side?: 'start' | 'end' | undefined;
14
+ /** Bubble colour. Omitted, daisyUI's neutral bubble. */
15
+ tone?: Tone | undefined;
16
+ /**
17
+ * Show `sentAt` relative ("3 minutes ago") rather than absolute.
18
+ * @defaultValue `false`
19
+ */
20
+ relative?: boolean | undefined;
21
+ /** Locale(s) for the time; falls back to the components context. */
22
+ locales?: string | readonly string[] | undefined;
23
+ /** The avatar (an `Avatar` or an image); decorative here. */
24
+ avatar?: Snippet<[]> | undefined;
25
+ /** Status line under the bubble ("Delivered", "Edited"). */
26
+ footer?: Snippet<[]> | undefined;
27
+ /** The message body. */
28
+ children: Snippet<[]>;
29
+ }
30
+ /** One message of a `MessageThread`: author, time, avatar, the body and a status line, as a daisyUI `chat` bubble. */
31
+ declare const ChatBubble: import("svelte").Component<Props, {}, "">;
32
+ type ChatBubble = ReturnType<typeof ChatBubble>;
33
+ export default ChatBubble;