@zonsh/ui 0.0.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (425) hide show
  1. package/LICENSE +43 -0
  2. package/README.md +81 -1
  3. package/assets/illustrations/drawing/bracket-construction-dark.svg +77 -0
  4. package/assets/illustrations/drawing/bracket-construction-filled-dark.svg +50 -0
  5. package/assets/illustrations/drawing/bracket-construction-filled.svg +50 -0
  6. package/assets/illustrations/drawing/bracket-construction.svg +77 -0
  7. package/assets/illustrations/drawing/crescent-dark.svg +28 -0
  8. package/assets/illustrations/drawing/crescent-guides-dark.svg +33 -0
  9. package/assets/illustrations/drawing/crescent-guides.svg +33 -0
  10. package/assets/illustrations/drawing/crescent.svg +28 -0
  11. package/assets/illustrations/drawing/eclipse-dark.svg +187 -0
  12. package/assets/illustrations/drawing/eclipse-guides-dark.svg +191 -0
  13. package/assets/illustrations/drawing/eclipse-guides.svg +191 -0
  14. package/assets/illustrations/drawing/eclipse.svg +187 -0
  15. package/assets/illustrations/drawing/elevation-guides-dark.svg +31 -0
  16. package/assets/illustrations/drawing/elevation-guides-plain-dark.svg +9 -0
  17. package/assets/illustrations/drawing/elevation-guides-plain.svg +9 -0
  18. package/assets/illustrations/drawing/elevation-guides.svg +31 -0
  19. package/assets/illustrations/drawing/horizon-dark.svg +30 -0
  20. package/assets/illustrations/drawing/horizon.svg +30 -0
  21. package/assets/illustrations/drawing/nib-study-dark.svg +107 -0
  22. package/assets/illustrations/drawing/nib-study-plain-dark.svg +93 -0
  23. package/assets/illustrations/drawing/nib-study-plain.svg +93 -0
  24. package/assets/illustrations/drawing/nib-study.svg +107 -0
  25. package/assets/illustrations/editorial/assistant-640.webp +0 -0
  26. package/assets/illustrations/editorial/assistant.webp +0 -0
  27. package/assets/illustrations/editorial/automation-640.webp +0 -0
  28. package/assets/illustrations/editorial/automation.webp +0 -0
  29. package/assets/illustrations/editorial/bracket-left-640.webp +0 -0
  30. package/assets/illustrations/editorial/bracket-left.webp +0 -0
  31. package/assets/illustrations/editorial/bracket-right-640.webp +0 -0
  32. package/assets/illustrations/editorial/bracket-right.webp +0 -0
  33. package/assets/illustrations/editorial/custom-software-640.webp +0 -0
  34. package/assets/illustrations/editorial/custom-software.webp +0 -0
  35. package/assets/illustrations/editorial/digitalization-640.webp +0 -0
  36. package/assets/illustrations/editorial/digitalization.webp +0 -0
  37. package/assets/illustrations/editorial/integration-640.webp +0 -0
  38. package/assets/illustrations/editorial/integration.webp +0 -0
  39. package/assets/illustrations/editorial/problem-640.webp +0 -0
  40. package/assets/illustrations/editorial/problem.webp +0 -0
  41. package/assets/illustrations/editorial/process-analysis-640.webp +0 -0
  42. package/assets/illustrations/editorial/process-analysis.webp +0 -0
  43. package/assets/illustrations/editorial/process-concept-640.webp +0 -0
  44. package/assets/illustrations/editorial/process-concept.webp +0 -0
  45. package/assets/illustrations/editorial/process-development-640.webp +0 -0
  46. package/assets/illustrations/editorial/process-development.webp +0 -0
  47. package/assets/illustrations/editorial/process-discovery-640.webp +0 -0
  48. package/assets/illustrations/editorial/process-discovery.webp +0 -0
  49. package/assets/illustrations/editorial/process-maintenance-640.webp +0 -0
  50. package/assets/illustrations/editorial/process-maintenance.webp +0 -0
  51. package/assets/illustrations/editorial/process-prototype-640.webp +0 -0
  52. package/assets/illustrations/editorial/process-prototype.webp +0 -0
  53. package/assets/illustrations/editorial/process-testing-640.webp +0 -0
  54. package/assets/illustrations/editorial/process-testing.webp +0 -0
  55. package/assets/illustrations/iso/automation-dark.svg +6 -0
  56. package/assets/illustrations/iso/automation.svg +6 -0
  57. package/assets/illustrations/iso/bar-chart-dark.svg +6 -0
  58. package/assets/illustrations/iso/bar-chart.svg +6 -0
  59. package/assets/illustrations/iso/brackets-classic-dark.svg +6 -0
  60. package/assets/illustrations/iso/brackets-classic.svg +6 -0
  61. package/assets/illustrations/iso/brackets-dark.svg +6 -0
  62. package/assets/illustrations/iso/brackets.svg +6 -0
  63. package/assets/illustrations/iso/city-dark.svg +6 -0
  64. package/assets/illustrations/iso/city.svg +6 -0
  65. package/assets/illustrations/iso/conveyor-dark.svg +6 -0
  66. package/assets/illustrations/iso/conveyor.svg +6 -0
  67. package/assets/illustrations/iso/database-dark.svg +6 -0
  68. package/assets/illustrations/iso/database.svg +6 -0
  69. package/assets/illustrations/iso/documents-dark.svg +6 -0
  70. package/assets/illustrations/iso/documents.svg +6 -0
  71. package/assets/illustrations/iso/inbox-dark.svg +6 -0
  72. package/assets/illustrations/iso/inbox.svg +6 -0
  73. package/assets/illustrations/iso/laptop-dark.svg +6 -0
  74. package/assets/illustrations/iso/laptop.svg +6 -0
  75. package/assets/illustrations/iso/monitor-dark.svg +6 -0
  76. package/assets/illustrations/iso/monitor.svg +6 -0
  77. package/assets/illustrations/iso/pipeline-dark.svg +6 -0
  78. package/assets/illustrations/iso/pipeline.svg +6 -0
  79. package/assets/illustrations/iso/platform-dark.svg +6 -0
  80. package/assets/illustrations/iso/platform.svg +6 -0
  81. package/assets/illustrations/iso/server-dark.svg +6 -0
  82. package/assets/illustrations/iso/server.svg +6 -0
  83. package/assets/illustrations/iso/spreadsheet-dark.svg +6 -0
  84. package/assets/illustrations/iso/spreadsheet.svg +6 -0
  85. package/assets/illustrations/iso/timeline-dark.svg +6 -0
  86. package/assets/illustrations/iso/timeline.svg +6 -0
  87. package/assets/illustrations/sheet/construction.svg +115 -0
  88. package/assets/illustrations/sheet/crescent.svg +40 -0
  89. package/assets/illustrations/sheet/limb.svg +42 -0
  90. package/assets/illustrations/sheet/stress-axis.svg +119 -0
  91. package/assets/illustrations/sheet/totality.svg +215 -0
  92. package/assets/illustrations/sheet/vertical-metrics.svg +43 -0
  93. package/assets/logo-left.svg +1 -0
  94. package/assets/logo-right.svg +1 -0
  95. package/assets/logo.svg +1 -0
  96. package/dist/components/_overlay.d.ts +47 -0
  97. package/dist/components/_overlay.js +59 -0
  98. package/dist/components/accordion.d.ts +32 -0
  99. package/dist/components/accordion.js +39 -0
  100. package/dist/components/alert-dialog.d.ts +45 -0
  101. package/dist/components/alert-dialog.js +56 -0
  102. package/dist/components/alert.d.ts +35 -0
  103. package/dist/components/alert.js +42 -0
  104. package/dist/components/ascii-field.d.ts +34 -0
  105. package/dist/components/ascii-field.js +410 -0
  106. package/dist/components/aspect-ratio.d.ts +14 -0
  107. package/dist/components/aspect-ratio.js +17 -0
  108. package/dist/components/avatar.d.ts +42 -0
  109. package/dist/components/avatar.js +55 -0
  110. package/dist/components/badge.d.ts +70 -0
  111. package/dist/components/badge.js +62 -0
  112. package/dist/components/bottom-nav.d.ts +86 -0
  113. package/dist/components/bottom-nav.js +175 -0
  114. package/dist/components/breadcrumb.d.ts +31 -0
  115. package/dist/components/breadcrumb.js +37 -0
  116. package/dist/components/button-group.d.ts +30 -0
  117. package/dist/components/button-group.js +47 -0
  118. package/dist/components/button.d.ts +53 -0
  119. package/dist/components/button.js +130 -0
  120. package/dist/components/calendar.d.ts +26 -0
  121. package/dist/components/calendar.js +179 -0
  122. package/dist/components/card.d.ts +42 -0
  123. package/dist/components/card.js +76 -0
  124. package/dist/components/carousel.d.ts +109 -0
  125. package/dist/components/carousel.js +231 -0
  126. package/dist/components/chart.d.ts +189 -0
  127. package/dist/components/chart.js +323 -0
  128. package/dist/components/checkbox.d.ts +23 -0
  129. package/dist/components/checkbox.js +43 -0
  130. package/dist/components/code-block.d.ts +55 -0
  131. package/dist/components/code-block.js +100 -0
  132. package/dist/components/collapsible.d.ts +20 -0
  133. package/dist/components/collapsible.js +32 -0
  134. package/dist/components/color-picker.d.ts +107 -0
  135. package/dist/components/color-picker.js +428 -0
  136. package/dist/components/combobox.d.ts +99 -0
  137. package/dist/components/combobox.js +172 -0
  138. package/dist/components/command.d.ts +132 -0
  139. package/dist/components/command.js +257 -0
  140. package/dist/components/context-menu.d.ts +29 -0
  141. package/dist/components/context-menu.js +35 -0
  142. package/dist/components/conversation.d.ts +36 -0
  143. package/dist/components/conversation.js +303 -0
  144. package/dist/components/copy-button.d.ts +55 -0
  145. package/dist/components/copy-button.js +133 -0
  146. package/dist/components/data-table.d.ts +235 -0
  147. package/dist/components/data-table.js +655 -0
  148. package/dist/components/date-picker.d.ts +160 -0
  149. package/dist/components/date-picker.js +338 -0
  150. package/dist/components/dialog.d.ts +57 -0
  151. package/dist/components/dialog.js +95 -0
  152. package/dist/components/direction.d.ts +16 -0
  153. package/dist/components/direction.js +18 -0
  154. package/dist/components/drawer.d.ts +69 -0
  155. package/dist/components/drawer.js +79 -0
  156. package/dist/components/empty.d.ts +31 -0
  157. package/dist/components/empty.js +50 -0
  158. package/dist/components/feature-list.d.ts +54 -0
  159. package/dist/components/feature-list.js +43 -0
  160. package/dist/components/field.d.ts +34 -0
  161. package/dist/components/field.js +81 -0
  162. package/dist/components/file-drop.d.ts +77 -0
  163. package/dist/components/file-drop.js +258 -0
  164. package/dist/components/filter-bar.d.ts +153 -0
  165. package/dist/components/filter-bar.js +334 -0
  166. package/dist/components/form.d.ts +35 -0
  167. package/dist/components/form.js +56 -0
  168. package/dist/components/graph.d.ts +146 -0
  169. package/dist/components/graph.js +825 -0
  170. package/dist/components/illustration.d.ts +85 -0
  171. package/dist/components/illustration.js +165 -0
  172. package/dist/components/input-group.d.ts +138 -0
  173. package/dist/components/input-group.js +312 -0
  174. package/dist/components/input.d.ts +16 -0
  175. package/dist/components/input.js +25 -0
  176. package/dist/components/item.d.ts +64 -0
  177. package/dist/components/item.js +116 -0
  178. package/dist/components/kbd.d.ts +50 -0
  179. package/dist/components/kbd.js +45 -0
  180. package/dist/components/label.d.ts +12 -0
  181. package/dist/components/label.js +24 -0
  182. package/dist/components/layout.d.ts +136 -0
  183. package/dist/components/layout.js +162 -0
  184. package/dist/components/lightbox.d.ts +100 -0
  185. package/dist/components/lightbox.js +439 -0
  186. package/dist/components/locale.d.ts +44 -0
  187. package/dist/components/locale.js +37 -0
  188. package/dist/components/logo.d.ts +54 -0
  189. package/dist/components/logo.js +96 -0
  190. package/dist/components/menu.d.ts +60 -0
  191. package/dist/components/menu.js +140 -0
  192. package/dist/components/menubar.d.ts +62 -0
  193. package/dist/components/menubar.js +223 -0
  194. package/dist/components/message.d.ts +42 -0
  195. package/dist/components/message.js +59 -0
  196. package/dist/components/meter.d.ts +31 -0
  197. package/dist/components/meter.js +27 -0
  198. package/dist/components/money-input.d.ts +80 -0
  199. package/dist/components/money-input.js +253 -0
  200. package/dist/components/native-select.d.ts +26 -0
  201. package/dist/components/native-select.js +35 -0
  202. package/dist/components/navigation-menu.d.ts +42 -0
  203. package/dist/components/navigation-menu.js +97 -0
  204. package/dist/components/number-field.d.ts +55 -0
  205. package/dist/components/number-field.js +164 -0
  206. package/dist/components/otp-field.d.ts +48 -0
  207. package/dist/components/otp-field.js +102 -0
  208. package/dist/components/pagination.d.ts +37 -0
  209. package/dist/components/pagination.js +81 -0
  210. package/dist/components/pdf-viewer.d.ts +134 -0
  211. package/dist/components/pdf-viewer.js +996 -0
  212. package/dist/components/phone-input.d.ts +79 -0
  213. package/dist/components/phone-input.js +282 -0
  214. package/dist/components/popover.d.ts +33 -0
  215. package/dist/components/popover.js +48 -0
  216. package/dist/components/preview-card.d.ts +25 -0
  217. package/dist/components/preview-card.js +22 -0
  218. package/dist/components/progress.d.ts +27 -0
  219. package/dist/components/progress.js +25 -0
  220. package/dist/components/prompt-input.d.ts +156 -0
  221. package/dist/components/prompt-input.js +415 -0
  222. package/dist/components/quote.d.ts +22 -0
  223. package/dist/components/quote.js +15 -0
  224. package/dist/components/radio-group.d.ts +18 -0
  225. package/dist/components/radio-group.js +34 -0
  226. package/dist/components/rating.d.ts +73 -0
  227. package/dist/components/rating.js +124 -0
  228. package/dist/components/reasoning.d.ts +46 -0
  229. package/dist/components/reasoning.js +73 -0
  230. package/dist/components/resizable.d.ts +47 -0
  231. package/dist/components/resizable.js +44 -0
  232. package/dist/components/response.d.ts +41 -0
  233. package/dist/components/response.js +566 -0
  234. package/dist/components/scroll-area.d.ts +33 -0
  235. package/dist/components/scroll-area.js +31 -0
  236. package/dist/components/select.d.ts +35 -0
  237. package/dist/components/select.js +71 -0
  238. package/dist/components/separator.d.ts +14 -0
  239. package/dist/components/separator.js +17 -0
  240. package/dist/components/sidebar.d.ts +163 -0
  241. package/dist/components/sidebar.js +505 -0
  242. package/dist/components/site-header.d.ts +93 -0
  243. package/dist/components/site-header.js +121 -0
  244. package/dist/components/skeleton.d.ts +31 -0
  245. package/dist/components/skeleton.js +29 -0
  246. package/dist/components/slider.d.ts +24 -0
  247. package/dist/components/slider.js +131 -0
  248. package/dist/components/sortable.d.ts +178 -0
  249. package/dist/components/sortable.js +1258 -0
  250. package/dist/components/sources.d.ts +40 -0
  251. package/dist/components/sources.js +42 -0
  252. package/dist/components/spinner.d.ts +48 -0
  253. package/dist/components/spinner.js +75 -0
  254. package/dist/components/stat.d.ts +91 -0
  255. package/dist/components/stat.js +141 -0
  256. package/dist/components/stepper.d.ts +71 -0
  257. package/dist/components/stepper.js +101 -0
  258. package/dist/components/suggestions.d.ts +20 -0
  259. package/dist/components/suggestions.js +18 -0
  260. package/dist/components/switch.d.ts +14 -0
  261. package/dist/components/switch.js +26 -0
  262. package/dist/components/table.d.ts +172 -0
  263. package/dist/components/table.js +895 -0
  264. package/dist/components/tabs.d.ts +25 -0
  265. package/dist/components/tabs.js +162 -0
  266. package/dist/components/tag.d.ts +41 -0
  267. package/dist/components/tag.js +88 -0
  268. package/dist/components/tags-input.d.ts +56 -0
  269. package/dist/components/tags-input.js +271 -0
  270. package/dist/components/textarea.d.ts +13 -0
  271. package/dist/components/textarea.js +16 -0
  272. package/dist/components/theme.d.ts +55 -0
  273. package/dist/components/theme.js +120 -0
  274. package/dist/components/time-field.d.ts +70 -0
  275. package/dist/components/time-field.js +450 -0
  276. package/dist/components/timeline.d.ts +92 -0
  277. package/dist/components/timeline.js +108 -0
  278. package/dist/components/tippy.d.ts +48 -0
  279. package/dist/components/tippy.js +648 -0
  280. package/dist/components/toast.d.ts +88 -0
  281. package/dist/components/toast.js +205 -0
  282. package/dist/components/toggle-group.d.ts +41 -0
  283. package/dist/components/toggle-group.js +140 -0
  284. package/dist/components/toggle.d.ts +23 -0
  285. package/dist/components/toggle.js +35 -0
  286. package/dist/components/tool-call.d.ts +63 -0
  287. package/dist/components/tool-call.js +68 -0
  288. package/dist/components/toolbar.d.ts +17 -0
  289. package/dist/components/toolbar.js +39 -0
  290. package/dist/components/tooltip.d.ts +42 -0
  291. package/dist/components/tooltip.js +47 -0
  292. package/dist/components/tour.d.ts +127 -0
  293. package/dist/components/tour.js +648 -0
  294. package/dist/components/tree.d.ts +75 -0
  295. package/dist/components/tree.js +649 -0
  296. package/dist/components/typography.d.ts +134 -0
  297. package/dist/components/typography.js +176 -0
  298. package/dist/components/video-player.d.ts +284 -0
  299. package/dist/components/video-player.js +1392 -0
  300. package/dist/illustration.d.ts +2 -0
  301. package/dist/illustration.js +7 -0
  302. package/dist/index.d.ts +93 -0
  303. package/dist/index.js +94 -0
  304. package/dist/lib/cn.d.ts +20 -0
  305. package/dist/lib/cn.js +38 -0
  306. package/dist/lib/code-highlight.d.ts +18 -0
  307. package/dist/lib/code-highlight.js +174 -0
  308. package/dist/lib/code-theme.d.ts +19 -0
  309. package/dist/lib/code-theme.js +140 -0
  310. package/dist/lib/collapse-row.d.ts +9 -0
  311. package/dist/lib/collapse-row.js +129 -0
  312. package/dist/lib/digit-roll.d.ts +21 -0
  313. package/dist/lib/digit-roll.js +31 -0
  314. package/dist/lib/editorial-assets.d.ts +16 -0
  315. package/dist/lib/editorial-assets.js +56 -0
  316. package/dist/lib/field-errors.d.ts +28 -0
  317. package/dist/lib/field-errors.js +24 -0
  318. package/dist/lib/field-value.d.ts +13 -0
  319. package/dist/lib/field-value.js +44 -0
  320. package/dist/lib/figure/catalog.d.ts +127 -0
  321. package/dist/lib/figure/catalog.js +130 -0
  322. package/dist/lib/figure/figures/automation.d.ts +7 -0
  323. package/dist/lib/figure/figures/automation.js +143 -0
  324. package/dist/lib/figure/figures/bar-chart.d.ts +7 -0
  325. package/dist/lib/figure/figures/bar-chart.js +99 -0
  326. package/dist/lib/figure/figures/brackets-classic.d.ts +11 -0
  327. package/dist/lib/figure/figures/brackets-classic.js +170 -0
  328. package/dist/lib/figure/figures/brackets.d.ts +8 -0
  329. package/dist/lib/figure/figures/brackets.js +84 -0
  330. package/dist/lib/figure/figures/city.d.ts +7 -0
  331. package/dist/lib/figure/figures/city.js +93 -0
  332. package/dist/lib/figure/figures/conveyor.d.ts +7 -0
  333. package/dist/lib/figure/figures/conveyor.js +97 -0
  334. package/dist/lib/figure/figures/database.d.ts +7 -0
  335. package/dist/lib/figure/figures/database.js +65 -0
  336. package/dist/lib/figure/figures/documents.d.ts +7 -0
  337. package/dist/lib/figure/figures/documents.js +83 -0
  338. package/dist/lib/figure/figures/inbox.d.ts +7 -0
  339. package/dist/lib/figure/figures/inbox.js +92 -0
  340. package/dist/lib/figure/figures/laptop.d.ts +7 -0
  341. package/dist/lib/figure/figures/laptop.js +67 -0
  342. package/dist/lib/figure/figures/monitor.d.ts +7 -0
  343. package/dist/lib/figure/figures/monitor.js +59 -0
  344. package/dist/lib/figure/figures/pipeline.d.ts +8 -0
  345. package/dist/lib/figure/figures/pipeline.js +117 -0
  346. package/dist/lib/figure/figures/platform.d.ts +7 -0
  347. package/dist/lib/figure/figures/platform.js +117 -0
  348. package/dist/lib/figure/figures/server.d.ts +7 -0
  349. package/dist/lib/figure/figures/server.js +115 -0
  350. package/dist/lib/figure/figures/spreadsheet.d.ts +7 -0
  351. package/dist/lib/figure/figures/spreadsheet.js +87 -0
  352. package/dist/lib/figure/figures/timeline.d.ts +7 -0
  353. package/dist/lib/figure/figures/timeline.js +65 -0
  354. package/dist/lib/figure/kernel.d.ts +152 -0
  355. package/dist/lib/figure/kernel.js +576 -0
  356. package/dist/lib/figure/parts.d.ts +42 -0
  357. package/dist/lib/figure/parts.js +126 -0
  358. package/dist/lib/form-reset.d.ts +11 -0
  359. package/dist/lib/form-reset.js +22 -0
  360. package/dist/lib/glide.d.ts +53 -0
  361. package/dist/lib/glide.js +138 -0
  362. package/dist/lib/graph-layout.d.ts +58 -0
  363. package/dist/lib/graph-layout.js +209 -0
  364. package/dist/lib/illustration-drawings.d.ts +89 -0
  365. package/dist/lib/illustration-drawings.js +539 -0
  366. package/dist/lib/illustration-info.d.ts +37 -0
  367. package/dist/lib/illustration-info.js +22 -0
  368. package/dist/lib/illustration-library.d.ts +87 -0
  369. package/dist/lib/illustration-library.js +352 -0
  370. package/dist/lib/logo-geometry.d.ts +29 -0
  371. package/dist/lib/logo-geometry.js +67 -0
  372. package/dist/lib/markdown-guard.d.ts +16 -0
  373. package/dist/lib/markdown-guard.js +123 -0
  374. package/dist/lib/merge-refs.d.ts +10 -0
  375. package/dist/lib/merge-refs.js +26 -0
  376. package/dist/lib/money.d.ts +73 -0
  377. package/dist/lib/money.js +343 -0
  378. package/dist/lib/motion.d.ts +6 -0
  379. package/dist/lib/motion.js +12 -0
  380. package/dist/lib/pdf-worker.d.ts +1 -0
  381. package/dist/lib/pdf-worker.js +6 -0
  382. package/dist/lib/pdf.d.ts +19 -0
  383. package/dist/lib/pdf.js +58 -0
  384. package/dist/lib/phone-countries.d.ts +1 -0
  385. package/dist/lib/phone-countries.js +281 -0
  386. package/dist/lib/phone.d.ts +90 -0
  387. package/dist/lib/phone.js +286 -0
  388. package/dist/lib/platform.d.ts +38 -0
  389. package/dist/lib/platform.js +75 -0
  390. package/dist/lib/room.d.ts +25 -0
  391. package/dist/lib/room.js +46 -0
  392. package/dist/lib/row-index.d.ts +15 -0
  393. package/dist/lib/row-index.js +136 -0
  394. package/dist/lib/table-fit.d.ts +143 -0
  395. package/dist/lib/table-fit.js +596 -0
  396. package/dist/lib/theme-script.d.ts +31 -0
  397. package/dist/lib/theme-script.js +49 -0
  398. package/dist/lib/tippy/pixels.d.ts +47 -0
  399. package/dist/lib/tippy/pixels.js +187 -0
  400. package/dist/lib/tippy/sprite.d.ts +86 -0
  401. package/dist/lib/tippy/sprite.js +753 -0
  402. package/dist/messages/de.d.ts +12 -0
  403. package/dist/messages/de.js +326 -0
  404. package/dist/styles/expressive.css +203 -0
  405. package/dist/styles/fonts.css +145 -0
  406. package/dist/styles/index.css +207 -0
  407. package/dist/styles/material.css +317 -0
  408. package/dist/styles/parts/ai.css +361 -0
  409. package/dist/styles/parts/brand.css +75 -0
  410. package/dist/styles/parts/controls.css +774 -0
  411. package/dist/styles/parts/data.css +222 -0
  412. package/dist/styles/parts/editorial.css +120 -0
  413. package/dist/styles/parts/feedback.css +340 -0
  414. package/dist/styles/parts/foundations.css +166 -0
  415. package/dist/styles/parts/graph.css +214 -0
  416. package/dist/styles/parts/inputs.css +261 -0
  417. package/dist/styles/parts/isometric.css +124 -0
  418. package/dist/styles/parts/navigation.css +424 -0
  419. package/dist/styles/parts/overlays.css +250 -0
  420. package/dist/styles/parts/pdf.css +154 -0
  421. package/dist/styles/parts/react-flow.css +519 -0
  422. package/dist/styles/tokens.css +299 -0
  423. package/dist/vite.d.ts +66 -0
  424. package/dist/vite.js +29 -0
  425. package/package.json +183 -5
@@ -0,0 +1,648 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { cn } from "../lib/cn.js";
5
+ import { frameSize, rasterise } from "../lib/tippy/pixels.js";
6
+ import { FPS, MOVE_LENGTH, poseTippy, STILL, TIPPY, TIPPY_MOVES, } from "../lib/tippy/sprite.js";
7
+ /** Every move Tippy plays, for a picker or a test. */
8
+ export const tippyMoves = TIPPY_MOVES;
9
+ /** The picture Tippy is drawn in, in sprite pixels: room either side for its arms, and over it for a jump. */
10
+ const FRAME = frameSize(TIPPY);
11
+ /** The row of the picture its feet stand on. */
12
+ const GROUND = FRAME.height - 2;
13
+ /* ── The pieces both players share ────────────────────────────────────────── */
14
+ const REDUCED = "(prefers-reduced-motion: reduce)";
15
+ function useReducedMotion() {
16
+ const [reduced, setReduced] = React.useState(false);
17
+ React.useEffect(() => {
18
+ const query = window.matchMedia(REDUCED);
19
+ const update = () => setReduced(query.matches);
20
+ update();
21
+ query.addEventListener("change", update);
22
+ return () => query.removeEventListener("change", update);
23
+ }, []);
24
+ return reduced;
25
+ }
26
+ /** The screen's device pixels to a CSS pixel, kept up to date as a window moves between screens. */
27
+ function useDevicePixelRatio() {
28
+ const [ratio, setRatio] = React.useState(1);
29
+ React.useEffect(() => {
30
+ let query = null;
31
+ const update = () => {
32
+ query?.removeEventListener("change", update);
33
+ const now = window.devicePixelRatio || 1;
34
+ setRatio(now);
35
+ query = window.matchMedia(`(resolution: ${now}dppx)`);
36
+ query.addEventListener("change", update);
37
+ };
38
+ update();
39
+ return () => query?.removeEventListener("change", update);
40
+ }, []);
41
+ return ratio;
42
+ }
43
+ /**
44
+ * CSS pixels to a sprite pixel: as near `scale` as a whole number of device pixels allows, so every
45
+ * sprite pixel is a crisp square on the screen, and never under one — Tippy is drawn at 64 pixels
46
+ * to be seen.
47
+ */
48
+ const snapScale = (scale, ratio) => Math.max(1, Math.round(Math.max(1, scale) * ratio)) / ratio;
49
+ /** The move it plays and since when, and what it was doing before, so the new move grows out of it. */
50
+ class Clock {
51
+ move;
52
+ start;
53
+ from = null;
54
+ constructor(move, now) {
55
+ this.move = move;
56
+ this.start = now;
57
+ }
58
+ /** Seconds into the move. */
59
+ at(now) {
60
+ return Math.max(0, (now - this.start) / 1000);
61
+ }
62
+ /** Change to `move` (or start it over); `t` says how far into the old move it was, if not by the clock. */
63
+ set(move, now, t = this.at(now)) {
64
+ let depth = 0;
65
+ for (let f = this.from; f; f = f.from)
66
+ depth++;
67
+ // What the old move came from still matters for a moment, a few moves back at most.
68
+ this.from = { move: this.move, t, from: t < 2.5 && depth < 3 ? this.from : null };
69
+ this.move = move;
70
+ this.start = now;
71
+ }
72
+ }
73
+ /** Put one frame of Tippy on its canvas. */
74
+ function paint(canvas, pose, shadow = true) {
75
+ const ctx = canvas.getContext("2d");
76
+ if (!ctx)
77
+ return;
78
+ ctx.putImageData(rasterise(TIPPY, pose, {
79
+ lift: pose.lift,
80
+ jitter: pose.jitter,
81
+ shadow,
82
+ }), 0, 0);
83
+ }
84
+ const pixelated = "select-none [image-rendering:pixelated]";
85
+ /**
86
+ * Tippy — zon.sh's mascot, the mark turned over and standing on its horns, as a 64-pixel sprite on
87
+ * a canvas: snapped to three inks with a one-pixel outline and drawn a whole number of device
88
+ * pixels to a sprite pixel, light on a light page and dark on a dark one. It plays a move — `wave`,
89
+ * `jump`, `think`, `success` and the rest — with weight, each new move growing out of the last;
90
+ * off screen it stops drawing, and under reduced motion it holds the move's clearest frame.
91
+ *
92
+ * The rule people break: Tippy as decoration on every screen. Bring it in where a person is being
93
+ * shown around or something has happened to them — a tour, an empty state, a finished task.
94
+ */
95
+ export function Tippy({ move = "idle", facing = "right", scale = 2, label, paused = false, className, style, ...props }) {
96
+ const canvasRef = React.useRef(null);
97
+ const reduced = useReducedMotion();
98
+ const ratio = useDevicePixelRatio();
99
+ const css = snapScale(scale, ratio);
100
+ const dir = facing === "left" ? -1 : 1;
101
+ const clock = React.useRef(null);
102
+ const [visible, setVisible] = React.useState(true);
103
+ // A new move starts from its beginning, out of what it was doing.
104
+ React.useLayoutEffect(() => {
105
+ const now = performance.now();
106
+ if (!clock.current)
107
+ clock.current = new Clock(move, now);
108
+ else if (clock.current.move !== move)
109
+ clock.current.set(move, now);
110
+ }, [move]);
111
+ // Drawn only while it is on screen.
112
+ React.useEffect(() => {
113
+ const canvas = canvasRef.current;
114
+ if (!canvas || typeof IntersectionObserver === "undefined")
115
+ return;
116
+ const observer = new IntersectionObserver(([entry]) => setVisible(entry?.isIntersecting ?? true));
117
+ observer.observe(canvas);
118
+ return () => observer.disconnect();
119
+ }, []);
120
+ React.useLayoutEffect(() => {
121
+ const canvas = canvasRef.current;
122
+ const c = clock.current;
123
+ if (!canvas || !c)
124
+ return;
125
+ if (reduced) {
126
+ paint(canvas, poseTippy(move, STILL[move], null, dir));
127
+ return;
128
+ }
129
+ let shown = "";
130
+ let frame = 0;
131
+ // Paused, it keeps the moment it was at.
132
+ const held = paused ? performance.now() : 0;
133
+ const tick = (now) => {
134
+ const t = c.at(held || now);
135
+ const key = `${c.move}:${Math.floor(t * FPS)}:${dir}`;
136
+ if (key !== shown) {
137
+ paint(canvas, poseTippy(c.move, t, c.from, dir));
138
+ shown = key;
139
+ }
140
+ if (!paused && visible)
141
+ frame = requestAnimationFrame(tick);
142
+ };
143
+ tick(held || performance.now());
144
+ return () => cancelAnimationFrame(frame);
145
+ }, [move, dir, reduced, paused, visible]);
146
+ return (_jsx("canvas", { ref: canvasRef, "data-slot": "tippy", "data-move": move, width: FRAME.width, height: FRAME.height, role: label ? "img" : undefined, "aria-label": label, "aria-hidden": label ? undefined : true, className: cn(pixelated, className), style: {
147
+ width: FRAME.width * css,
148
+ height: FRAME.height * css,
149
+ scale: dir < 0 ? "-1 1" : undefined,
150
+ ...style,
151
+ }, ...props }));
152
+ }
153
+ /*
154
+ * Its size, in sprite pixels from its feet, for standing it by a target: half the body's width,
155
+ * how far its hand reaches past the body when it points, how high its head is and its eyes.
156
+ */
157
+ const BODY = 26;
158
+ const REACH = 14;
159
+ const HEAD = 48;
160
+ const EYES = 40;
161
+ /** The room kept round everything: from the screen's edge, and round the target's spotlight. */
162
+ const MARGIN = 8;
163
+ const CLEAR = 8;
164
+ /** The bubble's tail and the room past it, as the Tour draws it, and the room the Tour keeps it from the screen's edge. */
165
+ const TAIL = 16;
166
+ const EDGE = 12;
167
+ /** The narrowest a bubble beside Tippy is worth making: under it, the words wrap too much. */
168
+ const NARROWEST = 220;
169
+ const rect = (left, top, width, height) => ({
170
+ left,
171
+ top,
172
+ right: left + width,
173
+ bottom: top + height,
174
+ });
175
+ /** How much of a lies over b, in square pixels. */
176
+ const overlap = (a, b) => Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left)) *
177
+ Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));
178
+ /** How much of a is off the screen, in square pixels. */
179
+ const offscreen = (a, vw, vh) => (a.right - a.left) * (a.bottom - a.top) -
180
+ overlap(a, rect(MARGIN, MARGIN, vw - 2 * MARGIN, vh - 2 * MARGIN));
181
+ /** Its feet, and the way it faces, for a stance by the target's box `t` (none: the middle of the screen). */
182
+ function feet(stance, t, s, bubbleHeight) {
183
+ const vw = window.innerWidth;
184
+ const vh = window.innerHeight;
185
+ if (!t || stance.at === "middle") {
186
+ // The bubble and Tippy under it, together in the middle; or the bubble beside it, at its eyes.
187
+ if (stance.bubble === "top")
188
+ return { x: vw / 2, y: vh / 2 + (bubbleHeight + TAIL + HEAD * s) / 2, facing: 1 };
189
+ return {
190
+ x: vw / 2,
191
+ y: vh / 2 + EYES * s,
192
+ facing: stance.bubble === "right" ? 1 : -1,
193
+ };
194
+ }
195
+ const by = (BODY + REACH) * s;
196
+ const across = Math.min(t.width / 2, 40 * s);
197
+ switch (stance.at) {
198
+ case "right":
199
+ return { x: t.right + CLEAR + by, y: t.bottom, facing: -1 };
200
+ case "left":
201
+ return { x: t.left - CLEAR - by, y: t.bottom, facing: 1 };
202
+ case "top":
203
+ return { x: t.left + across, y: t.top - CLEAR, facing: 1 };
204
+ default:
205
+ return { x: t.left + across, y: t.bottom + CLEAR + (HEAD + 4) * s, facing: 1 };
206
+ }
207
+ }
208
+ /** The box Tippy takes standing at (x, y), and the box its bubble takes said from there. */
209
+ function boxes(stance, x, y, s, w, h) {
210
+ const body = rect(x - (BODY + 2) * s, y - (HEAD + 2) * s, (BODY + 2) * 2 * s, (HEAD + 2) * s);
211
+ let bubble;
212
+ if (stance.bubble === "top") {
213
+ // Out from its head on the side away from the target, or across the middle of it.
214
+ const head = 14 * s;
215
+ const left = stance.at === "right" ? x - head : stance.at === "left" ? x + head - w : x - w / 2;
216
+ bubble = rect(left, y - HEAD * s - TAIL - h, w, h);
217
+ }
218
+ else {
219
+ // Beside it the bubble is as wide as the room there (the Tour lets it narrow), and taller for it.
220
+ const room = stance.bubble === "right"
221
+ ? window.innerWidth - EDGE - (x + BODY * s + TAIL)
222
+ : x - BODY * s - TAIL - EDGE;
223
+ const narrow = Math.max(NARROWEST, Math.min(w, room));
224
+ const tall = (h * w) / narrow;
225
+ const left = stance.bubble === "right" ? x + BODY * s + TAIL : x - BODY * s - TAIL - narrow;
226
+ bubble = rect(left, y - EYES * s - tall / 2, narrow, tall);
227
+ }
228
+ return { body, bubble };
229
+ }
230
+ /** What Tippy should not stand on: controls people use and words they read. */
231
+ const CONTENT = "a[href],button,input,select,textarea,summary,[role=button],[role=link],[role=checkbox],[role=radio],[role=switch],[role=tab],[role=slider],[role=progressbar],[role=meter],[tabindex]:not([tabindex='-1']),h1,h2,h3,h4,h5,h6,p,label,li,dt,dd,th,td,span,code,img,svg,video";
232
+ const INTERACTIVE = "a[href],button,input,select,textarea,summary,[role=button],[role=link],[role=checkbox],[role=radio],[role=switch],[role=tab],[role=slider],[role=progressbar],[role=meter],[tabindex]";
233
+ /** How many elements are looked at, at most: a page's first few thousand. */
234
+ const LOOKED_AT = 3000;
235
+ /**
236
+ * The boxes of what is on screen that Tippy should not stand on — controls, pictures, and the
237
+ * words themselves (their text's box, not their block's) — leaving out the target, what holds it,
238
+ * and the tour's own parts. Measured once a step, not every frame.
239
+ */
240
+ function contentOnScreen(target, skip) {
241
+ const vw = window.innerWidth;
242
+ const vh = window.innerHeight;
243
+ const found = [];
244
+ const all = document.querySelectorAll(CONTENT);
245
+ const range = document.createRange();
246
+ for (let i = 0; i < all.length && i < LOOKED_AT; i++) {
247
+ const el = all[i];
248
+ if (target && (el === target || el.contains(target) || target.contains(el)))
249
+ continue;
250
+ let r = el.getBoundingClientRect();
251
+ if (r.width < 1 || r.height < 1 || r.right < 0 || r.bottom < 0 || r.left > vw || r.top > vh)
252
+ continue;
253
+ if (skip(el))
254
+ continue;
255
+ if (!el.matches(INTERACTIVE) && !/^(img|svg|video)$/i.test(el.tagName)) {
256
+ // Words: only an element with text of its own, measured by the text.
257
+ let text = false;
258
+ for (const n of el.childNodes)
259
+ if (n.nodeType === 3 && n.textContent.trim())
260
+ text = true;
261
+ if (!text)
262
+ continue;
263
+ range.selectNodeContents(el);
264
+ r = range.getBoundingClientRect();
265
+ if (r.width < 1 || r.height < 1)
266
+ continue;
267
+ }
268
+ found.push({ left: r.left, top: r.top, right: r.right, bottom: r.bottom });
269
+ }
270
+ return found;
271
+ }
272
+ /**
273
+ * The stance for a step: Tippy beside the target, pointing at it, the bubble over its head — or
274
+ * beside it, away from the target — or on or under the target, a little further out, or out past
275
+ * the edge of what holds the target, in the page's empty space. Each is scored by what it covers:
276
+ * the target (never), the content on screen under Tippy (`avoid`), and Tippy or its bubble off
277
+ * screen; and a little for every pixel further out. The least covered wins. Without a target,
278
+ * both in the middle of the screen.
279
+ */
280
+ function stanceFor(target, s, w, h, rtl, avoid) {
281
+ const vw = window.innerWidth;
282
+ const t = target?.getBoundingClientRect() ?? null;
283
+ const tries = [];
284
+ if (!t) {
285
+ // No target: in the middle, the bubble over Tippy or beside it, moved off what is there.
286
+ const side = (BODY * 2 * s + TAIL + w) / 2 - BODY * s;
287
+ for (const dx of [0, -160, 160, -320, 320])
288
+ for (const dy of [0, 80, -80, 160])
289
+ tries.push({ at: "middle", bubble: "top", dx, dy });
290
+ for (const dy of [0, 80, -80, 160])
291
+ tries.push({ at: "middle", bubble: "right", dx: -side, dy }, { at: "middle", bubble: "left", dx: side, dy });
292
+ return cheapest(tries, null, s, w, h, avoid);
293
+ }
294
+ const roomRight = vw - t.right;
295
+ const roomLeft = t.left;
296
+ const sides = roomRight > roomLeft + 24 || (Math.abs(roomRight - roomLeft) <= 24 && !rtl)
297
+ ? ["right", "left"]
298
+ : ["left", "right"];
299
+ // Out past the edges of what holds the target: just outside each box round it that is wider.
300
+ const outside = {
301
+ left: [],
302
+ right: [],
303
+ top: [],
304
+ bottom: [],
305
+ };
306
+ for (let el = target.parentElement, depth = 0; el && el !== document.body && depth < 8; el = el.parentElement, depth++) {
307
+ const r = el.getBoundingClientRect();
308
+ if (r.right - t.right > 24)
309
+ outside.right.push(r.right - t.right + 4);
310
+ if (t.left - r.left > 24)
311
+ outside.left.push(-(t.left - r.left + 4));
312
+ if (r.bottom - t.bottom > 24)
313
+ outside.bottom.push(r.bottom - t.bottom + 4);
314
+ if (t.top - r.top > 24)
315
+ outside.top.push(-(t.top - r.top + 4));
316
+ }
317
+ const tall = HEAD * s;
318
+ for (const at of sides) {
319
+ const away = at === "right" ? 1 : -1;
320
+ const across = [0, 32, 80, 160].map((d) => d * away).concat(outside[at]);
321
+ // Level with the target's foot, higher or lower; or level with its top, for a tall one.
322
+ const levels = [0, -48, 48, -112, 112, 176];
323
+ if (t.height > tall)
324
+ levels.push(-(t.height - tall), -(t.height - tall) / 2);
325
+ for (const dx of new Set(across))
326
+ for (const dy of levels)
327
+ tries.push({ at, bubble: "top", dx, dy }, { at, bubble: at === "right" ? "right" : "left", dx, dy });
328
+ }
329
+ for (const at of ["top", "bottom"]) {
330
+ const out = at === "bottom" ? 1 : -1;
331
+ const across = Math.min(t.width / 2, 40 * s);
332
+ // Along the target, and just past either end of it.
333
+ const along = [
334
+ 0,
335
+ t.width / 2 - across,
336
+ t.width - 2 * across,
337
+ -across - (BODY + 4) * s,
338
+ t.width - across + (BODY + 4) * s,
339
+ ];
340
+ const levels = [0, 40 * out, 96 * out].concat(outside[at]);
341
+ for (const dx of new Set(along))
342
+ for (const dy of new Set(levels))
343
+ for (const bubble of at === "top" ? ["top", ...sides] : sides)
344
+ tries.push({ at, bubble, dx, dy });
345
+ }
346
+ return cheapest(tries, t, s, w, h, avoid);
347
+ }
348
+ /** The least covered of the stands tried: the first that covers nothing, else the cheapest. */
349
+ function cheapest(tries, t, s, w, h, avoid) {
350
+ const vw = window.innerWidth;
351
+ const vh = window.innerHeight;
352
+ // The target and the room round it the spotlight takes; none for a step in the middle.
353
+ const lit = t
354
+ ? rect(t.left - CLEAR, t.top - CLEAR, t.width + 2 * CLEAR, t.height + 2 * CLEAR)
355
+ : rect(-1e5, -1e5, 0, 0);
356
+ let best = null;
357
+ for (const stance of tries) {
358
+ const f = feet(stance, t, s, h);
359
+ // Kept on screen, arms and all: Tippy moved in from the edge, if it must be.
360
+ const half = (BODY + 8) * s;
361
+ const x = Math.min(vw - MARGIN - half, Math.max(MARGIN + half, f.x + stance.dx));
362
+ const y = Math.min(vh - MARGIN, Math.max(MARGIN + (HEAD + 2) * s, f.y + stance.dy));
363
+ let placed = { ...stance, dx: x - f.x, dy: y - f.y };
364
+ let { body, bubble } = boxes(placed, x, y, s, w, h);
365
+ // Over or under the target, it stands far enough off it for the bubble beside it to clear it too.
366
+ const push = stance.at === "bottom"
367
+ ? Math.max(0, lit.bottom - Math.min(body.top, bubble.top))
368
+ : stance.at === "top"
369
+ ? -Math.max(0, Math.max(body.bottom, bubble.bottom) - lit.top)
370
+ : 0;
371
+ if (push) {
372
+ placed = { ...placed, dy: placed.dy + push };
373
+ ({ body, bubble } = boxes(placed, x, y + push, s, w, h));
374
+ }
375
+ // The bubble is shifted along to stay on screen (as the Tour does), but not off its tail.
376
+ const shift = stance.bubble === "top" ? Math.max(MARGIN - bubble.left, Math.min(0, vw - MARGIN - bubble.right)) : 0;
377
+ const said = { ...bubble, left: bubble.left + shift, right: bubble.right + shift };
378
+ // Its arms hang a little past its body.
379
+ const reach = { ...body, left: body.left - 4 * s, right: body.right + 4 * s };
380
+ let covered = 0;
381
+ for (const a of avoid)
382
+ covered += overlap(reach, a);
383
+ const cost = overlap(body, lit) * 6 +
384
+ overlap(said, lit) * 3 +
385
+ overlap(said, body) * 3 +
386
+ offscreen(body, vw, vh) * 4 +
387
+ offscreen(said, vw, vh) * 2 +
388
+ covered * 3 +
389
+ // Nearer is better, all else alike: a few pixels further out for every one less covered.
390
+ (Math.abs(placed.dx) + Math.abs(placed.dy)) * 12;
391
+ if (cost < 1)
392
+ return placed;
393
+ if (!best || cost < best.cost)
394
+ best = { stance: placed, cost };
395
+ }
396
+ return best.stance;
397
+ }
398
+ /** Where Tippy stands for its stance now, the target where it is now. */
399
+ function spotOf(stance, target, s, bubbleHeight) {
400
+ const t = target?.isConnected ? target.getBoundingClientRect() : null;
401
+ const f = feet(stance, t, s, bubbleHeight);
402
+ const x = f.x + stance.dx;
403
+ // Over or under the target, it faces along to the target's middle.
404
+ const facing = t && (stance.at === "top" || stance.at === "bottom") ? (x <= t.left + t.width / 2 ? 1 : -1) : f.facing;
405
+ return { x, y: f.y + stance.dy, facing: facing };
406
+ }
407
+ /** The box the bubble's tail points at: over its head, or at its eyes from the side. */
408
+ function headOf(stance, x, y, s) {
409
+ return stance.bubble === "top"
410
+ ? new DOMRect(x - 14 * s, y - HEAD * s, 28 * s, 20 * s)
411
+ : new DOMRect(x - BODY * s, y - (EYES + 6) * s, BODY * 2 * s, 12 * s);
412
+ }
413
+ /** How long Tippy plays out the end before it goes: a happy hop with a check, or a wave goodbye. */
414
+ const EXIT = { complete: 2.3, skip: 1.4, closed: 0 };
415
+ /** How long it talks as the bubble comes out, and how fast its mouth goes. */
416
+ const TALK = 0.9;
417
+ const SYLLABLE = 0.13;
418
+ /**
419
+ * Tippy, saying something and pointing: the pose of its move, with its mouth going while it talks
420
+ * and the arm on the target's side raised towards it. On top of the drawing, so a new drawing of
421
+ * Tippy keeps it.
422
+ */
423
+ function gesture(pose, talk, point, at) {
424
+ const body = pose.body;
425
+ if (talk >= 0 && talk < TALK && !body.mouth) {
426
+ const syllable = Math.floor(talk / SYLLABLE);
427
+ body.mouth = syllable % 2 === 0 ? "o" : syllable % 4 === 1 ? "smile" : null;
428
+ }
429
+ if (point > 0 && body.armR && !body.armR.to) {
430
+ const ang = body.armR.ang + (at - body.armR.ang) * point;
431
+ body.armR = { ang, len: (body.armR.len ?? 6) + point };
432
+ }
433
+ return pose;
434
+ }
435
+ /**
436
+ * TippyGuide — Tippy, walking a Tour through with the person and saying each step:
437
+ * `<Tour guide={(g) => <TippyGuide {...g} />} />`. It stands beside the step's target, on the side
438
+ * with room, faces it and points at it, and the step is its speech bubble — the Tour's popover with
439
+ * a tail to its head. When the step changes the bubble goes back into its tail, Tippy gathers
440
+ * itself, leaps to the next target in an arc and lands with a bump, and the next bubble comes out
441
+ * as it lands, its mouth going. It waves on the first step; Done ends with a happy hop and a check,
442
+ * Skip with a wave goodbye. It is decoration: hidden from assistive technology, taking no clicks;
443
+ * the bubble is still the Tour's dialog. Under reduced motion it goes to the next target at once
444
+ * and holds still, and the bubble just appears.
445
+ */
446
+ export function TippyGuide({ scale = 2, ...state }) {
447
+ const canvasRef = React.useRef(null);
448
+ const reduced = useReducedMotion();
449
+ const ratio = useDevicePixelRatio();
450
+ const css = snapScale(scale, ratio);
451
+ const latest = React.useRef({ state, css, ratio, reduced });
452
+ latest.current = { state, css, ratio, reduced };
453
+ React.useEffect(() => {
454
+ const canvas = canvasRef.current;
455
+ if (!canvas)
456
+ return;
457
+ const clock = new Clock("wave", performance.now());
458
+ let x = NaN;
459
+ let y = NaN;
460
+ let facing = 1;
461
+ let mode = "away";
462
+ /** The step it stands for, how, and the bubble's height it was worked out with. */
463
+ let placed = -1;
464
+ let stance = null;
465
+ let bubbleHeight = 0;
466
+ let leap = { sx: 0, sy: 0, arc: 0, start: 0 };
467
+ let saidAt = -Infinity;
468
+ let exitAt = 0;
469
+ let fading = null;
470
+ let shown = "";
471
+ let frame = 0;
472
+ const show = () => {
473
+ canvas.style.visibility = "visible";
474
+ const ms = latest.current.reduced ? 0 : 150;
475
+ if (ms)
476
+ canvas.animate([{ opacity: 0 }, { opacity: 1 }], { duration: ms, easing: "ease-out" });
477
+ };
478
+ /** Give the Tour the bubble for this step, pointing at where Tippy's head is (or will be). */
479
+ let said = null;
480
+ const say = (step, target, ready) => {
481
+ const how = stance;
482
+ const { css: s } = latest.current;
483
+ // One anchor for each step: where its head is, read live; the same one when it is ready.
484
+ if (said?.step !== step)
485
+ said = {
486
+ step,
487
+ anchor: {
488
+ getBoundingClientRect: () => {
489
+ const spot = spotOf(how, target, s, bubbleHeight);
490
+ return headOf(how, spot.x, spot.y, s);
491
+ },
492
+ contextElement: target ?? undefined,
493
+ },
494
+ };
495
+ const { anchor } = said;
496
+ const rtl = latest.current.state.popover
497
+ ? getComputedStyle(latest.current.state.popover).direction === "rtl"
498
+ : false;
499
+ // Over its head the bubble runs away from the target: from its left edge when the target is
500
+ // to the left, which is the start of a line left to right and its end right to left.
501
+ const fromLeft = how.at === "right";
502
+ const fromRight = how.at === "left";
503
+ const placement = {
504
+ step,
505
+ anchor,
506
+ side: how.bubble,
507
+ align: how.bubble !== "top"
508
+ ? "center"
509
+ : fromLeft
510
+ ? rtl
511
+ ? "end"
512
+ : "start"
513
+ : fromRight
514
+ ? rtl
515
+ ? "start"
516
+ : "end"
517
+ : "center",
518
+ ready,
519
+ };
520
+ latest.current.state.place(placement);
521
+ if (ready)
522
+ saidAt = performance.now();
523
+ };
524
+ const tick = (now) => {
525
+ const { state: g, css: s, ratio, reduced } = latest.current;
526
+ const t = clock.at(now);
527
+ if (g.status !== "open" && mode !== "exit") {
528
+ // The tour is over: a last reaction where it stands, then it goes.
529
+ const length = mode === "away" || reduced ? 0 : EXIT[g.status];
530
+ mode = "exit";
531
+ exitAt = now + length * 1000;
532
+ if (length)
533
+ clock.set(g.status === "complete" ? "success" : "wave", now);
534
+ }
535
+ // A new step to say, once the Tour has got there (the last bubble gone, the page scrolled).
536
+ const pop = g.popover;
537
+ if (mode !== "exit" && g.step !== placed && !g.moving && pop?.isConnected && pop.offsetWidth > 0) {
538
+ const target = g.target?.isConnected ? g.target : null;
539
+ const rtl = getComputedStyle(pop).direction === "rtl";
540
+ bubbleHeight = pop.offsetHeight;
541
+ // What is on screen to keep off: measured now, once for the step.
542
+ const avoid = contentOnScreen(target, (el) => pop.contains(el) || canvas.contains(el) || !!el.closest("[data-slot=tour-guide]"));
543
+ stance = stanceFor(target, s, pop.offsetWidth, bubbleHeight, rtl, avoid);
544
+ placed = g.step;
545
+ const home = spotOf(stance, target, s, bubbleHeight);
546
+ const distance = Number.isNaN(x) ? 0 : Math.hypot(home.x - x, home.y - y);
547
+ if (mode === "away" || reduced || distance < 6) {
548
+ // On the first step it is there at once, waving; under reduced motion at every step.
549
+ if (mode === "away")
550
+ show();
551
+ ({ x, y, facing } = home);
552
+ mode = "here";
553
+ say(g.step, target, true);
554
+ }
555
+ else {
556
+ // Off from where it is (on screen, if the page has scrolled it off), in an arc for the distance.
557
+ const vw = window.innerWidth;
558
+ const vh = window.innerHeight;
559
+ x = Math.min(vw - BODY * s, Math.max(BODY * s, x));
560
+ y = Math.min(vh, Math.max(HEAD * s, y));
561
+ // Already in the air (the step changed again), it goes on without gathering itself again.
562
+ const start = mode === "leap" ? now - 200 : now;
563
+ leap = { sx: x, sy: y, arc: Math.min(140, 16 + distance * 0.22), start };
564
+ if (Math.abs(home.x - x) > 4)
565
+ facing = home.x > x ? 1 : -1;
566
+ if (mode !== "leap")
567
+ clock.set("jump", now);
568
+ mode = "leap";
569
+ say(g.step, target, false);
570
+ }
571
+ }
572
+ const target = g.target?.isConnected ? g.target : null;
573
+ const home = stance ? spotOf(stance, target, s, bubbleHeight) : null;
574
+ if (mode === "exit") {
575
+ if (now >= exitAt && !fading) {
576
+ fading = canvas.animate([{ opacity: 1 }, { opacity: 0 }], {
577
+ duration: reduced || Number.isNaN(x) ? 0 : 150,
578
+ fill: "forwards",
579
+ });
580
+ fading.onfinish = () => latest.current.state.release();
581
+ }
582
+ }
583
+ else if (mode === "here" && home) {
584
+ // Standing by the target, it goes where the target goes: the page scrolling, resizing. Just
585
+ // landed, it turns round to the target a moment later.
586
+ ({ x, y } = home);
587
+ if (clock.move !== "jump" || t > 0.95)
588
+ facing = home.facing;
589
+ if (clock.move === "wave" && t > MOVE_LENGTH.wave - 0.3)
590
+ clock.set("idle", now);
591
+ if (clock.move === "jump" && t > 1.3)
592
+ clock.set("idle", now);
593
+ }
594
+ else if (mode === "leap" && home) {
595
+ // A jump's own timing: gathered for 0.2s, in the air until 0.66s, then the landing. The
596
+ // body goes across on the way up and down, in a line, plus an arc for the distance; and as
597
+ // it lands, it says the step.
598
+ const u = (now - leap.start) / 1000;
599
+ const f = Math.max(0, Math.min(1, (u - 0.2) / 0.46));
600
+ x = leap.sx + (home.x - leap.sx) * f;
601
+ y = leap.sy + (home.y - leap.sy) * f - leap.arc * 4 * f * (1 - f);
602
+ if (f >= 1) {
603
+ mode = "here";
604
+ say(placed, target, true);
605
+ }
606
+ }
607
+ if (!Number.isNaN(x)) {
608
+ const fx = Math.round((x - (FRAME.width / 2) * s) * ratio) / ratio;
609
+ const fy = Math.round((y - GROUND * s) * ratio) / ratio;
610
+ canvas.style.transform = `translate(${fx}px, ${fy}px) scale(${facing}, 1)`;
611
+ }
612
+ const move = clock.move;
613
+ const at = reduced ? STILL[move] : clock.at(now);
614
+ // Its shadow stays on the ground it left: none in the air.
615
+ const grounded = mode !== "leap" || now - leap.start < 200;
616
+ // Talking as the bubble comes out; pointing at the target once it has stopped to say it.
617
+ const talk = reduced || mode === "exit" ? -1 : (now - saidAt) / 1000;
618
+ let point = 0;
619
+ let aim = 1.6;
620
+ if (mode === "here" && target && stance && stance.at !== "middle" && move !== "wave" && !reduced) {
621
+ point = Math.min(1, Math.max(0, (talk - 0.25) / 0.3));
622
+ if (move === "jump")
623
+ point *= Math.max(0, Math.min(1, (t - 0.9) / 0.3));
624
+ // At the target's middle from its shoulder, as an angle out from straight down.
625
+ const r = target.getBoundingClientRect();
626
+ const dx = Math.abs(r.left + r.width / 2 - x);
627
+ const dy = r.top + r.height / 2 - (y - 24 * s);
628
+ aim = Math.min(2.5, Math.max(0.9, Math.atan2(dx, dy)));
629
+ }
630
+ else if (mode === "here" && target && stance && stance.at !== "middle" && reduced) {
631
+ point = 1;
632
+ }
633
+ const key = `${move}:${Math.floor(at * FPS)}:${facing}:${grounded}:${Math.round(point * 8)}:${Math.floor(talk / SYLLABLE)}`;
634
+ if (key !== shown && !Number.isNaN(x)) {
635
+ const pose = gesture(poseTippy(move, at, reduced ? null : clock.from, facing), talk, point, aim);
636
+ paint(canvas, pose, grounded);
637
+ shown = key;
638
+ }
639
+ frame = requestAnimationFrame(tick);
640
+ };
641
+ frame = requestAnimationFrame(tick);
642
+ return () => {
643
+ cancelAnimationFrame(frame);
644
+ fading?.cancel();
645
+ };
646
+ }, []);
647
+ return (_jsx("canvas", { ref: canvasRef, "data-slot": "tippy-guide", width: FRAME.width, height: FRAME.height, "aria-hidden": true, className: cn(pixelated, "invisible absolute top-0 left-0 origin-center"), style: { width: FRAME.width * css, height: FRAME.height * css } }));
648
+ }