zabi-components 7.0.2 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (433) hide show
  1. package/CHANGELOG.md +1924 -0
  2. package/README.md +287 -11
  3. package/THEME.md +149 -332
  4. package/THEMING.md +1329 -163
  5. package/dist/atoms/ActionPanel.svelte +24 -9
  6. package/dist/atoms/ActionPanel.svelte.d.ts +2 -0
  7. package/dist/atoms/Avatar.svelte +104 -0
  8. package/dist/atoms/Avatar.svelte.d.ts +34 -0
  9. package/dist/atoms/Badge.svelte +124 -58
  10. package/dist/atoms/Badge.svelte.d.ts +17 -5
  11. package/dist/atoms/Button.svelte +212 -62
  12. package/dist/atoms/Button.svelte.d.ts +33 -2
  13. package/dist/atoms/Card.svelte +31 -28
  14. package/dist/atoms/Card.svelte.d.ts +5 -2
  15. package/dist/atoms/CardContent.svelte +10 -2
  16. package/dist/atoms/CardContent.svelte.d.ts +2 -0
  17. package/dist/atoms/CardFooter.svelte +10 -2
  18. package/dist/atoms/CardFooter.svelte.d.ts +2 -0
  19. package/dist/atoms/CardHeader.svelte +26 -6
  20. package/dist/atoms/CardHeader.svelte.d.ts +2 -0
  21. package/dist/atoms/Checkbox.svelte +52 -21
  22. package/dist/atoms/Checkbox.svelte.d.ts +6 -2
  23. package/dist/atoms/CodeBlock.svelte +35 -9
  24. package/dist/atoms/CodeBlock.svelte.d.ts +13 -3
  25. package/dist/atoms/ColorPicker.svelte +272 -52
  26. package/dist/atoms/ColorPicker.svelte.d.ts +6 -1
  27. package/dist/atoms/Container.svelte +17 -10
  28. package/dist/atoms/DateField.svelte +107 -0
  29. package/dist/atoms/DateField.svelte.d.ts +53 -0
  30. package/dist/atoms/Divider.svelte +4 -4
  31. package/dist/atoms/FeatureCard.svelte +4 -3
  32. package/dist/atoms/FieldMessages.svelte +69 -0
  33. package/dist/atoms/FieldMessages.svelte.d.ts +23 -0
  34. package/dist/atoms/FloatingActionButton.svelte +174 -0
  35. package/dist/atoms/FloatingActionButton.svelte.d.ts +51 -0
  36. package/dist/atoms/Heading.svelte +93 -32
  37. package/dist/atoms/Heading.svelte.d.ts +24 -4
  38. package/dist/atoms/IconButton.svelte +242 -53
  39. package/dist/atoms/IconButton.svelte.d.ts +49 -4
  40. package/dist/atoms/Input.svelte +267 -74
  41. package/dist/atoms/Input.svelte.d.ts +32 -2
  42. package/dist/atoms/List.svelte +13 -2
  43. package/dist/atoms/List.svelte.d.ts +2 -0
  44. package/dist/atoms/ListItem.svelte +44 -11
  45. package/dist/atoms/ListItem.svelte.d.ts +5 -0
  46. package/dist/atoms/ListItemLeading.svelte +4 -2
  47. package/dist/atoms/ListItemLeading.svelte.d.ts +1 -1
  48. package/dist/atoms/OptimizedImage.svelte +11 -2
  49. package/dist/atoms/OptimizedImage.svelte.d.ts +2 -0
  50. package/dist/atoms/Progress.svelte +31 -9
  51. package/dist/atoms/Progress.svelte.d.ts +6 -0
  52. package/dist/atoms/Radio.svelte +23 -3
  53. package/dist/atoms/Radio.svelte.d.ts +6 -2
  54. package/dist/atoms/Rating.svelte +494 -0
  55. package/dist/atoms/Rating.svelte.d.ts +56 -0
  56. package/dist/atoms/Select.svelte +475 -135
  57. package/dist/atoms/Select.svelte.d.ts +52 -2
  58. package/dist/atoms/SelectionControl.svelte +99 -18
  59. package/dist/atoms/SelectionControl.svelte.d.ts +6 -3
  60. package/dist/atoms/Skeleton.svelte +5 -3
  61. package/dist/atoms/Slider.svelte +309 -0
  62. package/dist/atoms/Slider.svelte.d.ts +40 -0
  63. package/dist/atoms/Spinner.svelte +57 -0
  64. package/dist/atoms/Spinner.svelte.d.ts +19 -0
  65. package/dist/atoms/Table.svelte +152 -6
  66. package/dist/atoms/Table.svelte.d.ts +15 -3
  67. package/dist/atoms/TemporalField.svelte +140 -0
  68. package/dist/atoms/TemporalField.svelte.d.ts +32 -0
  69. package/dist/atoms/Text.svelte +56 -15
  70. package/dist/atoms/Text.svelte.d.ts +13 -4
  71. package/dist/atoms/Textarea.svelte +57 -45
  72. package/dist/atoms/Textarea.svelte.d.ts +14 -2
  73. package/dist/atoms/ThemeToggle.svelte +238 -56
  74. package/dist/atoms/ThemeToggle.svelte.d.ts +28 -3
  75. package/dist/atoms/TimeField.svelte +108 -0
  76. package/dist/atoms/TimeField.svelte.d.ts +54 -0
  77. package/dist/atoms/Toast.svelte +25 -10
  78. package/dist/atoms/Toast.svelte.d.ts +2 -0
  79. package/dist/atoms/Toggle.svelte +60 -19
  80. package/dist/atoms/Toggle.svelte.d.ts +18 -2
  81. package/dist/atoms/Tooltip.svelte +583 -40
  82. package/dist/atoms/Tooltip.svelte.d.ts +26 -0
  83. package/dist/atoms/ZabiStringsProvider.svelte +45 -0
  84. package/dist/atoms/ZabiStringsProvider.svelte.d.ts +27 -0
  85. package/dist/atoms/index.d.ts +17 -0
  86. package/dist/atoms/index.js +12 -0
  87. package/dist/atoms/selection-control.styles.d.ts +36 -5
  88. package/dist/atoms/selection-control.styles.js +40 -9
  89. package/dist/components/atoms/index.d.ts +17 -0
  90. package/dist/components/atoms/index.d.ts.map +1 -1
  91. package/dist/components/atoms/selection-control.styles.d.ts +36 -5
  92. package/dist/components/atoms/selection-control.styles.d.ts.map +1 -1
  93. package/dist/components/index.d.ts +83 -3
  94. package/dist/components/index.d.ts.map +1 -1
  95. package/dist/components/molecules/index.d.ts +46 -0
  96. package/dist/components/molecules/index.d.ts.map +1 -1
  97. package/dist/components/molecules/toast-store.d.ts +53 -7
  98. package/dist/components/molecules/toast-store.d.ts.map +1 -1
  99. package/dist/components/organisms/index.d.ts +6 -0
  100. package/dist/components/organisms/index.d.ts.map +1 -1
  101. package/dist/components/types/variants.d.ts +15 -1
  102. package/dist/components/types/variants.d.ts.map +1 -1
  103. package/dist/components/util/app-shell.d.ts +28 -0
  104. package/dist/components/util/app-shell.d.ts.map +1 -0
  105. package/dist/components/util/avatar.d.ts +36 -0
  106. package/dist/components/util/avatar.d.ts.map +1 -0
  107. package/dist/components/util/bottom-sheet.d.ts +30 -0
  108. package/dist/components/util/bottom-sheet.d.ts.map +1 -0
  109. package/dist/components/util/bottom-tab-bar.d.ts +35 -0
  110. package/dist/components/util/bottom-tab-bar.d.ts.map +1 -0
  111. package/dist/components/util/calendar.d.ts +56 -0
  112. package/dist/components/util/calendar.d.ts.map +1 -0
  113. package/dist/components/util/cn.d.ts +8 -0
  114. package/dist/components/util/cn.d.ts.map +1 -0
  115. package/dist/components/util/collapsible.d.ts +58 -0
  116. package/dist/components/util/collapsible.d.ts.map +1 -0
  117. package/dist/components/util/confirm-dialog.d.ts +12 -0
  118. package/dist/components/util/confirm-dialog.d.ts.map +1 -0
  119. package/dist/components/util/date.d.ts +96 -0
  120. package/dist/components/util/date.d.ts.map +1 -0
  121. package/dist/components/util/drawer.d.ts +13 -0
  122. package/dist/components/util/drawer.d.ts.map +1 -0
  123. package/dist/components/util/dropdown.d.ts +47 -0
  124. package/dist/components/util/dropdown.d.ts.map +1 -0
  125. package/dist/components/util/field.d.ts +39 -0
  126. package/dist/components/util/field.d.ts.map +1 -0
  127. package/dist/components/util/fit-in-viewport.d.ts +201 -0
  128. package/dist/components/util/fit-in-viewport.d.ts.map +1 -0
  129. package/dist/components/util/focus-utils.d.ts +75 -2
  130. package/dist/components/util/focus-utils.d.ts.map +1 -1
  131. package/dist/components/util/hydration.d.ts +45 -0
  132. package/dist/components/util/hydration.d.ts.map +1 -0
  133. package/dist/components/util/keyboard-inset.d.ts +18 -0
  134. package/dist/components/util/keyboard-inset.d.ts.map +1 -0
  135. package/dist/components/util/media-grid.d.ts +51 -0
  136. package/dist/components/util/media-grid.d.ts.map +1 -0
  137. package/dist/components/util/media.d.ts +6 -0
  138. package/dist/components/util/media.d.ts.map +1 -0
  139. package/dist/components/util/overlay-chrome.d.ts +53 -0
  140. package/dist/components/util/overlay-chrome.d.ts.map +1 -0
  141. package/dist/components/util/overlay.d.ts +72 -0
  142. package/dist/components/util/overlay.d.ts.map +1 -0
  143. package/dist/components/util/photo.d.ts +215 -0
  144. package/dist/components/util/photo.d.ts.map +1 -0
  145. package/dist/components/util/portal.d.ts +23 -0
  146. package/dist/components/util/portal.d.ts.map +1 -0
  147. package/dist/components/util/pull-to-refresh.d.ts +27 -0
  148. package/dist/components/util/pull-to-refresh.d.ts.map +1 -0
  149. package/dist/components/util/radio-keys.d.ts +25 -0
  150. package/dist/components/util/radio-keys.d.ts.map +1 -0
  151. package/dist/components/util/rating.d.ts +23 -0
  152. package/dist/components/util/rating.d.ts.map +1 -0
  153. package/dist/components/util/ready-made-strings.d.ts +77 -0
  154. package/dist/components/util/ready-made-strings.d.ts.map +1 -0
  155. package/dist/components/util/scroll-padding.d.ts +20 -0
  156. package/dist/components/util/scroll-padding.d.ts.map +1 -0
  157. package/dist/components/util/segmented-control.d.ts +16 -0
  158. package/dist/components/util/segmented-control.d.ts.map +1 -0
  159. package/dist/components/util/select.d.ts +41 -0
  160. package/dist/components/util/select.d.ts.map +1 -0
  161. package/dist/components/util/sheet-drag.d.ts +60 -0
  162. package/dist/components/util/sheet-drag.d.ts.map +1 -0
  163. package/dist/components/util/sidebar.d.ts +63 -0
  164. package/dist/components/util/sidebar.d.ts.map +1 -0
  165. package/dist/components/util/sortable-list.d.ts +65 -0
  166. package/dist/components/util/sortable-list.d.ts.map +1 -0
  167. package/dist/components/util/ssr-safe.d.ts +4 -4
  168. package/dist/components/util/ssr-safe.d.ts.map +1 -1
  169. package/dist/components/util/stepper.d.ts +40 -0
  170. package/dist/components/util/stepper.d.ts.map +1 -0
  171. package/dist/components/util/swipeable-list-item.d.ts +36 -0
  172. package/dist/components/util/swipeable-list-item.d.ts.map +1 -0
  173. package/dist/components/util/theme-mode.d.ts +80 -0
  174. package/dist/components/util/theme-mode.d.ts.map +1 -0
  175. package/dist/components/util/toaster.d.ts +93 -0
  176. package/dist/components/util/toaster.d.ts.map +1 -0
  177. package/dist/components/util/tooltip.d.ts +10 -0
  178. package/dist/components/util/tooltip.d.ts.map +1 -0
  179. package/dist/components/util/top-navbar.d.ts +11 -0
  180. package/dist/components/util/top-navbar.d.ts.map +1 -0
  181. package/dist/components/util/touch-target.d.ts +31 -0
  182. package/dist/components/util/touch-target.d.ts.map +1 -0
  183. package/dist/components/util/zabi-strings.d.ts +133 -0
  184. package/dist/components/util/zabi-strings.d.ts.map +1 -0
  185. package/dist/create-theme/cli.js +169 -0
  186. package/dist/create-theme/index.d.ts +176 -0
  187. package/dist/create-theme/index.js +817 -0
  188. package/dist/create-theme/lib/ramp-math.js +128 -0
  189. package/dist/create-theme/lib/resolve.js +141 -0
  190. package/dist/create-theme/theme-data.js +1116 -0
  191. package/dist/index.d.ts +83 -3
  192. package/dist/index.js +60 -8
  193. package/dist/molecules/Alert.svelte +73 -66
  194. package/dist/molecules/Alert.svelte.d.ts +9 -1
  195. package/dist/molecules/AppBar.svelte +415 -0
  196. package/dist/molecules/AppBar.svelte.d.ts +69 -0
  197. package/dist/molecules/AvatarGroup.svelte +116 -0
  198. package/dist/molecules/AvatarGroup.svelte.d.ts +40 -0
  199. package/dist/molecules/BottomSheet.svelte +540 -0
  200. package/dist/molecules/BottomSheet.svelte.d.ts +93 -0
  201. package/dist/molecules/BottomTabBar.svelte +297 -0
  202. package/dist/molecules/BottomTabBar.svelte.d.ts +64 -0
  203. package/dist/molecules/Calendar.svelte +597 -0
  204. package/dist/molecules/Calendar.svelte.d.ts +72 -0
  205. package/dist/molecules/Collapsible.svelte +243 -0
  206. package/dist/molecules/Collapsible.svelte.d.ts +44 -0
  207. package/dist/molecules/CollapsibleGroup.svelte +126 -0
  208. package/dist/molecules/CollapsibleGroup.svelte.d.ts +14 -0
  209. package/dist/molecules/ComponentDemo.svelte +25 -5
  210. package/dist/molecules/ComponentDemo.svelte.d.ts +5 -0
  211. package/dist/molecules/ConfirmDialog.svelte +253 -0
  212. package/dist/molecules/ConfirmDialog.svelte.d.ts +55 -0
  213. package/dist/molecules/ContactForm.svelte +46 -19
  214. package/dist/molecules/ContactForm.svelte.d.ts +10 -0
  215. package/dist/molecules/Drawer.svelte +394 -0
  216. package/dist/molecules/Drawer.svelte.d.ts +55 -0
  217. package/dist/molecules/Dropdown.svelte +540 -50
  218. package/dist/molecules/Dropdown.svelte.d.ts +49 -6
  219. package/dist/molecules/DropdownItem.svelte +122 -0
  220. package/dist/molecules/DropdownItem.svelte.d.ts +28 -0
  221. package/dist/molecules/EmptyState.svelte +56 -10
  222. package/dist/molecules/EmptyState.svelte.d.ts +8 -0
  223. package/dist/molecules/Form.svelte +25 -14
  224. package/dist/molecules/Form.svelte.d.ts +13 -5
  225. package/dist/molecules/FormField.svelte +11 -2
  226. package/dist/molecules/FormField.svelte.d.ts +2 -0
  227. package/dist/molecules/Header.svelte +13 -3
  228. package/dist/molecules/Header.svelte.d.ts +2 -0
  229. package/dist/molecules/ImageUpload.svelte +422 -70
  230. package/dist/molecules/ImageUpload.svelte.d.ts +61 -5
  231. package/dist/molecules/MediaGrid.svelte +527 -0
  232. package/dist/molecules/MediaGrid.svelte.d.ts +77 -0
  233. package/dist/molecules/Modal.svelte +340 -45
  234. package/dist/molecules/Modal.svelte.d.ts +59 -7
  235. package/dist/molecules/NavigationMenu.svelte +15 -3
  236. package/dist/molecules/NavigationMenu.svelte.d.ts +4 -0
  237. package/dist/molecules/NavigationMenuContent.svelte +91 -36
  238. package/dist/molecules/NavigationMenuContent.svelte.d.ts +2 -0
  239. package/dist/molecules/NavigationMenuItem.svelte +10 -3
  240. package/dist/molecules/NavigationMenuItem.svelte.d.ts +2 -0
  241. package/dist/molecules/NavigationMenuLink.svelte +10 -2
  242. package/dist/molecules/NavigationMenuLink.svelte.d.ts +2 -0
  243. package/dist/molecules/NavigationMenuList.svelte +19 -4
  244. package/dist/molecules/NavigationMenuList.svelte.d.ts +2 -0
  245. package/dist/molecules/NavigationMenuTrigger.svelte +16 -3
  246. package/dist/molecules/NavigationMenuTrigger.svelte.d.ts +2 -0
  247. package/dist/molecules/Page.svelte +38 -2
  248. package/dist/molecules/Page.svelte.d.ts +13 -0
  249. package/dist/molecules/PhotoGrid.svelte +433 -0
  250. package/dist/molecules/PhotoGrid.svelte.d.ts +62 -0
  251. package/dist/molecules/PhotoViewer.svelte +1116 -0
  252. package/dist/molecules/PhotoViewer.svelte.d.ts +56 -0
  253. package/dist/molecules/PropsTable.svelte +26 -11
  254. package/dist/molecules/PropsTable.svelte.d.ts +5 -0
  255. package/dist/molecules/PullToRefresh.svelte +263 -0
  256. package/dist/molecules/PullToRefresh.svelte.d.ts +52 -0
  257. package/dist/molecules/RadioGroup.svelte +57 -15
  258. package/dist/molecules/RadioGroup.svelte.d.ts +16 -3
  259. package/dist/molecules/Section.svelte +13 -5
  260. package/dist/molecules/Section.svelte.d.ts +3 -1
  261. package/dist/molecules/SegmentedControl.svelte +323 -0
  262. package/dist/molecules/SegmentedControl.svelte.d.ts +34 -0
  263. package/dist/molecules/SidebarBrandHeader.svelte +24 -5
  264. package/dist/molecules/SidebarBrandHeader.svelte.d.ts +5 -0
  265. package/dist/molecules/SidebarFooter.svelte +39 -8
  266. package/dist/molecules/SidebarFooter.svelte.d.ts +5 -0
  267. package/dist/molecules/SidebarNavSection.svelte +12 -4
  268. package/dist/molecules/SidebarNavSection.svelte.d.ts +2 -0
  269. package/dist/molecules/SlideUp.svelte +253 -30
  270. package/dist/molecules/SlideUp.svelte.d.ts +31 -4
  271. package/dist/molecules/SortableList.svelte +632 -0
  272. package/dist/molecules/SortableList.svelte.d.ts +69 -0
  273. package/dist/molecules/Stepper.svelte +548 -0
  274. package/dist/molecules/Stepper.svelte.d.ts +39 -0
  275. package/dist/molecules/StickyActionBar.svelte +191 -0
  276. package/dist/molecules/StickyActionBar.svelte.d.ts +65 -0
  277. package/dist/molecules/SwipeableListItem.svelte +334 -0
  278. package/dist/molecules/SwipeableListItem.svelte.d.ts +54 -0
  279. package/dist/molecules/Tabs.svelte +254 -24
  280. package/dist/molecules/Tabs.svelte.d.ts +15 -4
  281. package/dist/molecules/Toaster.svelte +352 -6
  282. package/dist/molecules/Toaster.svelte.d.ts +95 -2
  283. package/dist/molecules/ToasterToast.svelte +279 -62
  284. package/dist/molecules/ToasterToast.svelte.d.ts +11 -0
  285. package/dist/molecules/UnsavedChangesBar.svelte +212 -0
  286. package/dist/molecules/UnsavedChangesBar.svelte.d.ts +43 -0
  287. package/dist/molecules/index.d.ts +46 -0
  288. package/dist/molecules/index.js +27 -0
  289. package/dist/molecules/toast-store.d.ts +53 -7
  290. package/dist/molecules/toast-store.js +21 -0
  291. package/dist/organisms/AppShell.svelte +196 -0
  292. package/dist/organisms/AppShell.svelte.d.ts +61 -0
  293. package/dist/organisms/SidebarAccountPanel.svelte +111 -12
  294. package/dist/organisms/SidebarAccountPanel.svelte.d.ts +21 -0
  295. package/dist/organisms/SidebarNavigation.svelte +193 -69
  296. package/dist/organisms/SidebarNavigation.svelte.d.ts +31 -1
  297. package/dist/organisms/SidebarPanel.svelte +45 -16
  298. package/dist/organisms/SidebarPanel.svelte.d.ts +2 -0
  299. package/dist/organisms/SidebarShell.svelte +263 -0
  300. package/dist/organisms/SidebarShell.svelte.d.ts +106 -0
  301. package/dist/organisms/TopNavbar.svelte +329 -33
  302. package/dist/organisms/TopNavbar.svelte.d.ts +28 -0
  303. package/dist/organisms/index.d.ts +6 -0
  304. package/dist/organisms/index.js +4 -0
  305. package/dist/routes/lib/variant-utils.d.ts +26 -0
  306. package/dist/routes/lib/{variant-utils.ts → variant-utils.js} +15 -46
  307. package/dist/types/components.d.ts +4 -0
  308. package/dist/types/components.d.ts.map +1 -1
  309. package/dist/types/events.js +1 -0
  310. package/dist/types/index.d.ts +605 -25
  311. package/dist/types/index.d.ts.map +1 -1
  312. package/dist/types/index.js +3 -0
  313. package/dist/types/variants.ts +17 -1
  314. package/dist/util/app-shell.d.ts +27 -0
  315. package/dist/util/app-shell.js +72 -0
  316. package/dist/util/avatar.d.ts +35 -0
  317. package/dist/util/avatar.js +52 -0
  318. package/dist/util/bottom-sheet.d.ts +29 -0
  319. package/dist/util/bottom-sheet.js +43 -0
  320. package/dist/util/bottom-tab-bar.d.ts +34 -0
  321. package/dist/util/bottom-tab-bar.js +54 -0
  322. package/dist/util/calendar.d.ts +55 -0
  323. package/dist/util/calendar.js +74 -0
  324. package/dist/util/cn.d.ts +7 -0
  325. package/dist/util/cn.js +48 -0
  326. package/dist/util/collapsible.d.ts +57 -0
  327. package/dist/util/collapsible.js +23 -0
  328. package/dist/util/confirm-dialog.d.ts +11 -0
  329. package/dist/util/confirm-dialog.js +2 -0
  330. package/dist/util/date.d.ts +95 -0
  331. package/dist/util/date.js +237 -0
  332. package/dist/util/drawer.d.ts +12 -0
  333. package/dist/util/drawer.js +7 -0
  334. package/dist/util/dropdown.d.ts +46 -0
  335. package/dist/util/dropdown.js +21 -0
  336. package/dist/util/field.d.ts +38 -0
  337. package/dist/util/field.js +38 -0
  338. package/dist/util/fit-in-viewport.d.ts +200 -0
  339. package/dist/util/fit-in-viewport.js +399 -0
  340. package/dist/util/focus-utils.d.ts +75 -2
  341. package/dist/util/focus-utils.js +182 -9
  342. package/dist/util/hydration.d.ts +44 -0
  343. package/dist/util/hydration.js +58 -0
  344. package/dist/util/keyboard-inset.d.ts +17 -0
  345. package/dist/util/keyboard-inset.js +53 -0
  346. package/dist/util/media-grid.d.ts +50 -0
  347. package/dist/util/media-grid.js +81 -0
  348. package/dist/util/media.d.ts +5 -0
  349. package/dist/util/media.js +10 -0
  350. package/dist/util/overlay-chrome.d.ts +52 -0
  351. package/dist/util/overlay-chrome.js +56 -0
  352. package/dist/util/overlay.d.ts +71 -0
  353. package/dist/util/overlay.js +240 -0
  354. package/dist/util/photo.d.ts +214 -0
  355. package/dist/util/photo.js +206 -0
  356. package/dist/util/portal.d.ts +22 -0
  357. package/dist/util/portal.js +50 -0
  358. package/dist/util/pull-to-refresh.d.ts +26 -0
  359. package/dist/util/pull-to-refresh.js +30 -0
  360. package/dist/util/radio-keys.d.ts +24 -0
  361. package/dist/util/radio-keys.js +49 -0
  362. package/dist/util/rating.d.ts +22 -0
  363. package/dist/util/rating.js +26 -0
  364. package/dist/util/ready-made-strings.d.ts +76 -0
  365. package/dist/util/ready-made-strings.js +67 -0
  366. package/dist/util/scroll-padding.d.ts +19 -0
  367. package/dist/util/scroll-padding.js +44 -0
  368. package/dist/util/segmented-control.d.ts +15 -0
  369. package/dist/util/segmented-control.js +1 -0
  370. package/dist/util/select.d.ts +40 -0
  371. package/dist/util/select.js +63 -0
  372. package/dist/util/sheet-drag.d.ts +59 -0
  373. package/dist/util/sheet-drag.js +241 -0
  374. package/dist/util/sidebar.d.ts +62 -0
  375. package/dist/util/sidebar.js +38 -0
  376. package/dist/util/sortable-list.d.ts +64 -0
  377. package/dist/util/sortable-list.js +53 -0
  378. package/dist/util/ssr-safe.d.ts +4 -4
  379. package/dist/util/stepper.d.ts +39 -0
  380. package/dist/util/stepper.js +38 -0
  381. package/dist/util/swipeable-list-item.d.ts +35 -0
  382. package/dist/util/swipeable-list-item.js +32 -0
  383. package/dist/util/theme-mode.d.ts +79 -0
  384. package/dist/util/theme-mode.js +121 -0
  385. package/dist/util/toaster.d.ts +92 -0
  386. package/dist/util/toaster.js +75 -0
  387. package/dist/util/tooltip.d.ts +9 -0
  388. package/dist/util/tooltip.js +18 -0
  389. package/dist/util/top-navbar.d.ts +10 -0
  390. package/dist/util/top-navbar.js +5 -0
  391. package/dist/util/touch-target.d.ts +30 -0
  392. package/dist/util/touch-target.js +30 -0
  393. package/dist/util/zabi-strings.d.ts +132 -0
  394. package/dist/util/zabi-strings.js +105 -0
  395. package/dist/zabi-components-colors.css +5 -2
  396. package/dist/zabi-components-theme-dark-only.css +574 -225
  397. package/dist/zabi-components-theme-dark.css +574 -225
  398. package/dist/zabi-components-theme-only.css +1680 -317
  399. package/dist/zabi-components-theme.css +1680 -317
  400. package/dist/zabi-components.css +4473 -1158
  401. package/docs/lucide-icons.md +41 -16
  402. package/docs/theme-imports.md +81 -11
  403. package/package.json +51 -29
  404. package/dist/lib/layout-width-tokens.d.ts +0 -17
  405. package/dist/lib/layout-width-tokens.d.ts.map +0 -1
  406. package/dist/lib/showcase/component-docs/Button.d.ts +0 -3
  407. package/dist/lib/showcase/component-docs/Button.d.ts.map +0 -1
  408. package/dist/lib/showcase/component-docs/Input.d.ts +0 -3
  409. package/dist/lib/showcase/component-docs/Input.d.ts.map +0 -1
  410. package/dist/lib/showcase/component-docs/List.d.ts +0 -3
  411. package/dist/lib/showcase/component-docs/List.d.ts.map +0 -1
  412. package/dist/lib/showcase/component-docs/Modal.d.ts +0 -3
  413. package/dist/lib/showcase/component-docs/Modal.d.ts.map +0 -1
  414. package/dist/lib/showcase/component-docs/Radio.d.ts +0 -3
  415. package/dist/lib/showcase/component-docs/Radio.d.ts.map +0 -1
  416. package/dist/lib/showcase/component-docs/SidebarNavigation.d.ts +0 -3
  417. package/dist/lib/showcase/component-docs/SidebarNavigation.d.ts.map +0 -1
  418. package/dist/lib/showcase/component-docs/Skeleton.d.ts +0 -3
  419. package/dist/lib/showcase/component-docs/Skeleton.d.ts.map +0 -1
  420. package/dist/lib/showcase/component-docs/_shared.d.ts +0 -12
  421. package/dist/lib/showcase/component-docs/_shared.d.ts.map +0 -1
  422. package/dist/lib/showcase/component-docs/index.d.ts +0 -4
  423. package/dist/lib/showcase/component-docs/index.d.ts.map +0 -1
  424. package/dist/lib/showcase/components-catalog.d.ts +0 -3
  425. package/dist/lib/showcase/components-catalog.d.ts.map +0 -1
  426. package/dist/lib/showcase/components-showcase-constants.d.ts +0 -89
  427. package/dist/lib/showcase/components-showcase-constants.d.ts.map +0 -1
  428. package/dist/lib/showcase/docs-sidebar-helpers.d.ts +0 -15
  429. package/dist/lib/showcase/docs-sidebar-helpers.d.ts.map +0 -1
  430. package/dist/routes/lib/focus-utils.d.ts +0 -12
  431. package/dist/routes/lib/focus-utils.ts +0 -110
  432. package/dist/routes/lib/ssr-safe.ts +0 -58
  433. package/scripts/fix-lucide-svelte-icon-dts.js +0 -35
@@ -0,0 +1,56 @@
1
+ /**
2
+ * The chrome of an overlay at large text: the header of a BottomSheet, Drawer,
3
+ * Modal or SlideUp, and the padding of its footer.
4
+ *
5
+ * Tailwind's spacing is in rem, so at `html { font-size: 200% }` the gutters,
6
+ * the gap above the title, the title and the close button all doubled. On a
7
+ * phone that left a third of a half-height sheet to what the sheet was opened
8
+ * for. This is navigation chrome, as the app bar is (see AppBar): it says
9
+ * where you are and how to leave, and it is not what the user enlarged the
10
+ * text to read. So it is laid out in px, and its title grows to 1.3 times its
11
+ * size and stops. The content, and whatever the app puts in the footer, scale
12
+ * in full. docs/ACCESSIBILITY.md has the reasoning against WCAG 1.4.4.
13
+ */
14
+ /**
15
+ * On the header box: the spacing scale in px for everything inside it, so
16
+ * `px-6`, `gap-4`, `size-8` and the 44px of `TOUCH_HIT_AREA` are the sizes
17
+ * they are at 100% text. Only for a box that holds chrome alone: an app's
18
+ * Button inside it would stop growing too, which is why a footer spells its
19
+ * padding out in px instead.
20
+ */
21
+ export const OVERLAY_CHROME = "[--spacing:4px]";
22
+ /**
23
+ * How a title wraps: onto as many lines as it needs, between words, and a
24
+ * word wider than the whole line is cut rather than left sticking out.
25
+ */
26
+ export const OVERLAY_TITLE_WRAP = "[overflow-wrap:break-word]";
27
+ /**
28
+ * On the title while the text is enlarged (`textIsEnlarged`): a word that does
29
+ * not fit at the end of a line is hyphenated by the rules of the page's
30
+ * `lang`, where the browser has them, before it is cut.
31
+ *
32
+ * Not at the default text size, and not narrowed with `hyphenate-limit-chars`:
33
+ * `hyphens: auto` hyphenates at the end of every line, not only where a word
34
+ * is too wide, and what a browser offers as a hyphenation point is the
35
+ * platform's ("sett-ings", "histor-y" in Chromium on macOS). A title that
36
+ * wraps between words today would get those. A limit, where it is supported
37
+ * at all (not in Safari), turns a hyphenated break of a shorter word into a
38
+ * plain cut.
39
+ */
40
+ export const OVERLAY_TITLE_HYPHENS = "hyphens-auto";
41
+ /**
42
+ * Whether the reader has enlarged the text: the root font size is above the
43
+ * 16px every browser starts from. Read when an overlay opens. False on the
44
+ * server and until then, which is the layout at the default size.
45
+ */
46
+ export function textIsEnlarged() {
47
+ if (typeof document === "undefined")
48
+ return false;
49
+ return parseFloat(getComputedStyle(document.documentElement).fontSize) > 16;
50
+ }
51
+ /** A title of 20px (`text-xl`): up to 26px, on the same 1.4 line. */
52
+ export const OVERLAY_TITLE_XL = "text-[length:min(1.25rem,26px)] leading-[1.4]";
53
+ /** A title of 24px (`text-2xl`): up to 31.2px, on the same 4/3 line. */
54
+ export const OVERLAY_TITLE_2XL = "text-[length:min(1.5rem,31.2px)] leading-[calc(4/3)]";
55
+ /** The "×" of a close button: a control, so the size it is at 100%. */
56
+ export const OVERLAY_CLOSE_GLYPH = "text-[24px] leading-[32px]";
@@ -0,0 +1,71 @@
1
+ /**
2
+ * What Modal, SlideUp and Drawer share beyond `focus-utils.ts`: the scroll
3
+ * lock on `<body>` and the Tab cycle inside the panel. One copy, so the
4
+ * overlays cannot drift apart and keep working when nested in any order.
5
+ */
6
+ /**
7
+ * Stops the page behind an overlay from scrolling. Ref-counted on `<body>`
8
+ * (`data-zabi-scroll-lock`), so nested overlays share one lock and the page
9
+ * scrolls again only when the last one has released it.
10
+ *
11
+ * Call it when the overlay opens, in the browser, and call the returned
12
+ * function when it closes.
13
+ */
14
+ export declare function lockBodyScroll(): () => void;
15
+ /**
16
+ * Keeps Tab inside `container`: call it from the panel's `keydown` handler.
17
+ * Focusables are re-queried on every Tab, so content added while the overlay
18
+ * is open stays inside the cycle. A Tab that comes from a dialog nested in the
19
+ * container is left to that dialog. The toasts on screen are in the cycle too,
20
+ * after the container's own controls: see `getToastFocusables`.
21
+ */
22
+ export declare function trapTabKey(container: HTMLElement | undefined, event: KeyboardEvent): void;
23
+ /**
24
+ * Watches a scrolling box in an overlay and reports whether it has to be a
25
+ * Tab stop itself: true when its content is taller than it and holds nothing
26
+ * that can take focus, so the keyboard would otherwise have no way to scroll
27
+ * it. The answer changes with the viewport and with the content, so it is
28
+ * reported again whenever either does.
29
+ *
30
+ * Call it when the overlay opens, in the browser; the returned function stops it.
31
+ */
32
+ export declare function watchScrollerNeedsFocus(box: HTMLElement, onChange: (needsFocus: boolean) => void): () => void;
33
+ /**
34
+ * Keeps an overlay on the part of the screen the on-screen keyboard leaves.
35
+ *
36
+ * Where the keyboard covers the page instead of shrinking it (iOS Safari,
37
+ * Chrome on Android), a panel at the bottom of a `fixed inset-0` root ends up
38
+ * behind it, footer and all. This moves the root's bottom edge up to the top
39
+ * of the keyboard (and its top edge down, if the browser has panned the
40
+ * screen), so everything laid out against the root follows: a sheet's height,
41
+ * a pinned footer, a drawer's end. `data-keyboard-open` is set on the root
42
+ * meanwhile. The field that has focus is scrolled back into view once the
43
+ * root has its new size. Where the page shrinks by itself, nothing is done.
44
+ *
45
+ * The root is usually the backdrop as well: while it is moved, its dimming is
46
+ * carried on past its edges, so the page does not show undimmed where the
47
+ * keyboard was while that slides away.
48
+ *
49
+ * `root` is the overlay's outermost, fixed element. Call it when the overlay
50
+ * opens, in the browser; the returned function stops it and puts the root back.
51
+ */
52
+ export declare function followKeyboard(root: HTMLElement): () => void;
53
+ /**
54
+ * Says that `footer` is pinned to the bottom of an open overlay, so what is
55
+ * drawn over the overlays (the toast stack) can stay off it. Call it when the
56
+ * footer is rendered, in the browser; the returned function withdraws it.
57
+ */
58
+ export declare function registerOverlayFooter(footer: HTMLElement): () => void;
59
+ /**
60
+ * Says that `header` is the top of an open overlay and holds its close
61
+ * button, so the toast stack starts below it and never lies over the one
62
+ * control that always closes the overlay. Call it when the header is
63
+ * rendered, in the browser; the returned function withdraws it.
64
+ */
65
+ export declare function registerOverlayHeader(header: HTMLElement): () => void;
66
+ /** The footer of the overlay on top, if it has one. */
67
+ export declare function topOverlayFooter(): HTMLElement | null;
68
+ /** The header of the overlay on top, if it has one. */
69
+ export declare function topOverlayHeader(): HTMLElement | null;
70
+ /** Calls `listener` whenever a registered header or footer appears, goes, moves or changes size. */
71
+ export declare function watchOverlayFooters(listener: () => void): () => void;
@@ -0,0 +1,240 @@
1
+ /**
2
+ * What Modal, SlideUp and Drawer share beyond `focus-utils.ts`: the scroll
3
+ * lock on `<body>` and the Tab cycle inside the panel. One copy, so the
4
+ * overlays cannot drift apart and keep working when nested in any order.
5
+ */
6
+ import { cycleTrappedFocus, DIALOG_SELECTOR, getFocusableElements } from "./focus-utils.js";
7
+ import { readKeyboardInset } from "./keyboard-inset.js";
8
+ /**
9
+ * Stops the page behind an overlay from scrolling. Ref-counted on `<body>`
10
+ * (`data-zabi-scroll-lock`), so nested overlays share one lock and the page
11
+ * scrolls again only when the last one has released it.
12
+ *
13
+ * Call it when the overlay opens, in the browser, and call the returned
14
+ * function when it closes.
15
+ */
16
+ export function lockBodyScroll() {
17
+ const body = document.body;
18
+ const count = Number(body.dataset.zabiScrollLock ?? "0");
19
+ if (count === 0) {
20
+ body.dataset.zabiScrollLockOverflow = body.style.overflow;
21
+ body.style.overflow = "hidden";
22
+ }
23
+ body.dataset.zabiScrollLock = String(count + 1);
24
+ return () => {
25
+ const next = Number(body.dataset.zabiScrollLock ?? "1") - 1;
26
+ if (next <= 0) {
27
+ body.style.overflow = body.dataset.zabiScrollLockOverflow ?? "";
28
+ delete body.dataset.zabiScrollLock;
29
+ delete body.dataset.zabiScrollLockOverflow;
30
+ }
31
+ else {
32
+ body.dataset.zabiScrollLock = String(next);
33
+ }
34
+ };
35
+ }
36
+ /**
37
+ * Keeps Tab inside `container`: call it from the panel's `keydown` handler.
38
+ * Focusables are re-queried on every Tab, so content added while the overlay
39
+ * is open stays inside the cycle. A Tab that comes from a dialog nested in the
40
+ * container is left to that dialog. The toasts on screen are in the cycle too,
41
+ * after the container's own controls: see `getToastFocusables`.
42
+ */
43
+ export function trapTabKey(container, event) {
44
+ if (event.key !== "Tab" || !container)
45
+ return;
46
+ // A nested dialog handles its own Tab cycle.
47
+ const owner = event.target?.closest?.(DIALOG_SELECTOR);
48
+ if (owner && owner !== container)
49
+ return;
50
+ cycleTrappedFocus(container, event);
51
+ }
52
+ /**
53
+ * Watches a scrolling box in an overlay and reports whether it has to be a
54
+ * Tab stop itself: true when its content is taller than it and holds nothing
55
+ * that can take focus, so the keyboard would otherwise have no way to scroll
56
+ * it. The answer changes with the viewport and with the content, so it is
57
+ * reported again whenever either does.
58
+ *
59
+ * Call it when the overlay opens, in the browser; the returned function stops it.
60
+ */
61
+ export function watchScrollerNeedsFocus(box, onChange) {
62
+ const measure = () => {
63
+ onChange(box.scrollHeight > box.clientHeight && getFocusableElements(box).length === 0);
64
+ };
65
+ measure();
66
+ const resize = typeof ResizeObserver === "function" ? new ResizeObserver(measure) : undefined;
67
+ resize?.observe(box);
68
+ const mutation = new MutationObserver(measure);
69
+ mutation.observe(box, { childList: true, subtree: true, characterData: true });
70
+ return () => {
71
+ resize?.disconnect();
72
+ mutation.disconnect();
73
+ };
74
+ }
75
+ /**
76
+ * Keeps an overlay on the part of the screen the on-screen keyboard leaves.
77
+ *
78
+ * Where the keyboard covers the page instead of shrinking it (iOS Safari,
79
+ * Chrome on Android), a panel at the bottom of a `fixed inset-0` root ends up
80
+ * behind it, footer and all. This moves the root's bottom edge up to the top
81
+ * of the keyboard (and its top edge down, if the browser has panned the
82
+ * screen), so everything laid out against the root follows: a sheet's height,
83
+ * a pinned footer, a drawer's end. `data-keyboard-open` is set on the root
84
+ * meanwhile. The field that has focus is scrolled back into view once the
85
+ * root has its new size. Where the page shrinks by itself, nothing is done.
86
+ *
87
+ * The root is usually the backdrop as well: while it is moved, its dimming is
88
+ * carried on past its edges, so the page does not show undimmed where the
89
+ * keyboard was while that slides away.
90
+ *
91
+ * `root` is the overlay's outermost, fixed element. Call it when the overlay
92
+ * opens, in the browser; the returned function stops it and puts the root back.
93
+ */
94
+ export function followKeyboard(root) {
95
+ if (typeof window === "undefined")
96
+ return () => { };
97
+ const viewport = window.visualViewport;
98
+ const restore = () => {
99
+ root.style.bottom = "";
100
+ root.style.top = "";
101
+ root.style.boxShadow = "";
102
+ delete root.dataset.keyboardOpen;
103
+ };
104
+ let last = "";
105
+ const update = () => {
106
+ const inset = readKeyboardInset();
107
+ // How far the browser has panned the screen to show the field. It
108
+ // counts when the pan is complete as well: nothing of the page is
109
+ // under the keyboard then (the inset is 0), and the top of the root
110
+ // is as far above the screen as the keyboard is tall.
111
+ const shorter = !!viewport &&
112
+ Math.abs(viewport.scale - 1) <= 0.01 &&
113
+ document.documentElement.clientHeight - viewport.height > 1;
114
+ const panned = shorter ? Math.max(0, Math.round(viewport.offsetTop)) : 0;
115
+ const key = `${inset}:${panned}`;
116
+ if (key === last)
117
+ return;
118
+ last = key;
119
+ if (inset > 0 || panned > 0) {
120
+ root.style.bottom = inset > 0 ? `${inset}px` : "";
121
+ root.style.top = panned > 0 ? `${panned}px` : "";
122
+ root.dataset.keyboardOpen = "true";
123
+ // The root is the backdrop too. What it no longer covers is under
124
+ // the keyboard, but shows for a moment while the keyboard slides
125
+ // away: the dimming goes on past the root's edges.
126
+ const dim = getComputedStyle(root).backgroundColor;
127
+ root.style.boxShadow =
128
+ dim && dim !== "transparent" && dim !== "rgba(0, 0, 0, 0)"
129
+ ? `0 0 0 100vmax ${dim}`
130
+ : "";
131
+ }
132
+ else {
133
+ restore();
134
+ }
135
+ notifyOverlayFooters();
136
+ const active = document.activeElement;
137
+ if (inset > 0 && active instanceof HTMLElement && root.contains(active)) {
138
+ active.scrollIntoView?.({ block: "nearest" });
139
+ }
140
+ };
141
+ update();
142
+ viewport?.addEventListener("resize", update);
143
+ viewport?.addEventListener("scroll", update);
144
+ window.addEventListener("resize", update);
145
+ return () => {
146
+ viewport?.removeEventListener("resize", update);
147
+ viewport?.removeEventListener("scroll", update);
148
+ window.removeEventListener("resize", update);
149
+ restore();
150
+ };
151
+ }
152
+ const overlayParts = [];
153
+ const footerListeners = new Set();
154
+ function notifyOverlayFooters() {
155
+ for (const listener of footerListeners)
156
+ listener();
157
+ }
158
+ function registerOverlayPart(part, element) {
159
+ const panel = element.closest(DIALOG_SELECTOR);
160
+ let entry = panel ? overlayParts.find((candidate) => candidate.panel === panel) : undefined;
161
+ if (!entry) {
162
+ entry = { panel };
163
+ overlayParts.push(entry);
164
+ }
165
+ const mine = entry;
166
+ mine[part] = element;
167
+ const observer = typeof ResizeObserver === "function" ? new ResizeObserver(notifyOverlayFooters) : undefined;
168
+ observer?.observe(element);
169
+ notifyOverlayFooters();
170
+ // An overlay that slides in is still on its way when its parts are
171
+ // rendered, and a move is not a change of size: say so again once the
172
+ // panel has come to rest.
173
+ let frame = 0;
174
+ const settle = () => {
175
+ frame = 0;
176
+ if (typeof panel?.getAnimations === "function" && panel.getAnimations().length > 0) {
177
+ frame = requestAnimationFrame(settle);
178
+ return;
179
+ }
180
+ notifyOverlayFooters();
181
+ };
182
+ if (panel && typeof requestAnimationFrame === "function")
183
+ frame = requestAnimationFrame(settle);
184
+ return () => {
185
+ if (frame)
186
+ cancelAnimationFrame(frame);
187
+ observer?.disconnect();
188
+ if (mine[part] === element)
189
+ delete mine[part];
190
+ if (!mine.header && !mine.footer) {
191
+ const index = overlayParts.indexOf(mine);
192
+ if (index !== -1)
193
+ overlayParts.splice(index, 1);
194
+ }
195
+ notifyOverlayFooters();
196
+ };
197
+ }
198
+ /**
199
+ * Says that `footer` is pinned to the bottom of an open overlay, so what is
200
+ * drawn over the overlays (the toast stack) can stay off it. Call it when the
201
+ * footer is rendered, in the browser; the returned function withdraws it.
202
+ */
203
+ export function registerOverlayFooter(footer) {
204
+ return registerOverlayPart("footer", footer);
205
+ }
206
+ /**
207
+ * Says that `header` is the top of an open overlay and holds its close
208
+ * button, so the toast stack starts below it and never lies over the one
209
+ * control that always closes the overlay. Call it when the header is
210
+ * rendered, in the browser; the returned function withdraws it.
211
+ */
212
+ export function registerOverlayHeader(header) {
213
+ return registerOverlayPart("header", header);
214
+ }
215
+ /** The parts of the overlay opened last that has registered any. */
216
+ function topOverlayParts() {
217
+ for (let index = overlayParts.length - 1; index >= 0; index -= 1) {
218
+ const entry = overlayParts[index];
219
+ if (entry.header?.isConnected || entry.footer?.isConnected)
220
+ return entry;
221
+ }
222
+ return undefined;
223
+ }
224
+ /** The footer of the overlay on top, if it has one. */
225
+ export function topOverlayFooter() {
226
+ const footer = topOverlayParts()?.footer;
227
+ return footer?.isConnected ? footer : null;
228
+ }
229
+ /** The header of the overlay on top, if it has one. */
230
+ export function topOverlayHeader() {
231
+ const header = topOverlayParts()?.header;
232
+ return header?.isConnected ? header : null;
233
+ }
234
+ /** Calls `listener` whenever a registered header or footer appears, goes, moves or changes size. */
235
+ export function watchOverlayFooters(listener) {
236
+ footerListeners.add(listener);
237
+ return () => {
238
+ footerListeners.delete(listener);
239
+ };
240
+ }
@@ -0,0 +1,214 @@
1
+ /**
2
+ * Public types and pure helpers for `PhotoGrid` and `PhotoViewer`.
3
+ *
4
+ * Everything a gesture means is worked out here, on numbers: where a pinch
5
+ * leaves the photo, how far it may be panned, whether a swipe turns the page.
6
+ * The components only feed pointers in and apply the result, so the
7
+ * arithmetic can be tested without a browser.
8
+ */
9
+ import type { Component } from "svelte";
10
+ export type PhotoKey = string | number;
11
+ /** One photo. `PhotoGrid` and `PhotoViewer` take the same array. */
12
+ export interface Photo {
13
+ /** Stable identity, when the same `src` may appear twice or may change. Without it, `src` is the identity. */
14
+ id?: PhotoKey;
15
+ /** The full image, shown in the viewer. */
16
+ src: string;
17
+ /** A small version for the grid, and for the viewer while the full image loads. Without it, `src`. */
18
+ thumbSrc?: string;
19
+ /** What the photo shows, for those who cannot see it. */
20
+ alt: string;
21
+ /** Width of the full image in px. With `height` it reserves the photo's box before it has loaded. */
22
+ width: number;
23
+ /** Height of the full image in px. */
24
+ height: number;
25
+ /** Shown under the photo in the viewer. */
26
+ caption?: string;
27
+ }
28
+ export declare function photoKey(photo: Photo): PhotoKey;
29
+ /** Payload of PhotoGrid's `onselect`. */
30
+ export interface PhotoGridSelectDetail {
31
+ photo: Photo;
32
+ index: number;
33
+ /** False when the press cleared the photo's selection (only in `multiple`). */
34
+ selected: boolean;
35
+ /** Every selected key after the change: one or none in `single`. */
36
+ keys: PhotoKey[];
37
+ }
38
+ /** Every built-in string of PhotoGrid. Pass a partial object to `strings` to translate. */
39
+ export interface PhotoGridStrings {
40
+ /** Visible label and name of the tile that adds a photo. */
41
+ addPhoto: string;
42
+ /** Name of a photo that has no `alt`. */
43
+ photoName: (position: number, total: number) => string;
44
+ /** Name of the last tile when it stands for the photos not shown. */
45
+ morePhotos: (count: number) => string;
46
+ /** Name of the button that opens a photo, in a grid where a press selects. */
47
+ openPhoto: (name: string) => string;
48
+ /** How to get around by keyboard. Read once when focus enters the grid, and shown while it has keyboard focus. */
49
+ keyboardHint: string;
50
+ }
51
+ export declare const PHOTO_GRID_STRINGS: PhotoGridStrings;
52
+ /** What the user did to close the viewer. `swipe` is a swipe down on the photo. */
53
+ export type PhotoViewerCloseReason = "escape" | "close-button" | "swipe";
54
+ /** Something to do with the photo that is showing: share it, delete it. */
55
+ export interface PhotoViewerAction {
56
+ id: string;
57
+ label: string;
58
+ /** An icon component, as `@lucide/svelte` icons are. */
59
+ icon?: Component<{
60
+ size?: number;
61
+ class?: string;
62
+ }>;
63
+ /** `danger` for a destructive action such as Delete. */
64
+ tone?: "danger";
65
+ disabled?: boolean;
66
+ onclick: (photo: Photo, index: number) => void;
67
+ }
68
+ /** Every built-in string of PhotoViewer. Pass a partial object to `strings` to translate. */
69
+ export interface PhotoViewerStrings {
70
+ close: string;
71
+ previous: string;
72
+ next: string;
73
+ /** The counter that is shown: "3 / 12". */
74
+ counter: (position: number, total: number) => string;
75
+ /** The same for a screen reader, read out after the photo's `alt`: "3 of 12". */
76
+ position: (position: number, total: number) => string;
77
+ /** Announced, with a spinner, when a photo takes a while to load. */
78
+ loading: string;
79
+ /** Shown when a photo cannot be loaded. */
80
+ loadError: string;
81
+ retry: string;
82
+ /** Name of the menu that holds the actions that do not fit in the bar. */
83
+ moreActions: string;
84
+ /** The button that shows all of a long caption, and the one that folds it again. */
85
+ showMore: string;
86
+ showLess: string;
87
+ /** Name of a photo that has no `alt`. */
88
+ photoName: (position: number, total: number) => string;
89
+ }
90
+ export declare const PHOTO_VIEWER_STRINGS: PhotoViewerStrings;
91
+ /** How many actions the viewer's bar shows before the rest go into a menu. */
92
+ export declare const MAX_BAR_ACTIONS = 3;
93
+ /** The actions shown in the bar, and those that go into the menu. */
94
+ export declare function splitActions<T>(actions: readonly T[], max?: number): {
95
+ bar: T[];
96
+ menu: T[];
97
+ };
98
+ /** An index held inside a list of `count` photos; -1 for an empty list. */
99
+ export declare function clampIndex(index: number, count: number): number;
100
+ /** What the grid shows of `total` photos under `max`, and how many the last tile stands for. */
101
+ export declare function visibleCount(total: number, max: number | undefined): {
102
+ shown: number;
103
+ hidden: number;
104
+ };
105
+ export interface Size {
106
+ width: number;
107
+ height: number;
108
+ }
109
+ export interface Point {
110
+ x: number;
111
+ y: number;
112
+ }
113
+ /**
114
+ * Where the photo is. `scale` 1 is the photo fitted to the screen. `x` and
115
+ * `y` are how far its centre is from the centre of the screen, in px.
116
+ */
117
+ export interface PhotoTransform {
118
+ scale: number;
119
+ x: number;
120
+ y: number;
121
+ }
122
+ export declare const REST: PhotoTransform;
123
+ export declare const MIN_SCALE = 1;
124
+ export declare const MAX_SCALE = 4;
125
+ /** What a double tap zooms to. */
126
+ export declare const DOUBLE_TAP_SCALE = 2.5;
127
+ export declare const isZoomed: (transform: PhotoTransform) => boolean;
128
+ /** The largest size a photo of `photo` px takes inside `view` without being cropped. */
129
+ export declare function fitSize(photo: Size, view: Size): Size;
130
+ /**
131
+ * The transform with its pan held to the photo's edges: an edge of the photo
132
+ * never comes further in than the edge of the screen, and a side that is
133
+ * narrower than the screen stays centred. `fit` is the photo's size at scale 1.
134
+ */
135
+ export declare function clampPan(transform: PhotoTransform, fit: Size, view: Size): PhotoTransform;
136
+ /**
137
+ * Zooms to `scale` so that the point of the photo under `point` stays under
138
+ * it. `point` is measured from the centre of the screen.
139
+ */
140
+ export declare function zoomAbout(transform: PhotoTransform, scale: number, point: Point, fit: Size, view: Size): PhotoTransform;
141
+ /** Two fingers on the glass: the point between them, and how far apart they are. */
142
+ export interface PinchSample {
143
+ centre: Point;
144
+ distance: number;
145
+ }
146
+ export declare function pinchSample(first: Point, second: Point): PinchSample;
147
+ /**
148
+ * Where a pinch has taken the photo: scaled by how much the fingers have
149
+ * spread, about the point that was between them when it began, and moved with
150
+ * that point. Points are measured from the centre of the screen.
151
+ */
152
+ export declare function pinchTransform(start: PhotoTransform, from: PinchSample, now: PinchSample, fit: Size, view: Size): PhotoTransform;
153
+ /** A pinch let go a hair above the fitted size is the fitted size. */
154
+ export declare function settleZoom(transform: PhotoTransform, fit: Size, view: Size): PhotoTransform;
155
+ /** A double tap: in to 2.5 times about the tap from the fitted photo, and back to fitted from any zoom. */
156
+ export declare function doubleTapTransform(transform: PhotoTransform, point: Point, fit: Size, view: Size): PhotoTransform;
157
+ /** The photo moved by `delta` px, held to its edges. */
158
+ export declare function panBy(transform: PhotoTransform, delta: Point, fit: Size, view: Size): PhotoTransform;
159
+ /** One step of the keyboard or the wheel: in or out by half again, about the centre. */
160
+ export declare const ZOOM_STEP = 1.5;
161
+ /** Movement under this many px is a press, not a drag. */
162
+ export declare const TAP_SLOP = 8;
163
+ /** A press shorter than this is a tap, and two taps closer together than this are a double tap. */
164
+ export declare const TAP_MS = 300;
165
+ /** Two taps further apart than this are two taps. */
166
+ export declare const DOUBLE_TAP_RADIUS = 32;
167
+ export declare function isDoubleTap(previous: {
168
+ time: number;
169
+ point: Point;
170
+ } | null, now: {
171
+ time: number;
172
+ point: Point;
173
+ }): boolean;
174
+ /**
175
+ * Which way a drag on the fitted photo is going, once it has gone far enough
176
+ * to tell: `x` turns the page, `down` closes, and null is not yet known. A
177
+ * drag upwards is neither, and stays null.
178
+ */
179
+ export declare function dragAxis(delta: Point, slop?: number): "x" | "down" | null;
180
+ /** Part of the screen's width a slow swipe has to cross to turn the page. */
181
+ export declare const TURN_DISTANCE = 0.25;
182
+ /** Part of the screen's height a slow swipe down has to cross to close. */
183
+ export declare const CLOSE_DISTANCE = 0.2;
184
+ /**
185
+ * What a horizontal swipe does when the finger lifts. A flick decides by its
186
+ * direction; a slow one by how far it went. Swiping left shows the next
187
+ * photo, and the previous one in a right-to-left layout. At either end there
188
+ * is nothing to turn to.
189
+ */
190
+ export declare function swipeTurn(options: {
191
+ /** px moved; negative is to the left. */
192
+ distance: number;
193
+ /** px per ms at release; negative is to the left. */
194
+ velocity: number;
195
+ width: number;
196
+ index: number;
197
+ count: number;
198
+ rtl?: boolean;
199
+ flick: number;
200
+ }): -1 | 0 | 1;
201
+ /** Whether a swipe down closes the viewer when the finger lifts. */
202
+ export declare function swipeCloses(options: {
203
+ /** px moved down. */
204
+ distance: number;
205
+ /** px per ms at release; positive is down. */
206
+ velocity: number;
207
+ height: number;
208
+ flick: number;
209
+ }): boolean;
210
+ /**
211
+ * How far a drag past the first or last photo moves it: a third of the
212
+ * finger's travel, so it gives but does not come away.
213
+ */
214
+ export declare function resist(distance: number): number;