@eifi1/ui-kit 0.51.6 → 0.52.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 (805) hide show
  1. package/README.md +146 -26
  2. package/dist/account/account-parts.d.ts +10 -8
  3. package/dist/account/account-parts.js +1 -18
  4. package/dist/account/account-parts.js.map +1 -1
  5. package/dist/account/data-export-setting-labels.js +1 -1
  6. package/dist/account/data-export-setting-labels.js.map +1 -1
  7. package/dist/account/delete-account-setting-labels.js +1 -1
  8. package/dist/account/delete-account-setting-labels.js.map +1 -1
  9. package/dist/account/email-change-setting-labels.js +1 -1
  10. package/dist/account/email-change-setting-labels.js.map +1 -1
  11. package/dist/account/passkeys-setting.d.ts +9 -2
  12. package/dist/account/passkeys-setting.js +41 -29
  13. package/dist/account/passkeys-setting.js.map +1 -1
  14. package/dist/account/sessions-setting.d.ts +3 -2
  15. package/dist/account/sessions-setting.js +10 -8
  16. package/dist/account/sessions-setting.js.map +1 -1
  17. package/dist/admin/admin-action-confirm.js +3 -7
  18. package/dist/admin/admin-action-confirm.js.map +1 -1
  19. package/dist/admin/admin-parts.d.ts +6 -3
  20. package/dist/admin/admin-parts.js +6 -21
  21. package/dist/admin/admin-parts.js.map +1 -1
  22. package/dist/admin/mail-test-card-labels.js +1 -1
  23. package/dist/admin/mail-test-card-labels.js.map +1 -1
  24. package/dist/admin/plan-change-labels.d.ts +2 -2
  25. package/dist/admin/plan-change-labels.js +1 -17
  26. package/dist/admin/plan-change-labels.js.map +1 -1
  27. package/dist/admin/plan-change.d.ts +3 -42
  28. package/dist/admin/plan-change.js +1 -1
  29. package/dist/admin/plan-change.js.map +1 -1
  30. package/dist/admin/reviewer-scope-editor.js +3 -3
  31. package/dist/admin/reviewer-scope-editor.js.map +1 -1
  32. package/dist/auth/auth-errors-labels.d.ts +11 -0
  33. package/dist/auth/auth-errors-labels.js +13 -0
  34. package/dist/auth/auth-errors-labels.js.map +1 -0
  35. package/dist/auth/auth-errors.d.ts +7 -23
  36. package/dist/auth/auth-errors.js +2 -15
  37. package/dist/auth/auth-errors.js.map +1 -1
  38. package/dist/auth/complete-name-dialog.d.ts +3 -2
  39. package/dist/auth/complete-name-dialog.js +3 -5
  40. package/dist/auth/complete-name-dialog.js.map +1 -1
  41. package/dist/auth/forgot-password-form-labels.js +1 -1
  42. package/dist/auth/forgot-password-form-labels.js.map +1 -1
  43. package/dist/auth/forgot-password-form.js +7 -2
  44. package/dist/auth/forgot-password-form.js.map +1 -1
  45. package/dist/auth/register-form-labels.js +1 -1
  46. package/dist/auth/register-form-labels.js.map +1 -1
  47. package/dist/auth/reset-password-form-labels.js +1 -1
  48. package/dist/auth/reset-password-form-labels.js.map +1 -1
  49. package/dist/auth/reset-password-form.js +5 -1
  50. package/dist/auth/reset-password-form.js.map +1 -1
  51. package/dist/auth/sign-in-form-labels.js +1 -1
  52. package/dist/auth/sign-in-form-labels.js.map +1 -1
  53. package/dist/auth/status-parts.d.ts +0 -3
  54. package/dist/auth/status-parts.js +0 -4
  55. package/dist/auth/status-parts.js.map +1 -1
  56. package/dist/auth/verify-email-labels.js +1 -1
  57. package/dist/auth/verify-email-labels.js.map +1 -1
  58. package/dist/auth/verify-email.js +7 -2
  59. package/dist/auth/verify-email.js.map +1 -1
  60. package/dist/billing/cancel-request.d.ts +11 -2
  61. package/dist/billing/cancel-request.js +15 -3
  62. package/dist/billing/cancel-request.js.map +1 -1
  63. package/dist/billing/cancel-subscription.d.ts +22 -10
  64. package/dist/billing/cancel-subscription.js +8 -11
  65. package/dist/billing/cancel-subscription.js.map +1 -1
  66. package/dist/billing/dialog-close.d.ts +29 -0
  67. package/dist/billing/dialog-close.js +8 -0
  68. package/dist/billing/dialog-close.js.map +1 -0
  69. package/dist/billing/plan-card.d.ts +14 -4
  70. package/dist/billing/plan-card.js +15 -8
  71. package/dist/billing/plan-card.js.map +1 -1
  72. package/dist/billing/plan-change-labels.d.ts +42 -0
  73. package/dist/billing/plan-change-labels.js +22 -0
  74. package/dist/billing/plan-change-labels.js.map +1 -0
  75. package/dist/billing/plan-switch.d.ts +21 -9
  76. package/dist/billing/plan-switch.js +10 -8
  77. package/dist/billing/plan-switch.js.map +1 -1
  78. package/dist/chart.d.ts +12 -0
  79. package/dist/chart.js +16 -1
  80. package/dist/chart.js.map +1 -1
  81. package/dist/components/account-chips.d.ts +5 -5
  82. package/dist/components/account-chips.js +11 -13
  83. package/dist/components/account-chips.js.map +1 -1
  84. package/dist/components/alert-banner.d.ts +16 -5
  85. package/dist/components/alert-banner.js +46 -1
  86. package/dist/components/alert-banner.js.map +1 -1
  87. package/dist/components/amount-input.d.ts +22 -4
  88. package/dist/components/amount-input.js +3 -3
  89. package/dist/components/amount-input.js.map +1 -1
  90. package/dist/components/autocomplete.js +57 -65
  91. package/dist/components/autocomplete.js.map +1 -1
  92. package/dist/components/bulk-action-bar.d.ts +12 -2
  93. package/dist/components/bulk-action-bar.js +65 -21
  94. package/dist/components/bulk-action-bar.js.map +1 -1
  95. package/dist/components/button-look.d.ts +5 -5
  96. package/dist/components/button-look.js.map +1 -1
  97. package/dist/components/button.d.ts +2 -2
  98. package/dist/components/button.js.map +1 -1
  99. package/dist/components/calculator.d.ts +21 -2
  100. package/dist/components/calculator.js +53 -14
  101. package/dist/components/calculator.js.map +1 -1
  102. package/dist/components/chart-edge.d.ts +16 -0
  103. package/dist/components/chart-edge.js +14 -1
  104. package/dist/components/chart-edge.js.map +1 -1
  105. package/dist/components/chart-figure.d.ts +13 -0
  106. package/dist/components/chart-figure.js +15 -0
  107. package/dist/components/chart-figure.js.map +1 -0
  108. package/dist/components/chart-zoom-core.js +1 -4
  109. package/dist/components/chart-zoom-core.js.map +1 -1
  110. package/dist/components/chart.d.ts +8 -1
  111. package/dist/components/chart.js +19 -10
  112. package/dist/components/chart.js.map +1 -1
  113. package/dist/components/combobox-core.d.ts +119 -7
  114. package/dist/components/combobox-core.js +151 -46
  115. package/dist/components/combobox-core.js.map +1 -1
  116. package/dist/components/combobox.d.ts +1 -1
  117. package/dist/components/combobox.js +142 -131
  118. package/dist/components/combobox.js.map +1 -1
  119. package/dist/components/copy-button.d.ts +6 -5
  120. package/dist/components/copy-button.js +5 -3
  121. package/dist/components/copy-button.js.map +1 -1
  122. package/dist/components/country-select.js +2 -2
  123. package/dist/components/country-select.js.map +1 -1
  124. package/dist/components/data-table-column-settings.d.ts +1 -1
  125. package/dist/components/data-table-column-settings.js +33 -7
  126. package/dist/components/data-table-column-settings.js.map +1 -1
  127. package/dist/components/data-table-filters.d.ts +4 -2
  128. package/dist/components/data-table-filters.js +2 -2
  129. package/dist/components/data-table-filters.js.map +1 -1
  130. package/dist/components/data-table-fit.d.ts +6 -4
  131. package/dist/components/data-table-fit.js +4 -1
  132. package/dist/components/data-table-fit.js.map +1 -1
  133. package/dist/components/data-table-groups.d.ts +1 -1
  134. package/dist/components/data-table-groups.js.map +1 -1
  135. package/dist/components/data-table-head.d.ts +1 -1
  136. package/dist/components/data-table-head.js +15 -12
  137. package/dist/components/data-table-head.js.map +1 -1
  138. package/dist/components/data-table-mobile.d.ts +36 -7
  139. package/dist/components/data-table-mobile.js +63 -31
  140. package/dist/components/data-table-mobile.js.map +1 -1
  141. package/dist/components/data-table-pagination.js +11 -6
  142. package/dist/components/data-table-pagination.js.map +1 -1
  143. package/dist/components/data-table-resize.d.ts +1 -1
  144. package/dist/components/data-table-resize.js.map +1 -1
  145. package/dist/components/data-table-row-actions.d.ts +2 -2
  146. package/dist/components/data-table-row-actions.js.map +1 -1
  147. package/dist/components/data-table-row.d.ts +6 -2
  148. package/dist/components/data-table-row.js +17 -10
  149. package/dist/components/data-table-row.js.map +1 -1
  150. package/dist/components/data-table-selection.d.ts +1 -1
  151. package/dist/components/data-table-selection.js.map +1 -1
  152. package/dist/components/data-table-shared.d.ts +10 -2
  153. package/dist/components/data-table-shared.js +18 -0
  154. package/dist/components/data-table-shared.js.map +1 -1
  155. package/dist/components/data-table-sort.d.ts +21 -2
  156. package/dist/components/data-table-sort.js +24 -0
  157. package/dist/components/data-table-sort.js.map +1 -1
  158. package/dist/components/data-table-virtual.d.ts +1 -1
  159. package/dist/components/data-table-virtual.js +18 -6
  160. package/dist/components/data-table-virtual.js.map +1 -1
  161. package/dist/components/data-table.d.ts +25 -8
  162. package/dist/components/data-table.js +154 -25
  163. package/dist/components/data-table.js.map +1 -1
  164. package/dist/components/date-field.d.ts +24 -2
  165. package/dist/components/date-field.js +33 -8
  166. package/dist/components/date-field.js.map +1 -1
  167. package/dist/components/date-picker.d.ts +15 -2
  168. package/dist/components/date-picker.js +55 -26
  169. package/dist/components/date-picker.js.map +1 -1
  170. package/dist/components/date-range-picker.d.ts +47 -20
  171. package/dist/components/date-range-picker.js +23 -7
  172. package/dist/components/date-range-picker.js.map +1 -1
  173. package/dist/components/dialog-frame.d.ts +2 -1
  174. package/dist/components/dialog-frame.js.map +1 -1
  175. package/dist/components/entity-combobox.js +4 -2
  176. package/dist/components/entity-combobox.js.map +1 -1
  177. package/dist/components/error-boundary.js +37 -30
  178. package/dist/components/error-boundary.js.map +1 -1
  179. package/dist/components/{ui-labels.d.ts → field-base-labels.d.ts} +0 -2
  180. package/dist/components/{ui-labels.js → field-base-labels.js} +2 -9
  181. package/dist/components/field-base-labels.js.map +1 -0
  182. package/dist/components/field-base.d.ts +4 -3
  183. package/dist/components/field-base.js +3 -3
  184. package/dist/components/field-base.js.map +1 -1
  185. package/dist/components/field-sync-labels.d.ts +1 -0
  186. package/dist/components/field-sync-labels.js.map +1 -1
  187. package/dist/components/field-sync.d.ts +23 -1
  188. package/dist/components/field-sync.js.map +1 -1
  189. package/dist/components/form-actions.js +11 -5
  190. package/dist/components/form-actions.js.map +1 -1
  191. package/dist/components/hover-menu.d.ts +3 -0
  192. package/dist/components/hover-menu.js +5 -3
  193. package/dist/components/hover-menu.js.map +1 -1
  194. package/dist/components/icon-button.js +14 -9
  195. package/dist/components/icon-button.js.map +1 -1
  196. package/dist/components/inline-confirm.d.ts +43 -0
  197. package/dist/components/inline-confirm.js +67 -0
  198. package/dist/components/inline-confirm.js.map +1 -0
  199. package/dist/components/inline-entity-combobox.d.ts +4 -3
  200. package/dist/components/inline-entity-combobox.js +150 -141
  201. package/dist/components/inline-entity-combobox.js.map +1 -1
  202. package/dist/components/input.js +1 -1
  203. package/dist/components/input.js.map +1 -1
  204. package/dist/components/jump-calendar.js +28 -112
  205. package/dist/components/jump-calendar.js.map +1 -1
  206. package/dist/components/legal-page.d.ts +3 -1
  207. package/dist/components/legal-page.js +3 -2
  208. package/dist/components/legal-page.js.map +1 -1
  209. package/dist/components/legal.d.ts +4 -2
  210. package/dist/components/legal.js.map +1 -1
  211. package/dist/components/lightbox.d.ts +2 -2
  212. package/dist/components/lightbox.js +17 -6
  213. package/dist/components/lightbox.js.map +1 -1
  214. package/dist/components/list.d.ts +6 -2
  215. package/dist/components/list.js +4 -3
  216. package/dist/components/list.js.map +1 -1
  217. package/dist/components/measured-grid.d.ts +1 -1
  218. package/dist/components/measured-grid.js +2 -1
  219. package/dist/components/measured-grid.js.map +1 -1
  220. package/dist/components/mini-calendar.js +3 -5
  221. package/dist/components/mini-calendar.js.map +1 -1
  222. package/dist/components/modal.d.ts +24 -0
  223. package/dist/components/modal.js +12 -4
  224. package/dist/components/modal.js.map +1 -1
  225. package/dist/components/money-draft.js +7 -5
  226. package/dist/components/money-draft.js.map +1 -1
  227. package/dist/components/money-field.d.ts +2 -2
  228. package/dist/components/money-field.js.map +1 -1
  229. package/dist/components/month-grid.d.ts +55 -0
  230. package/dist/components/month-grid.js +148 -0
  231. package/dist/components/month-grid.js.map +1 -0
  232. package/dist/components/month-picker.d.ts +36 -4
  233. package/dist/components/month-picker.js +123 -146
  234. package/dist/components/month-picker.js.map +1 -1
  235. package/dist/components/multi-entity-combobox.js +2 -1
  236. package/dist/components/multi-entity-combobox.js.map +1 -1
  237. package/dist/components/multi-select.d.ts +2 -2
  238. package/dist/components/multi-select.js +11 -6
  239. package/dist/components/multi-select.js.map +1 -1
  240. package/dist/components/number-field.d.ts +6 -4
  241. package/dist/components/number-field.js +3 -2
  242. package/dist/components/number-field.js.map +1 -1
  243. package/dist/components/number-input.d.ts +4 -1
  244. package/dist/components/number-input.js +3 -2
  245. package/dist/components/number-input.js.map +1 -1
  246. package/dist/components/numpad-sheet.js.map +1 -1
  247. package/dist/components/picker-sheet.js +2 -1
  248. package/dist/components/picker-sheet.js.map +1 -1
  249. package/dist/components/pie-chart-labels.d.ts +7 -0
  250. package/dist/components/pie-chart-labels.js +1 -0
  251. package/dist/components/pie-chart-labels.js.map +1 -1
  252. package/dist/components/pie-chart.d.ts +5 -3
  253. package/dist/components/pie-chart.js +7 -22
  254. package/dist/components/pie-chart.js.map +1 -1
  255. package/dist/components/popover.d.ts +3 -0
  256. package/dist/components/popover.js +7 -1
  257. package/dist/components/popover.js.map +1 -1
  258. package/dist/components/reauth-dialog.d.ts +4 -5
  259. package/dist/components/reauth-dialog.js +1 -4
  260. package/dist/components/reauth-dialog.js.map +1 -1
  261. package/dist/components/row-actions.js +2 -1
  262. package/dist/components/row-actions.js.map +1 -1
  263. package/dist/components/section-nav.d.ts +7 -0
  264. package/dist/components/section-nav.js.map +1 -1
  265. package/dist/components/series-chart-axes.d.ts +10 -3
  266. package/dist/components/series-chart-axes.js +1 -0
  267. package/dist/components/series-chart-axes.js.map +1 -1
  268. package/dist/components/series-chart-labels.d.ts +7 -4
  269. package/dist/components/series-chart-labels.js.map +1 -1
  270. package/dist/components/series-chart.d.ts +31 -7
  271. package/dist/components/series-chart.js +72 -29
  272. package/dist/components/series-chart.js.map +1 -1
  273. package/dist/components/share-card.js +3 -3
  274. package/dist/components/share-card.js.map +1 -1
  275. package/dist/components/sign-chip-labels.d.ts +1 -0
  276. package/dist/components/sign-chip-labels.js.map +1 -1
  277. package/dist/components/sign-chip.d.ts +10 -1
  278. package/dist/components/sign-chip.js.map +1 -1
  279. package/dist/components/tabs-labels.d.ts +2 -0
  280. package/dist/components/tabs-labels.js +11 -0
  281. package/dist/components/tabs-labels.js.map +1 -0
  282. package/dist/components/tabs.d.ts +1 -1
  283. package/dist/components/tabs.js +13 -11
  284. package/dist/components/tabs.js.map +1 -1
  285. package/dist/components/toggle-legend.d.ts +2 -2
  286. package/dist/components/toggle-legend.js +6 -6
  287. package/dist/components/toggle-legend.js.map +1 -1
  288. package/dist/components/translation-review-editor.d.ts +4 -2
  289. package/dist/components/translation-review-editor.js +2 -3
  290. package/dist/components/translation-review-editor.js.map +1 -1
  291. package/dist/components/translation-review.d.ts +2 -1
  292. package/dist/components/translation-review.js +2 -2
  293. package/dist/components/translation-review.js.map +1 -1
  294. package/dist/components/treemap-labels.d.ts +26 -0
  295. package/dist/components/treemap-labels.js +10 -0
  296. package/dist/components/treemap-labels.js.map +1 -0
  297. package/dist/components/treemap-layout.d.ts +62 -0
  298. package/dist/components/treemap-layout.js +126 -0
  299. package/dist/components/treemap-layout.js.map +1 -0
  300. package/dist/components/treemap.d.ts +140 -17
  301. package/dist/components/treemap.js +324 -97
  302. package/dist/components/treemap.js.map +1 -1
  303. package/dist/components/use-table-state.d.ts +5 -5
  304. package/dist/components/use-table-state.js +4 -1
  305. package/dist/components/use-table-state.js.map +1 -1
  306. package/dist/data-table.d.ts +6 -2
  307. package/dist/data-table.js +7 -2
  308. package/dist/data-table.js.map +1 -1
  309. package/dist/eslint/index.js +1 -1
  310. package/dist/eslint/role-utilities.d.ts +36 -7
  311. package/dist/eslint/role-utilities.js +42 -9
  312. package/dist/eslint/role-utilities.js.map +1 -1
  313. package/dist/feedback/feedback-dialog.d.ts +25 -16
  314. package/dist/feedback/feedback-dialog.js +6 -2
  315. package/dist/feedback/feedback-dialog.js.map +1 -1
  316. package/dist/feedback/feedback-mutation.d.ts +30 -0
  317. package/dist/feedback/feedback-mutation.js +16 -0
  318. package/dist/feedback/feedback-mutation.js.map +1 -0
  319. package/dist/feedback/feedback-page-link.d.ts +53 -0
  320. package/dist/feedback/feedback-page-link.js +37 -0
  321. package/dist/feedback/feedback-page-link.js.map +1 -0
  322. package/dist/feedback/feedback-public-list.d.ts +12 -3
  323. package/dist/feedback/feedback-public-list.js +2 -1
  324. package/dist/feedback/feedback-public-list.js.map +1 -1
  325. package/dist/feedback/feedback-replies.d.ts +3 -1
  326. package/dist/feedback/feedback-replies.js +5 -4
  327. package/dist/feedback/feedback-replies.js.map +1 -1
  328. package/dist/feedback/feedback-row-detail-labels.js +5 -0
  329. package/dist/feedback/feedback-row-detail-labels.js.map +1 -1
  330. package/dist/feedback/feedback-row-detail.d.ts +64 -28
  331. package/dist/feedback/feedback-row-detail.js +30 -28
  332. package/dist/feedback/feedback-row-detail.js.map +1 -1
  333. package/dist/feedback/feedback-status-undo.d.ts +30 -11
  334. package/dist/feedback/feedback-status-undo.js +10 -15
  335. package/dist/feedback/feedback-status-undo.js.map +1 -1
  336. package/dist/feedback/feedback-submit-dialog.d.ts +1 -1
  337. package/dist/feedback/feedback-submit-dialog.js +1 -1
  338. package/dist/feedback/feedback-submit-dialog.js.map +1 -1
  339. package/dist/feedback/feedback-submit.js +9 -3
  340. package/dist/feedback/feedback-submit.js.map +1 -1
  341. package/dist/feedback/feedback-swipe.d.ts +1 -1
  342. package/dist/feedback/feedback-swipe.js.map +1 -1
  343. package/dist/feedback/feedback-table.d.ts +21 -9
  344. package/dist/feedback/feedback-table.js +45 -25
  345. package/dist/feedback/feedback-table.js.map +1 -1
  346. package/dist/feedback/feedback-thread-labels.d.ts +2 -2
  347. package/dist/feedback/feedback-thread-labels.js.map +1 -1
  348. package/dist/feedback/feedback-thread.d.ts +24 -23
  349. package/dist/feedback/feedback-thread.js +2 -1
  350. package/dist/feedback/feedback-thread.js.map +1 -1
  351. package/dist/feedback.d.ts +34 -0
  352. package/dist/feedback.js +42 -0
  353. package/dist/feedback.js.map +1 -1
  354. package/dist/hooks/use-dismiss.js.map +1 -1
  355. package/dist/hooks/use-focus-trap.d.ts +35 -0
  356. package/dist/hooks/use-focus-trap.js +6 -4
  357. package/dist/hooks/use-focus-trap.js.map +1 -1
  358. package/dist/hooks/use-hotkey.d.ts +5 -2
  359. package/dist/hooks/use-hotkey.js +5 -4
  360. package/dist/hooks/use-hotkey.js.map +1 -1
  361. package/dist/hooks/use-long-press.d.ts +7 -4
  362. package/dist/hooks/use-long-press.js +3 -0
  363. package/dist/hooks/use-long-press.js.map +1 -1
  364. package/dist/hooks/use-media-query.js +12 -4
  365. package/dist/hooks/use-media-query.js.map +1 -1
  366. package/dist/hooks/use-mounted.d.ts +22 -0
  367. package/dist/hooks/use-mounted.js +24 -0
  368. package/dist/hooks/use-mounted.js.map +1 -0
  369. package/dist/hooks/use-overlay-history.d.ts +7 -1
  370. package/dist/hooks/use-overlay-history.js +35 -5
  371. package/dist/hooks/use-overlay-history.js.map +1 -1
  372. package/dist/i18n/defaults.js +4 -5
  373. package/dist/i18n/defaults.js.map +1 -1
  374. package/dist/i18n/german.js +7 -1
  375. package/dist/i18n/german.js.map +1 -1
  376. package/dist/i18n/kit-labels.d.ts +9 -2
  377. package/dist/i18n/kit-labels.js.map +1 -1
  378. package/dist/i18n/locales/en.js +20 -41
  379. package/dist/i18n/locales/en.js.map +3 -3
  380. package/dist/i18n/locales/es.js +7 -1
  381. package/dist/i18n/locales/es.js.map +1 -1
  382. package/dist/i18n/locales/fr.js +20 -10
  383. package/dist/i18n/locales/fr.js.map +1 -1
  384. package/dist/i18n/locales/hu.js +9 -1
  385. package/dist/i18n/locales/hu.js.map +1 -1
  386. package/dist/i18n/locales/it.js +7 -1
  387. package/dist/i18n/locales/it.js.map +1 -1
  388. package/dist/i18n/locales/zh.js +8 -1
  389. package/dist/i18n/locales/zh.js.map +1 -1
  390. package/dist/i18n/review.js +5 -0
  391. package/dist/i18n/review.js.map +1 -1
  392. package/dist/index.d.ts +64 -17
  393. package/dist/index.js +77 -12
  394. package/dist/index.js.map +1 -1
  395. package/dist/landing/routing.d.ts +3 -1
  396. package/dist/landing/routing.js +4 -7
  397. package/dist/landing/routing.js.map +1 -1
  398. package/dist/lib/broadcast.d.ts +17 -0
  399. package/dist/lib/broadcast.js +30 -0
  400. package/dist/lib/broadcast.js.map +1 -0
  401. package/dist/lib/calc.d.ts +7 -1
  402. package/dist/lib/calc.js +3 -1
  403. package/dist/lib/calc.js.map +1 -1
  404. package/dist/lib/clipboard-minus.d.ts +2 -2
  405. package/dist/lib/clipboard-minus.js +1 -1
  406. package/dist/lib/clipboard-minus.js.map +1 -1
  407. package/dist/lib/date-format.d.ts +37 -2
  408. package/dist/lib/date-format.js +34 -8
  409. package/dist/lib/date-format.js.map +1 -1
  410. package/dist/lib/day-format.d.ts +46 -0
  411. package/dist/lib/day-format.js +46 -0
  412. package/dist/lib/day-format.js.map +1 -0
  413. package/dist/lib/decimal-marks.d.ts +7 -1
  414. package/dist/lib/decimal-marks.js +5 -2
  415. package/dist/lib/decimal-marks.js.map +1 -1
  416. package/dist/lib/describe-failure.d.ts +14 -0
  417. package/dist/lib/describe-failure.js +9 -0
  418. package/dist/lib/describe-failure.js.map +1 -0
  419. package/dist/lib/direction.d.ts +16 -0
  420. package/dist/lib/direction.js +9 -1
  421. package/dist/lib/direction.js.map +1 -1
  422. package/dist/lib/focus-left.d.ts +63 -0
  423. package/dist/lib/focus-left.js +67 -0
  424. package/dist/lib/focus-left.js.map +1 -0
  425. package/dist/lib/format.d.ts +5 -3
  426. package/dist/lib/format.js +16 -13
  427. package/dist/lib/format.js.map +1 -1
  428. package/dist/lib/http-status.d.ts +24 -0
  429. package/dist/lib/http-status.js +14 -0
  430. package/dist/lib/http-status.js.map +1 -0
  431. package/dist/lib/intl-cache.d.ts +14 -0
  432. package/dist/lib/intl-cache.js +15 -0
  433. package/dist/lib/intl-cache.js.map +1 -0
  434. package/dist/lib/isin.d.ts +10 -0
  435. package/dist/lib/isin.js.map +1 -1
  436. package/dist/lib/iso-day.d.ts +11 -0
  437. package/dist/lib/iso-day.js +8 -0
  438. package/dist/lib/iso-day.js.map +1 -0
  439. package/dist/lib/lazy-with-fallback.d.ts +31 -0
  440. package/dist/lib/lazy-with-fallback.js +40 -0
  441. package/dist/lib/lazy-with-fallback.js.map +1 -0
  442. package/dist/lib/path-pattern.d.ts +34 -0
  443. package/dist/lib/path-pattern.js +24 -0
  444. package/dist/lib/path-pattern.js.map +1 -0
  445. package/dist/lib/reduced-motion.d.ts +2 -1
  446. package/dist/lib/reduced-motion.js.map +1 -1
  447. package/dist/lib/round.d.ts +2 -1
  448. package/dist/lib/round.js +2 -1
  449. package/dist/lib/round.js.map +1 -1
  450. package/dist/lib/safe-storage.d.ts +24 -5
  451. package/dist/lib/safe-storage.js +27 -2
  452. package/dist/lib/safe-storage.js.map +1 -1
  453. package/dist/lib/session-refresh.js +1 -1
  454. package/dist/lib/session-refresh.js.map +1 -1
  455. package/dist/lib/share-format.d.ts +13 -0
  456. package/dist/lib/share-format.js +10 -0
  457. package/dist/lib/share-format.js.map +1 -0
  458. package/dist/lib/text-case.d.ts +17 -0
  459. package/dist/lib/text-case.js +8 -0
  460. package/dist/lib/text-case.js.map +1 -0
  461. package/dist/lib/text-match.d.ts +38 -0
  462. package/dist/lib/text-match.js +24 -2
  463. package/dist/lib/text-match.js.map +1 -1
  464. package/dist/lib/thenable.d.ts +13 -0
  465. package/dist/lib/thenable.js +8 -0
  466. package/dist/lib/thenable.js.map +1 -0
  467. package/dist/lib/translation-review.d.ts +7 -2
  468. package/dist/lib/translation-review.js +4 -4
  469. package/dist/lib/translation-review.js.map +1 -1
  470. package/dist/notifications/device-zone-report.js +1 -1
  471. package/dist/notifications/device-zone-report.js.map +1 -1
  472. package/dist/notifications/notification-bell.d.ts +2 -1
  473. package/dist/notifications/notification-bell.js +3 -3
  474. package/dist/notifications/notification-bell.js.map +1 -1
  475. package/dist/notifications/notification-inbox.d.ts +10 -6
  476. package/dist/notifications/notification-inbox.js +26 -48
  477. package/dist/notifications/notification-inbox.js.map +1 -1
  478. package/dist/notifications/notification-parts.d.ts +3 -2
  479. package/dist/notifications/notification-parts.js +1 -3
  480. package/dist/notifications/notification-parts.js.map +1 -1
  481. package/dist/notifications/notification-types-setting.js +1 -1
  482. package/dist/notifications/notification-types-setting.js.map +1 -1
  483. package/dist/notifications/notifications-labels.d.ts +6 -0
  484. package/dist/notifications/notifications-labels.js +1 -0
  485. package/dist/notifications/notifications-labels.js.map +1 -1
  486. package/dist/notifications/push-device-setting.js +1 -1
  487. package/dist/notifications/push-device-setting.js.map +1 -1
  488. package/dist/notifications/push-devices-setting.d.ts +2 -1
  489. package/dist/notifications/push-devices-setting.js +27 -49
  490. package/dist/notifications/push-devices-setting.js.map +1 -1
  491. package/dist/notifications/quiet-hours-setting.d.ts +10 -3
  492. package/dist/notifications/quiet-hours-setting.js +65 -26
  493. package/dist/notifications/quiet-hours-setting.js.map +1 -1
  494. package/dist/notifications/unsubscribe-panel.js +4 -7
  495. package/dist/notifications/unsubscribe-panel.js.map +1 -1
  496. package/dist/notifications/use-push-device.d.ts +39 -1
  497. package/dist/notifications/use-push-device.js +28 -7
  498. package/dist/notifications/use-push-device.js.map +1 -1
  499. package/dist/offline/query-persistence.d.ts +3 -1
  500. package/dist/offline/query-persistence.js +19 -2
  501. package/dist/offline/query-persistence.js.map +1 -1
  502. package/dist/rhf/fields.d.ts +11 -4
  503. package/dist/rhf/fields.js.map +1 -1
  504. package/dist/search/command-palette.js +1 -1
  505. package/dist/search/command-palette.js.map +1 -1
  506. package/dist/search/global-search.js +19 -9
  507. package/dist/search/global-search.js.map +1 -1
  508. package/dist/search/use-command-key.d.ts +12 -1
  509. package/dist/search/use-command-key.js +3 -12
  510. package/dist/search/use-command-key.js.map +1 -1
  511. package/dist/search.d.ts +7 -0
  512. package/dist/search.js +10 -0
  513. package/dist/search.js.map +1 -1
  514. package/dist/settings/use-settings-focus.js +1 -0
  515. package/dist/settings/use-settings-focus.js.map +1 -1
  516. package/dist/shell/account-menu-language.d.ts +21 -5
  517. package/dist/shell/account-menu-language.js +3 -1
  518. package/dist/shell/account-menu-language.js.map +1 -1
  519. package/dist/shell/account-menu-text-size.d.ts +26 -9
  520. package/dist/shell/account-menu-text-size.js +3 -2
  521. package/dist/shell/account-menu-text-size.js.map +1 -1
  522. package/dist/shell/dev-menu.js +5 -18
  523. package/dist/shell/dev-menu.js.map +1 -1
  524. package/dist/shell/role-switcher.d.ts +7 -0
  525. package/dist/shell/role-switcher.js.map +1 -1
  526. package/dist/shell/top-bar-actions.d.ts +1 -1
  527. package/dist/shell/top-bar-actions.js.map +1 -1
  528. package/dist/shell/top-bar-parts-labels.d.ts +0 -2
  529. package/dist/shell/top-bar-parts-labels.js +0 -1
  530. package/dist/shell/top-bar-parts-labels.js.map +1 -1
  531. package/dist/shell.d.ts +27 -8
  532. package/dist/shell.js +28 -7
  533. package/dist/shell.js.map +1 -1
  534. package/dist/sync/engine.d.ts +30 -4
  535. package/dist/sync/engine.js +172 -52
  536. package/dist/sync/engine.js.map +1 -1
  537. package/dist/sync.d.ts +6 -2
  538. package/dist/sync.js +6 -1
  539. package/dist/sync.js.map +1 -1
  540. package/dist/testing/css-variables.js +3 -8
  541. package/dist/testing/css-variables.js.map +1 -1
  542. package/dist/theme/contrast.d.ts +2 -1
  543. package/dist/theme/contrast.js +3 -8
  544. package/dist/theme/contrast.js.map +1 -1
  545. package/dist/theme/palette-store.js +6 -6
  546. package/dist/theme/palette-store.js.map +1 -1
  547. package/dist/theme/text-size.js +3 -8
  548. package/dist/theme/text-size.js.map +1 -1
  549. package/dist/theme/theme-store.js +3 -6
  550. package/dist/theme/theme-store.js.map +1 -1
  551. package/dist/tour/tour-catalogue.d.ts +7 -4
  552. package/dist/tour/tour-catalogue.js +12 -10
  553. package/dist/tour/tour-catalogue.js.map +1 -1
  554. package/dist/tour/tour-dock.d.ts +0 -2
  555. package/dist/tour/tour-dock.js +0 -2
  556. package/dist/tour/tour-dock.js.map +1 -1
  557. package/dist/tour/tour-gates.d.ts +4 -0
  558. package/dist/tour/tour-gates.js +14 -0
  559. package/dist/tour/tour-gates.js.map +1 -1
  560. package/dist/tour/tour-overlay.d.ts +27 -0
  561. package/dist/tour/tour-overlay.js +741 -0
  562. package/dist/tour/tour-overlay.js.map +1 -0
  563. package/dist/tour/tour.d.ts +16 -4
  564. package/dist/tour/tour.js +62 -778
  565. package/dist/tour/tour.js.map +1 -1
  566. package/dist/tour/use-tour-progress.js +1 -1
  567. package/dist/tour/use-tour-progress.js.map +1 -1
  568. package/dist/tour/use-tour-url-sync.js +2 -2
  569. package/dist/tour/use-tour-url-sync.js.map +1 -1
  570. package/dist/wizard/stepper-nav.d.ts +5 -1
  571. package/dist/wizard/stepper-nav.js.map +1 -1
  572. package/dist/wizard/types.d.ts +6 -2
  573. package/dist/wizard/types.js.map +1 -1
  574. package/dist/wizard/use-wizard.d.ts +3 -1
  575. package/dist/wizard/use-wizard.js.map +1 -1
  576. package/dist/wizard/validation.d.ts +3 -1
  577. package/dist/wizard/validation.js.map +1 -1
  578. package/package.json +12 -8
  579. package/src/account/account-parts.ts +5 -25
  580. package/src/account/data-export-setting-labels.ts +1 -1
  581. package/src/account/delete-account-setting-labels.ts +1 -1
  582. package/src/account/email-change-setting-labels.ts +1 -1
  583. package/src/account/passkeys-setting.tsx +60 -38
  584. package/src/account/sessions-setting.tsx +18 -12
  585. package/src/admin/admin-action-confirm.tsx +5 -10
  586. package/src/admin/admin-parts.ts +11 -25
  587. package/src/admin/mail-test-card-labels.ts +1 -1
  588. package/src/admin/plan-change-labels.ts +5 -23
  589. package/src/admin/plan-change.tsx +7 -44
  590. package/src/admin/reviewer-scope-editor.tsx +3 -3
  591. package/src/auth/auth-errors-labels.ts +23 -0
  592. package/src/auth/auth-errors.ts +11 -38
  593. package/src/auth/complete-name-dialog.tsx +9 -8
  594. package/src/auth/forgot-password-form-labels.ts +1 -1
  595. package/src/auth/forgot-password-form.tsx +11 -6
  596. package/src/auth/register-form-labels.ts +1 -1
  597. package/src/auth/reset-password-form-labels.ts +1 -1
  598. package/src/auth/reset-password-form.tsx +8 -4
  599. package/src/auth/sign-in-form-labels.ts +1 -1
  600. package/src/auth/status-parts.tsx +0 -6
  601. package/src/auth/verify-email-labels.ts +1 -1
  602. package/src/auth/verify-email.tsx +11 -6
  603. package/src/billing/cancel-request.ts +28 -6
  604. package/src/billing/cancel-subscription.tsx +29 -22
  605. package/src/billing/dialog-close.ts +34 -0
  606. package/src/billing/plan-card.tsx +36 -11
  607. package/src/billing/plan-change-labels.ts +66 -0
  608. package/src/billing/plan-switch.tsx +31 -20
  609. package/src/chart.ts +21 -3
  610. package/src/components/account-chips.tsx +20 -23
  611. package/src/components/alert-banner.tsx +82 -5
  612. package/src/components/amount-input.tsx +32 -14
  613. package/src/components/autocomplete.tsx +64 -70
  614. package/src/components/bulk-action-bar.tsx +70 -2
  615. package/src/components/button-look.ts +5 -5
  616. package/src/components/button.tsx +2 -2
  617. package/src/components/calculator.tsx +98 -17
  618. package/src/components/chart-edge.ts +34 -1
  619. package/src/components/chart-figure.tsx +35 -0
  620. package/src/components/chart-zoom-core.tsx +6 -5
  621. package/src/components/chart.tsx +26 -5
  622. package/src/components/combobox-core.tsx +303 -69
  623. package/src/components/combobox.tsx +184 -155
  624. package/src/components/copy-button.tsx +34 -23
  625. package/src/components/country-select.tsx +16 -11
  626. package/src/components/data-table-column-settings.tsx +52 -10
  627. package/src/components/data-table-filters.ts +6 -4
  628. package/src/components/data-table-fit.ts +19 -5
  629. package/src/components/data-table-groups.tsx +1 -1
  630. package/src/components/data-table-head.tsx +32 -22
  631. package/src/components/data-table-mobile.tsx +110 -27
  632. package/src/components/data-table-pagination.tsx +21 -6
  633. package/src/components/data-table-resize.ts +1 -1
  634. package/src/components/data-table-row-actions.tsx +3 -3
  635. package/src/components/data-table-row.tsx +25 -14
  636. package/src/components/data-table-selection.ts +1 -1
  637. package/src/components/data-table-shared.tsx +33 -1
  638. package/src/components/data-table-sort.ts +57 -2
  639. package/src/components/data-table-virtual.ts +32 -8
  640. package/src/components/data-table.tsx +267 -41
  641. package/src/components/date-field.tsx +65 -8
  642. package/src/components/date-picker.tsx +125 -48
  643. package/src/components/date-range-picker.tsx +82 -31
  644. package/src/components/dialog-frame.tsx +2 -1
  645. package/src/components/entity-combobox.tsx +4 -1
  646. package/src/components/error-boundary.tsx +53 -39
  647. package/src/components/field-base-labels.ts +20 -0
  648. package/src/components/field-base.tsx +13 -7
  649. package/src/components/field-sync-labels.ts +1 -0
  650. package/src/components/field-sync.tsx +23 -1
  651. package/src/components/form-actions.tsx +20 -5
  652. package/src/components/hover-menu.tsx +18 -8
  653. package/src/components/icon-button.tsx +14 -9
  654. package/src/components/inline-confirm.tsx +116 -0
  655. package/src/components/inline-entity-combobox.tsx +198 -152
  656. package/src/components/input.tsx +1 -1
  657. package/src/components/jump-calendar.tsx +30 -146
  658. package/src/components/legal-page.tsx +10 -7
  659. package/src/components/legal.tsx +4 -2
  660. package/src/components/lightbox.tsx +21 -8
  661. package/src/components/list.tsx +14 -5
  662. package/src/components/measured-grid.tsx +8 -4
  663. package/src/components/mini-calendar.tsx +6 -5
  664. package/src/components/modal.tsx +45 -4
  665. package/src/components/money-draft.ts +16 -5
  666. package/src/components/money-field.tsx +2 -2
  667. package/src/components/month-grid.tsx +229 -0
  668. package/src/components/month-picker.tsx +192 -200
  669. package/src/components/multi-entity-combobox.tsx +1 -0
  670. package/src/components/multi-select.tsx +21 -9
  671. package/src/components/number-field.tsx +14 -7
  672. package/src/components/number-input.tsx +9 -3
  673. package/src/components/numpad-sheet.tsx +4 -3
  674. package/src/components/picker-sheet.tsx +12 -9
  675. package/src/components/pie-chart-labels.ts +8 -0
  676. package/src/components/pie-chart.tsx +22 -28
  677. package/src/components/popover.tsx +18 -1
  678. package/src/components/reauth-dialog.tsx +6 -10
  679. package/src/components/row-actions.tsx +2 -1
  680. package/src/components/section-nav.tsx +7 -0
  681. package/src/components/series-chart-axes.ts +11 -3
  682. package/src/components/series-chart-labels.ts +7 -4
  683. package/src/components/series-chart.tsx +178 -69
  684. package/src/components/share-card.tsx +6 -6
  685. package/src/components/sign-chip-labels.ts +1 -0
  686. package/src/components/sign-chip.tsx +10 -1
  687. package/src/components/tabs-labels.ts +13 -0
  688. package/src/components/tabs.tsx +35 -19
  689. package/src/components/toggle-legend.tsx +16 -11
  690. package/src/components/translation-review-editor.tsx +6 -5
  691. package/src/components/translation-review.tsx +4 -3
  692. package/src/components/treemap-labels.ts +39 -0
  693. package/src/components/treemap-layout.ts +210 -0
  694. package/src/components/treemap.tsx +722 -133
  695. package/src/components/use-table-state.ts +12 -9
  696. package/src/data-table.ts +9 -2
  697. package/src/eslint/role-utilities.ts +97 -19
  698. package/src/feedback/feedback-dialog.tsx +30 -19
  699. package/src/feedback/feedback-mutation.ts +41 -0
  700. package/src/feedback/feedback-page-link.ts +90 -0
  701. package/src/feedback/feedback-public-list.tsx +17 -5
  702. package/src/feedback/feedback-replies.tsx +13 -6
  703. package/src/feedback/feedback-row-detail-labels.ts +5 -0
  704. package/src/feedback/feedback-row-detail.tsx +103 -67
  705. package/src/feedback/feedback-status-undo.ts +41 -27
  706. package/src/feedback/feedback-submit-dialog.tsx +2 -2
  707. package/src/feedback/feedback-submit.tsx +21 -7
  708. package/src/feedback/feedback-swipe.tsx +1 -1
  709. package/src/feedback/feedback-table.tsx +86 -38
  710. package/src/feedback/feedback-thread-labels.ts +2 -2
  711. package/src/feedback/feedback-thread.tsx +27 -25
  712. package/src/feedback.ts +42 -0
  713. package/src/hooks/use-dismiss.ts +3 -2
  714. package/src/hooks/use-focus-trap.ts +8 -24
  715. package/src/hooks/use-hotkey.ts +24 -7
  716. package/src/hooks/use-long-press.ts +16 -2
  717. package/src/hooks/use-media-query.ts +20 -4
  718. package/src/hooks/use-mounted.ts +39 -0
  719. package/src/hooks/use-overlay-history.ts +70 -5
  720. package/src/i18n/defaults.ts +4 -5
  721. package/src/i18n/german.ts +8 -2
  722. package/src/i18n/kit-labels.tsx +9 -2
  723. package/src/i18n/locales/es.ts +8 -2
  724. package/src/i18n/locales/fr.ts +21 -13
  725. package/src/i18n/locales/hu.ts +10 -2
  726. package/src/i18n/locales/it.ts +8 -2
  727. package/src/i18n/locales/zh.ts +9 -2
  728. package/src/i18n/review.ts +5 -0
  729. package/src/index.ts +103 -13
  730. package/src/landing/routing.tsx +14 -10
  731. package/src/lib/broadcast.ts +52 -0
  732. package/src/lib/calc.ts +13 -2
  733. package/src/lib/clipboard-minus.ts +14 -4
  734. package/src/lib/date-format.ts +89 -13
  735. package/src/lib/day-format.ts +96 -0
  736. package/src/lib/decimal-marks.ts +12 -3
  737. package/src/lib/describe-failure.ts +18 -0
  738. package/src/lib/direction.ts +39 -0
  739. package/src/lib/focus-left.ts +156 -0
  740. package/src/lib/format.ts +34 -19
  741. package/src/lib/http-status.ts +38 -0
  742. package/src/lib/intl-cache.ts +25 -0
  743. package/src/lib/isin.ts +10 -0
  744. package/src/lib/iso-day.ts +13 -0
  745. package/src/lib/lazy-with-fallback.ts +82 -0
  746. package/src/lib/path-pattern.ts +55 -0
  747. package/src/lib/reduced-motion.ts +2 -1
  748. package/src/lib/round.ts +7 -2
  749. package/src/lib/safe-storage.ts +48 -6
  750. package/src/lib/session-refresh.ts +1 -1
  751. package/src/lib/share-format.ts +18 -0
  752. package/src/lib/text-case.ts +19 -0
  753. package/src/lib/text-match.ts +69 -2
  754. package/src/lib/thenable.ts +19 -0
  755. package/src/lib/translation-review.ts +13 -5
  756. package/src/notifications/device-zone-report.ts +1 -1
  757. package/src/notifications/notification-bell.tsx +7 -4
  758. package/src/notifications/notification-inbox.tsx +40 -58
  759. package/src/notifications/notification-parts.tsx +3 -4
  760. package/src/notifications/notification-types-setting.tsx +1 -1
  761. package/src/notifications/notifications-labels.ts +7 -0
  762. package/src/notifications/push-device-setting.tsx +1 -1
  763. package/src/notifications/push-devices-setting.tsx +30 -55
  764. package/src/notifications/quiet-hours-setting.tsx +93 -31
  765. package/src/notifications/unsubscribe-panel.tsx +4 -7
  766. package/src/notifications/use-push-device.ts +76 -10
  767. package/src/offline/query-persistence.ts +35 -3
  768. package/src/rhf/fields.tsx +11 -4
  769. package/src/search/command-palette.tsx +2 -4
  770. package/src/search/global-search.tsx +36 -15
  771. package/src/search/use-command-key.ts +13 -12
  772. package/src/search.ts +9 -0
  773. package/src/settings/use-settings-focus.ts +3 -0
  774. package/src/shell/account-menu-language.tsx +27 -5
  775. package/src/shell/account-menu-text-size.tsx +32 -10
  776. package/src/shell/dev-menu.tsx +7 -21
  777. package/src/shell/role-switcher.tsx +7 -0
  778. package/src/shell/top-bar-actions.tsx +1 -1
  779. package/src/shell/top-bar-parts-labels.ts +0 -3
  780. package/src/shell.ts +40 -9
  781. package/src/sync/engine.ts +339 -61
  782. package/src/sync.ts +8 -1
  783. package/src/testing/css-variables.ts +8 -9
  784. package/src/theme/contrast.ts +8 -9
  785. package/src/theme/palette-store.ts +9 -9
  786. package/src/theme/text-size.ts +6 -8
  787. package/src/theme/theme-store.ts +7 -9
  788. package/src/tour/tour-catalogue.tsx +26 -15
  789. package/src/tour/tour-dock.ts +0 -2
  790. package/src/tour/tour-gates.ts +23 -0
  791. package/src/tour/tour-overlay.tsx +1170 -0
  792. package/src/tour/tour.tsx +116 -1193
  793. package/src/tour/use-tour-progress.ts +1 -1
  794. package/src/tour/use-tour-url-sync.ts +7 -3
  795. package/src/wizard/stepper-nav.tsx +3 -1
  796. package/src/wizard/types.ts +11 -2
  797. package/src/wizard/use-wizard.ts +2 -1
  798. package/src/wizard/validation.ts +8 -2
  799. package/tokens.css +2 -1
  800. package/dist/components/ui-labels.js.map +0 -1
  801. package/dist/shell/dev-switchers.d.ts +0 -6
  802. package/dist/shell/dev-switchers.js +0 -12
  803. package/dist/shell/dev-switchers.js.map +0 -1
  804. package/src/components/ui-labels.ts +0 -24
  805. package/src/shell/dev-switchers.tsx +0 -18
package/src/tour/tour.tsx CHANGED
@@ -1,33 +1,76 @@
1
1
  import {
2
2
  createContext,
3
+ Suspense,
3
4
  useCallback,
4
5
  useContext,
5
6
  useEffect,
6
- useId,
7
7
  useLayoutEffect,
8
8
  useMemo,
9
9
  useRef,
10
10
  useState,
11
- useSyncExternalStore,
12
11
  } from "react";
13
- import type { CSSProperties, ReactNode, RefObject } from "react";
14
- import { createPortal } from "react-dom";
15
- import { cn } from "../lib/cn";
12
+ import type { ReactNode } from "react";
16
13
  import { useKitLabels, type LabelOverride } from "../i18n/kit-labels";
17
- import { Button } from "../components/button";
18
- import { useFocusTrap } from "../hooks/use-focus-trap";
19
- import { useDismissLayer } from "../hooks/use-dismiss";
20
- import { sameRect } from "../hooks/use-anchored-rect";
21
- import { dirOf, horizontalStep } from "../lib/direction";
22
- import { isComposing } from "../lib/ime";
23
- import { focusQuietly } from "../lib/quiet-focus";
24
- import type { Direction } from "../lib/direction";
25
14
  import { DEFAULT_TOUR_LABELS } from "./tour-labels";
26
15
  import type { TourInfo } from "./tour-info";
27
16
  import { completeStored, rememberAccount, rememberMigrate, type UseTourProgressOptions } from "./use-tour-progress";
28
- import { createGateRegistry, devWarnings, TourInternalContext, type GateRegistry } from "./tour-gates";
17
+ import { createGateRegistry, devWarnings, isShown, stepContext, TourInternalContext } from "./tour-gates";
29
18
  import { liveEngine } from "./tour-engine";
30
- import { DOCK_MAX_WIDTH, dockEdge, dockStyle, readBand, scrollIntoFreeHalf, type DockEdge } from "./tour-dock";
19
+ import { lazyWithFallback } from "../lib/lazy-with-fallback";
20
+ // Types only, gone from the built module: the overlay's modules load with the overlay.
21
+ import type { Refusal } from "./tour-overlay";
22
+
23
+ /**
24
+ * The overlay — the card, the spotlight and its shields, the placement, the dock — loaded
25
+ * when a tour first starts, not with the provider every app mounts above its routes
26
+ * (refactor audit 2026-10-30, MOD-1: about 28.5 kB minified, 10.3 kB gzip of each app's
27
+ * first load at 0.51.6). A LITERAL relative `import()`, as feedback-submit.tsx's dialog
28
+ * is (0.34, MOD-1): the library build keeps the module its own (`bundle: false`), and a
29
+ * path an app's bundler can read is a chunk it can split off.
30
+ *
31
+ * A fetch that fails — a tab left open across a deploy, a local-first app offline — ends
32
+ * the run and leaves the page (0.52 code review, tour.tsx): the provider sits above the
33
+ * routes, in keksdose and Kurvenschmiede above the app's own boundary, and the rejected
34
+ * import unmounted the whole app — for a tour, whose start fetched nothing before 0.52.
35
+ * `lazyWithFallback` logs it, and the next start fetches again.
36
+ */
37
+ const LazyTourOverlay = lazyWithFallback(
38
+ () => import("./tour-overlay").then((module) => module.TourOverlay),
39
+ TourOverlayUnavailable,
40
+ );
41
+
42
+ /** The provider's end of a run whose overlay did not load; see {@link TourOverlayUnavailable}. */
43
+ const TourUnavailableContext = createContext<() => void>(() => {});
44
+
45
+ /**
46
+ * Stands in for an overlay whose chunk did not arrive: ends the run with the start's
47
+ * `onSkip("unavailable")` and draws nothing. It ended with `stop()` at first, which calls
48
+ * nothing — after the start's `onStart` had run, so what the app turned on for the run
49
+ * stayed on: kastlan's practice mode, which its launcher turns on and its `onSkip` and
50
+ * `onFinish` turn off (0.52 code review, tour.tsx).
51
+ */
52
+ function TourOverlayUnavailable() {
53
+ const unavailable = useContext(TourUnavailableContext);
54
+ useLayoutEffect(unavailable, [unavailable]);
55
+ return null;
56
+ }
57
+
58
+ /**
59
+ * Hears Escape while the overlay's chunk is on its way, as the overlay does before it has
60
+ * located its step: the run is skipped. With nothing mounted the tour was `active` and
61
+ * deaf, and on a slow first start the overlay came up seconds after the person had
62
+ * pressed Escape and gone back to the page (0.52 code review, tour.tsx).
63
+ */
64
+ function TourOverlayLoading({ onSkip }: { onSkip: () => void }) {
65
+ useEffect(() => {
66
+ const onKey = (e: KeyboardEvent) => {
67
+ if (e.key === "Escape") onSkip();
68
+ };
69
+ document.addEventListener("keydown", onKey);
70
+ return () => document.removeEventListener("keydown", onKey);
71
+ }, [onSkip]);
72
+ return null;
73
+ }
31
74
 
32
75
  export { useTourGate, useTourGateRelease } from "./tour-gates";
33
76
  export type { TourGateRelease } from "./tour-gates";
@@ -57,8 +100,9 @@ export interface TourStep {
57
100
  * are physical. An explicit side flips to the opposite side if it would
58
101
  * overflow, then clamps into the viewport.
59
102
  *
60
- * `"dock"` (0.50, §11.7): below `sm` (640 px) the card is pinned full-width to the top
61
- * or bottom edge of the usable band — the visual viewport less the keyboard and any
103
+ * `"dock"` (0.50, §11.7): below `sm` (640 px at Normal text, 800 at Large, as
104
+ * `max-sm:` since 0.52) the card is pinned full-width to the top or bottom edge of the
105
+ * usable band — the visual viewport less the keyboard and any
62
106
  * `[data-tour-obstruction]` (the number pad) — on the edge away from the field, and the
63
107
  * field's scroll container brings it into the other half. From `sm` up it is auto
64
108
  * placement. On a phone a field step (`interactive`, `awaitInput`, `gate`, `awaitGate`)
@@ -140,7 +184,9 @@ export interface TourStep {
140
184
  /** Runs before the step is shown — e.g. navigate to a route, open a panel.
141
185
  * May be async; the step waits for it, then locates the target. Receives the
142
186
  * {@link TourStepContext} (0.50); a step entered by "Guide me" sees `via: "at"` and
143
- * should leave an open form alone. */
187
+ * should leave an open form alone. One that throws or rejects is logged to the
188
+ * console, and the step is located and shown anyway. Enter and the arrows wait for
189
+ * it; Escape does not. */
144
190
  beforeStep?: (ctx: TourStepContext) => void | Promise<void>;
145
191
  }
146
192
 
@@ -255,9 +301,19 @@ interface StartOptions {
255
301
  onStart?: () => void;
256
302
  /** After the last step: runs after the provider's progress write and `onComplete`. */
257
303
  onFinish?: () => void;
258
- onSkip?: () => void;
304
+ /**
305
+ * The run ended before its last step — undo here what `onStart` or the launcher turned
306
+ * on. `reason` says why: `"skipped"`, the person left (Skip, Escape); `"unavailable"`
307
+ * (0.52), the overlay's chunk did not load (a tab left open across a deploy, offline),
308
+ * so no step was shown — the moment to say so, if the app wants to. `stop()` calls
309
+ * nothing.
310
+ */
311
+ onSkip?: (reason?: TourSkipReason) => void;
259
312
  }
260
313
 
314
+ /** Why a run ended before its last step, as `onSkip` hears it. */
315
+ type TourSkipReason = "skipped" | "unavailable";
316
+
261
317
  /** What `TourProvider`'s `onComplete` learns besides the tour (§9.1, §9.6). */
262
318
  export interface TourCompletion {
263
319
  /**
@@ -481,7 +537,10 @@ export function TourProvider({
481
537
  const last = Math.max(0, s.length - 1);
482
538
  floorRef.current = opts?.at === undefined ? 0 : resolveAt(s, opts.at);
483
539
  const via: TourStepContext["via"] = opts?.at === undefined ? "start" : "at";
484
- const wanted = Math.min(Math.max(floorRef.current, opts?.startIndex ?? floorRef.current), last);
540
+ // Floored, as `at` is (FLW-9): `steps[1.5]` is undefined, and `forward` threw on
541
+ // its `when` — an edited `?tourStep=2.5` was enough.
542
+ const asked = opts?.startIndex === undefined ? floorRef.current : Math.floor(opts.startIndex);
543
+ const wanted = Math.min(Math.max(floorRef.current, asked), last);
485
544
  let to = forward(s, wanted, via);
486
545
  if (to < 0) to = backward(s, wanted, via);
487
546
  // Not one step of the run is shown: there is nothing to tour.
@@ -549,8 +608,17 @@ export function TourProvider({
549
608
  setSteps(null);
550
609
  setActiveId(null);
551
610
  }, []);
611
+ // Takes no argument: the card's Skip passes its click event.
552
612
  const skip = useCallback(() => {
553
- optsRef.current.onSkip?.();
613
+ optsRef.current.onSkip?.("skipped");
614
+ setSteps(null);
615
+ setActiveId(null);
616
+ }, []);
617
+ const unavailable = useCallback(() => {
618
+ // Once per run: the fallback's layout effect runs twice under StrictMode.
619
+ if (!stepsRef.current) return;
620
+ stepsRef.current = null;
621
+ optsRef.current.onSkip?.("unavailable");
554
622
  setSteps(null);
555
623
  setActiveId(null);
556
624
  }, []);
@@ -561,7 +629,7 @@ export function TourProvider({
561
629
  (i: number) => {
562
630
  const s = stepsRef.current;
563
631
  if (!s || s.length === 0) return;
564
- const wanted = Math.min(Math.max(floorRef.current, i), s.length - 1);
632
+ const wanted = Math.min(Math.max(floorRef.current, Math.floor(i)), s.length - 1);
565
633
  let to = forward(s, wanted, "goto");
566
634
  if (to < 0) to = backward(s, wanted, "goto");
567
635
  if (to >= 0) arrive(s, to, "goto");
@@ -628,24 +696,32 @@ export function TourProvider({
628
696
  <TourInternalContext.Provider value={internals}>
629
697
  <TourContext.Provider value={value}>
630
698
  {children}
631
- {active && (
632
- <TourOverlay
633
- steps={steps!}
634
- index={index}
635
- via={nav.via}
636
- floor={nav.floor}
637
- position={nav.position}
638
- count={nav.count}
639
- refusal={refusal?.step === steps![index] ? refusal : null}
640
- onGoTo={goToStep}
641
- labels={merged}
642
- gates={gates}
643
- dockOnPhones={dockOnPhones}
644
- onNext={next}
645
- onPrev={prev}
646
- onSkip={skip}
647
- />
648
- )}
699
+ {active ? (
700
+ // Its own boundary, so the first start's chunk fetch suspends nothing of the
701
+ // app's; it shows nothing meanwhile, as the overlay itself does until it has
702
+ // located the step, and hears Escape as it does. A failed fetch ends the run
703
+ // (`TourOverlayUnavailable`).
704
+ <Suspense fallback={<TourOverlayLoading onSkip={skip} />}>
705
+ <TourUnavailableContext.Provider value={unavailable}>
706
+ <LazyTourOverlay
707
+ steps={steps!}
708
+ index={index}
709
+ via={nav.via}
710
+ floor={nav.floor}
711
+ position={nav.position}
712
+ count={nav.count}
713
+ refusal={refusal?.step === steps![index] ? refusal : null}
714
+ onGoTo={goToStep}
715
+ labels={merged}
716
+ gates={gates}
717
+ dockOnPhones={dockOnPhones}
718
+ onNext={next}
719
+ onPrev={prev}
720
+ onSkip={skip}
721
+ />
722
+ </TourUnavailableContext.Provider>
723
+ </Suspense>
724
+ ) : null}
649
725
  </TourContext.Provider>
650
726
  </TourInternalContext.Provider>
651
727
  );
@@ -662,20 +738,6 @@ interface Nav {
662
738
 
663
739
  const NO_NAV: Nav = { index: 0, floor: 0, via: "start", position: 0, count: 0 };
664
740
 
665
- /** The app's `refuse` on the step that awaits its key (§11.4). */
666
- interface Refusal {
667
- step: TourStep;
668
- reason?: string;
669
- /** Bumped per refusal, so the same words are announced again. */
670
- seq: number;
671
- }
672
-
673
- const NOOP = () => {};
674
-
675
- function stepContext(gates: GateRegistry, via: TourStepContext["via"]): TourStepContext {
676
- return { gate: (key) => gates.get(key), via };
677
- }
678
-
679
741
  /** `StartOptions.at` as a step index: a number clamped, an anchor's first step, else 0. */
680
742
  function resolveAt(steps: TourStep[], at: TourAt): number {
681
743
  if (typeof at === "number") return Math.min(Math.max(0, Math.floor(at)), Math.max(0, steps.length - 1));
@@ -686,1142 +748,3 @@ function resolveAt(steps: TourStep[], at: TourAt): number {
686
748
  console.warn(`[ui-kit] A tour was started at "${at}", but no step targets [${anchor}]: it starts at 0.`);
687
749
  return 0;
688
750
  }
689
-
690
- /** The first step in [floor, index) shown now whose gate is published and unsatisfied, or -1. */
691
- function firstEmptied(steps: TourStep[], floor: number, index: number, gates: GateRegistry): number {
692
- const ctx = stepContext(gates, "goto");
693
- for (let j = floor; j < index; j++) {
694
- const key = steps[j].gate;
695
- if (key && gates.get(key) === false && isShown(steps[j], ctx)) return j;
696
- }
697
- return -1;
698
- }
699
-
700
- /** A step's `when`, asked now; a throw is a skip, and the error goes to the console. */
701
- function isShown(step: TourStep, ctx: TourStepContext): boolean {
702
- if (!step.when) return true;
703
- try {
704
- return step.when(ctx) === true;
705
- } catch (error) {
706
- console.error(error);
707
- return false;
708
- }
709
- }
710
-
711
- interface Rect {
712
- top: number;
713
- left: number;
714
- width: number;
715
- height: number;
716
- }
717
-
718
- function isVisible(el: Element): boolean {
719
- // A non-zero box already rules out display:none on the element or any ancestor
720
- // (an unrendered element measures 0x0). We deliberately do NOT test
721
- // offsetParent: it is null for position:fixed elements even when fully visible,
722
- // which made the mobile bottom-nav bar (fixed) un-highlightable on mobile
723
- // (feedback #313). visibility:hidden keeps a box, so check it explicitly.
724
- const r = el.getBoundingClientRect();
725
- if (r.width <= 0 || r.height <= 0) return false;
726
- const style = getComputedStyle(el);
727
- return style.visibility !== "hidden" && style.display !== "none";
728
- }
729
-
730
- // The first VISIBLE element matching the selector, not merely the first in DOM
731
- // order. This lets a step target the same control across layouts with one
732
- // combined selector — e.g. the desktop sidebar link AND the mobile bottom-bar
733
- // link — where the off-layout copy is present but `display:none` (feedback
734
- // #313). Returns null while none is visible so the finder keeps retrying.
735
- function queryVisibleTarget(selector: string): Element | null {
736
- const els = document.querySelectorAll(selector);
737
- for (const el of els) {
738
- if (isVisible(el)) return el;
739
- }
740
- return null;
741
- }
742
-
743
- function rectOf(el: Element): Rect {
744
- const r = el.getBoundingClientRect();
745
- return { top: r.top, left: r.left, width: r.width, height: r.height };
746
- }
747
-
748
- /** The two-tone frame's width outside the spot (3px white, 2px keyline), plus a pixel. */
749
- const RING_BAND = 6;
750
-
751
- /**
752
- * What a step's ring frames (keksdose S1, §11.6): the target, and on a FIELD step also the
753
- * lines that describe the field from outside it — the elements its `aria-describedby`
754
- * (on the target or a control inside) names that lie within the ring's reach of it (a
755
- * caption, a hint or warning line, an error drawn under or above the field). Without
756
- * them the ring's frame ran through such a line; with them it frames field and line, and
757
- * the line is lit, not under the scrim. A kit field's own caption and error are inside
758
- * its root already. A line far away (a tooltip, another part of the page) is not taken.
759
- */
760
- function spotRectOf(el: Element, step: TourStep): Rect {
761
- const own = rectOf(el);
762
- if (!isFieldStep(step)) return own;
763
- const ids = new Set<string>();
764
- const holders = [el, ...Array.from(el.querySelectorAll("[aria-describedby]"))];
765
- for (const holder of holders) {
766
- for (const id of (holder.getAttribute("aria-describedby") ?? "").split(/\s+/)) if (id) ids.add(id);
767
- }
768
- if (ids.size === 0) return own;
769
- const lines: DOMRect[] = [];
770
- for (const id of ids) {
771
- const line = document.getElementById(id);
772
- if (!line || el.contains(line) || line.closest('[role="tooltip"]') || !isVisible(line)) continue;
773
- const r = line.getBoundingClientRect();
774
- // An `sr-only` description measures 1×1: nothing to frame.
775
- if (r.width > 1 && r.height > 1) lines.push(r);
776
- }
777
- let top = own.top;
778
- let left = own.left;
779
- let right = own.left + own.width;
780
- let bottom = own.top + own.height;
781
- const reach = (step.padding ?? 8) + RING_BAND;
782
- // Grow until nothing more is in reach: a hint under the field, then an error under it.
783
- for (let grew = true; grew;) {
784
- grew = false;
785
- for (let i = lines.length - 1; i >= 0; i--) {
786
- const r = lines[i];
787
- const across = r.left < right && r.right > left;
788
- const gap = Math.max(r.top - bottom, top - r.bottom);
789
- if (!across || gap > reach) continue;
790
- top = Math.min(top, r.top);
791
- left = Math.min(left, r.left);
792
- right = Math.max(right, r.right);
793
- bottom = Math.max(bottom, r.bottom);
794
- lines.splice(i, 1);
795
- grew = true;
796
- }
797
- }
798
- return { top, left, width: right - left, height: bottom - top };
799
- }
800
-
801
- /**
802
- * What the finder established for ONE step: where its target is (`null` = no target,
803
- * or not on the page), and the reading direction the card takes from it.
804
- *
805
- * It carries the step it was found for, and the overlay only believes it for that
806
- * step — which is the whole fix for keksdose's tours audit 2026-10-02, §1.0 A ("stale
807
- * spotlight on the step after a spotlighted one", 15 steps in 16 tours, desktop and
808
- * phone, mouse and keyboard). When step N spotlit a target and step N+1 had none (or
809
- * its anchor was missing), N+1 kept N's hole and parked its card beside it, so a
810
- * centred "You're all set" read as pointing at the Import & Export link; Back→Next kept
811
- * it for as long as anyone watched.
812
- *
813
- * The overlay used to hold `rect` and `ready` as separate states and reset them
814
- * DURING RENDER when the step changed. React 19 does not keep a render-phase update
815
- * while an earlier, lower-priority update to the same hook is still queued — it only
816
- * writes the result to the base state "unless the queue is empty" — and the follow
817
- * interval below queues exactly such an update every 250 ms (eagerly bailed out because
818
- * the rect had not moved, but left in the queue for rebasing). So the click's render
819
- * showed the reset, and the very next render (the finder saying "ready") re-based on
820
- * the old rect. A deep link was fine because nothing had queued anything yet.
821
- *
822
- * Keying the result to its step does not depend on any of that ordering: a rect found
823
- * for another step is not this step's rect, whatever the queue does with it, and a
824
- * missing anchor reads as "no target" instead of as the last thing that was lit.
825
- */
826
- interface Located {
827
- index: number;
828
- step: TourStep;
829
- rect: Rect | null;
830
- dir: Direction;
831
- /**
832
- * A field step's own container (§11.6): inserted right after the kit layer holding the
833
- * target (`host.after`), or at the end of <body> on the page. `null` on a plain step,
834
- * which is portalled to <body> at z-[60] as ever.
835
- */
836
- layer: HTMLElement | null;
837
- /** The host fills the visual viewport (a phone's FullBleedDialog): no scrim, no shields. */
838
- fullScreen: boolean;
839
- }
840
-
841
- /** The kit layer (`data-kit-layer`) holding `el`, if any. */
842
- function layerHost(el: Element): HTMLElement | null {
843
- return el.closest<HTMLElement>("[data-kit-layer]");
844
- }
845
-
846
- /**
847
- * Does the host fill the visual viewport? A backdrop host (`data-kit-layer="backdrop"`:
848
- * Modal, FullBleedDialog) is judged by its panel, the child holding the target.
849
- */
850
- function coversViewport(host: HTMLElement, el: Element): boolean {
851
- let surface: Element = host;
852
- if (host.getAttribute("data-kit-layer") === "backdrop") {
853
- for (const child of Array.from(host.children)) {
854
- if (child.contains(el)) {
855
- surface = child;
856
- break;
857
- }
858
- }
859
- }
860
- const r = surface.getBoundingClientRect();
861
- const vv = window.visualViewport;
862
- const top = vv?.offsetTop ?? 0;
863
- const bottom = top + (vv?.height ?? window.innerHeight);
864
- const width = vv?.width ?? window.innerWidth;
865
- return r.width > 0 && r.left <= 1 && r.top <= top + 1 && r.right >= width - 1 && r.bottom >= bottom - 1;
866
- }
867
-
868
- /** Does this step's card dock now (§11.7)? A phone-width viewport, and `"dock"` or a field
869
- * step with no placement while the provider docks on phones. */
870
- function docks(step: TourStep, dockOnPhones: boolean): boolean {
871
- if (typeof window === "undefined" || window.innerWidth >= DOCK_MAX_WIDTH || !step.target) return false;
872
- return step.placement === "dock" || (step.placement === undefined && dockOnPhones && isFieldStep(step));
873
- }
874
-
875
- /** A step whose control is for using: its card joins the layer stack above the field (§11.6). */
876
- function isFieldStep(step: TourStep): boolean {
877
- return !!(step.interactive || step.awaitInput || step.gate || step.awaitGate);
878
- }
879
-
880
- /** The first control in `el` (or `el` itself) a person would type into or press. */
881
- function firstFocusable(el: Element): HTMLElement | null {
882
- if (el instanceof HTMLElement && el.matches(FOCUSABLE_CONTROL)) return el;
883
- return el.querySelector<HTMLElement>(FOCUSABLE_CONTROL);
884
- }
885
-
886
- /** The tab stops inside `el`, in DOM order (the focus trap's selector). */
887
- function tabStops(el: Element): HTMLElement[] {
888
- const all = el.matches(FOCUSABLE_CONTROL) ? [el as HTMLElement] : [];
889
- return all.concat(
890
- Array.from(el.querySelectorAll<HTMLElement>(FOCUSABLE_CONTROL)).filter(
891
- (x) => x.tabIndex >= 0 && !x.closest("[hidden],[inert]"),
892
- ),
893
- );
894
- }
895
-
896
- const FOCUSABLE_CONTROL =
897
- 'a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])';
898
-
899
- /** A touch screen: the card takes focus, so no keyboard or pad opens before the step is read (§11.8). */
900
- function coarsePointer(): boolean {
901
- return typeof window !== "undefined" && typeof window.matchMedia === "function"
902
- ? window.matchMedia("(pointer: coarse)").matches
903
- : false;
904
- }
905
-
906
- function TourOverlay({
907
- steps,
908
- index,
909
- via,
910
- floor,
911
- position,
912
- count,
913
- refusal,
914
- onGoTo,
915
- labels,
916
- gates,
917
- dockOnPhones,
918
- onNext,
919
- onPrev,
920
- onSkip,
921
- }: {
922
- steps: TourStep[];
923
- index: number;
924
- via: TourStepContext["via"];
925
- floor: number;
926
- /** The app refused this step's save (§11.4). */
927
- refusal: Refusal | null;
928
- onGoTo: (index: number) => void;
929
- /** 1-based among the steps shown; Back is hidden on the first, Done on the last. */
930
- position: number;
931
- count: number;
932
- labels: TourLabels;
933
- gates: GateRegistry;
934
- dockOnPhones: boolean;
935
- onNext: () => void;
936
- onPrev: () => void;
937
- onSkip: () => void;
938
- }) {
939
- const step = steps[index];
940
- const isFirst = position <= 1;
941
- const isLast = position >= count;
942
- // A new step starts unlocated: whatever was found for another step (see `Located`)
943
- // is ignored, so the overlay renders nothing until the effect below has located THIS
944
- // step, and never the previous step's spotlight.
945
- const [located, setLocated] = useState<Located | null>(null);
946
- const current = located !== null && located.index === index && located.step === step ? located : null;
947
- const ready = current !== null;
948
- const rect = current?.rect ?? null;
949
- // The overlay is portalled to <body>, out of whatever `dir` subtree the app set, so it
950
- // takes the direction of the element it spotlights (the document's for a centered
951
- // step). Arrow keys and start/end placement read it.
952
- const dir: Direction = current?.dir ?? "ltr";
953
- const rootRef = useRef<HTMLDivElement>(null);
954
- const cardRef = useRef<HTMLDivElement>(null);
955
- const bodyId = useId();
956
- const hintId = useId();
957
-
958
- // The gate (§11.1). Re-rendered on every registry change while the tour runs.
959
- const gateVersion = useSyncExternalStore(gates.subscribe, gates.version, gates.version);
960
- const gateKey = step.gate;
961
- const enforced = !!gateKey && gates.has(gateKey);
962
- const locked = enforced && gates.get(gateKey) !== true;
963
-
964
- // The polite live region (§11.8): `gateReady` once a gate opens, the hint on a locked
965
- // Next. A repeat of the same words gets a trailing zero-width space so it is read again.
966
- const [polite, setPolite] = useState("");
967
- const announce = useCallback((text: string) => {
968
- setPolite((prev) => (prev === text ? `${text}\u200b` : text));
969
- }, []);
970
-
971
- // Run beforeStep, then locate the target (retrying across route/render lag).
972
- useEffect(() => {
973
- let cancelled = false;
974
- let raf = 0;
975
- // `null` = untargeted, or the finder gave up → the card centres, with no hole.
976
- const settle = (el: Element | null) => {
977
- let layer: HTMLElement | null = null;
978
- let fullScreen = false;
979
- if (el && isFieldStep(step)) {
980
- // §11.6: directly above the layer holding the field — DOM order decides between
981
- // the kit's z-50 body children, so this paints over the host and everything opened
982
- // before it, and under whatever the field opens next (a list, the number pad).
983
- const host = layerHost(el);
984
- layer = document.createElement("div");
985
- layer.setAttribute("data-tour-layer", "");
986
- if (host) host.after(layer);
987
- else document.body.appendChild(layer);
988
- fullScreen = !!host && coversViewport(host, el);
989
- }
990
- setLocated({ index, step, rect: el ? spotRectOf(el, step) : null, dir: dirOf(el), layer, fullScreen });
991
- };
992
- void (async () => {
993
- await step.beforeStep?.(stepContext(gates, via));
994
- if (cancelled) return;
995
- if (!step.target) {
996
- settle(null);
997
- return;
998
- }
999
- let tries = 0;
1000
- const find = () => {
1001
- if (cancelled) return;
1002
- const el = queryVisibleTarget(step.target!);
1003
- if (el) {
1004
- // A docked step scrolls the field into the half the card leaves free, through
1005
- // the field's own scroll container (§11.7); any other centres it, as ever.
1006
- if (docks(step, dockOnPhones)) scrollIntoFreeHalf(el, null, null);
1007
- else el.scrollIntoView({ block: "center", behavior: "smooth" });
1008
- settle(el);
1009
- return;
1010
- }
1011
- if (tries++ < 45) raf = requestAnimationFrame(find);
1012
- else settle(null); // give up → render centered
1013
- };
1014
- find();
1015
- })();
1016
- return () => {
1017
- cancelled = true;
1018
- cancelAnimationFrame(raf);
1019
- };
1020
- // `via` and the gates are read at arrival, not followed.
1021
- // eslint-disable-next-line react-hooks/exhaustive-deps
1022
- }, [index, step]);
1023
-
1024
- // Follow the target as the page scrolls / reflows — only once THIS step is located,
1025
- // and only into this step's result.
1026
- useEffect(() => {
1027
- if (!step.target) return;
1028
- const update = () => {
1029
- const el = queryVisibleTarget(step.target!);
1030
- if (el) {
1031
- const next = spotRectOf(el, step);
1032
- // A sheet that grows to full screen (or shrinks from it) takes or drops the scrim.
1033
- const host = layerHost(el);
1034
- const full = !!host && coversViewport(host, el);
1035
- setLocated((prev) => {
1036
- if (!prev || prev.index !== index || prev.step !== step) return prev;
1037
- const fullScreen = prev.layer ? full : prev.fullScreen;
1038
- if (sameRect(prev.rect, next) && fullScreen === prev.fullScreen) return prev;
1039
- return { ...prev, rect: next, fullScreen };
1040
- });
1041
- }
1042
- };
1043
- window.addEventListener("scroll", update, true);
1044
- window.addEventListener("resize", update);
1045
- const id = window.setInterval(update, 250);
1046
- return () => {
1047
- window.removeEventListener("scroll", update, true);
1048
- window.removeEventListener("resize", update);
1049
- clearInterval(id);
1050
- };
1051
- }, [index, step]);
1052
-
1053
- // A field step's container goes with the step (and with the tour).
1054
- const layer = located?.layer ?? null;
1055
- useEffect(() => {
1056
- if (!layer) return;
1057
- return () => layer.remove();
1058
- }, [layer]);
1059
-
1060
- // Escape (§11.6.4): the tour is a layer on the kit's Escape stack, pushed on each
1061
- // arrival, so it sits above the sheet holding the form. Escape from the card skips the
1062
- // tour and no longer also closes that sheet; a layer the field opens afterwards (a
1063
- // list, the pad) is above the tour and takes Escape first. An Escape pressed in the
1064
- // field itself belongs to the field: the tour lets it pass by doing nothing.
1065
- useDismissLayer(
1066
- ready,
1067
- (e) => {
1068
- if (fieldStepNow && step.target && e.target instanceof Node) {
1069
- const el = queryVisibleTarget(step.target);
1070
- if (el?.contains(e.target)) return;
1071
- }
1072
- onSkip();
1073
- },
1074
- // Not an overlay to `useOverlayOpen`: a floating launcher a tour spotlights stays.
1075
- { overlay: false },
1076
- );
1077
-
1078
- // awaitClick: advance when the *real* target is clicked. The spotlight hole is
1079
- // click-through (see the shields in the render below) so the element's own
1080
- // handler runs first; we step forward on the next macrotask.
1081
- //
1082
- // Re-armed when the target turns up after the finder gave up (the follow effect
1083
- // lights it late): the card swaps Next for the "click the highlighted element" hint
1084
- // as soon as there is a rect, so the click must work from that moment too.
1085
- const spotted = rect !== null;
1086
- useEffect(() => {
1087
- if (!ready || !spotted || !step.awaitClick || !step.target) return;
1088
- const el = queryVisibleTarget(step.target);
1089
- if (!el) return;
1090
- const onClick = () => window.setTimeout(() => onNext(), 0);
1091
- el.addEventListener("click", onClick, { once: true });
1092
- return () => el.removeEventListener("click", onClick);
1093
- }, [ready, spotted, index, step, onNext]);
1094
-
1095
- // A field step (see `TourStep.interactive`): only while the target is lit — a step
1096
- // whose target is missing centres its card over a full scrim, modal as ever.
1097
- const interactive =
1098
- spotted && !!step.target && !!(step.interactive || step.awaitInput || step.gate || step.awaitGate);
1099
- // A GUIDED field step (§11.8): focus goes to the field on a fine pointer, and Tab
1100
- // cycles field + card. A plain `interactive` step keeps the card's own trap.
1101
- const guided = interactive && !!(step.gate || step.awaitInput || step.awaitGate);
1102
- const fieldStepNow = interactive;
1103
- // An awaitGate step whose target is lit: only `release` moves it (a missing Save
1104
- // button would otherwise be a dead end, as for awaitClick).
1105
- const awaitsRelease = spotted && !!step.target && !!step.awaitGate;
1106
-
1107
- // A gate nobody publishes is not enforced: Next opens, and a development build says why
1108
- // (on arrival, or when its publisher unmounts under the step), once per step.
1109
- const warnedGateRef = useRef<TourStep | null>(null);
1110
- useEffect(() => {
1111
- if (!ready || !gateKey || gates.has(gateKey) || !devWarnings() || warnedGateRef.current === step) return;
1112
- warnedGateRef.current = step;
1113
- console.warn(
1114
- `[ui-kit] Tour step "${step.title}" waits for the gate "${gateKey}", which nothing publishes: its Next is open. ` +
1115
- "Publish it with useTourGate beside the field, or the form has closed under the tour.",
1116
- );
1117
- }, [ready, gateKey, gates, step, gateVersion]);
1118
-
1119
- // `optional` means "may stay EMPTY": without a gate there is no value to compare.
1120
- useEffect(() => {
1121
- if (!ready || !step.optional || step.gate || !devWarnings()) return;
1122
- console.warn(
1123
- `[ui-kit] Tour step "${step.title}" is \`optional\` without a \`gate\`: it shows the Optional chip ` +
1124
- 'and a plain Next. "Leave empty" needs a gate to compare.',
1125
- );
1126
- }, [ready, step]);
1127
-
1128
- // "Ready" once, when this step's gate turns satisfied (not when it arrives satisfied).
1129
- const wasLockedRef = useRef<{ step: TourStep; locked: boolean } | null>(null);
1130
- useEffect(() => {
1131
- if (!ready || !gateKey) return;
1132
- const before = wasLockedRef.current;
1133
- if (before && before.step === step && before.locked && !locked && enforced) announce(labels.gateReady);
1134
- wasLockedRef.current = { step, locked };
1135
- }, [ready, gateKey, step, locked, enforced, announce, labels.gateReady]);
1136
-
1137
- // Arrival on a guided step: the field takes focus on a fine pointer, the card on a
1138
- // coarse one; the field is described by the card's body while the step lasts.
1139
- // Declared BEFORE the advance listeners below, so the focus it moves is not mistaken
1140
- // for the person leaving the field.
1141
- useEffect(() => {
1142
- if (!ready || !guided || !step.target) return;
1143
- const el = queryVisibleTarget(step.target);
1144
- const control = el ? firstFocusable(el) : null;
1145
- // Described BEFORE it is focused, so a screen reader reads the step with the field's
1146
- // name. Focused quietly (0.50.1, keksdose B1): a picker that opens on focus stays
1147
- // closed, or its list would cover the card; ArrowDown, typing or a click opens it.
1148
- const previous = control ? control.getAttribute("aria-describedby") : null;
1149
- if (control) control.setAttribute("aria-describedby", previous ? `${previous} ${bodyId}` : bodyId);
1150
- if (coarsePointer() || !control) cardRef.current?.focus();
1151
- else if (!el!.contains(document.activeElement)) focusQuietly(control);
1152
- if (!control) return;
1153
- return () => {
1154
- if (previous === null) control.removeAttribute("aria-describedby");
1155
- else control.setAttribute("aria-describedby", previous);
1156
- };
1157
- }, [ready, guided, index, step, bodyId]);
1158
-
1159
- // Tab on a guided step cycles field + card as one ring (§11.8): from the field's last
1160
- // stop to the card's first, from the card's last back to the field. Captured on the
1161
- // document, ahead of a sheet's own trap, which would wrap inside the sheet.
1162
- useEffect(() => {
1163
- if (!ready || !guided || !step.target) return;
1164
- const onTab = (e: KeyboardEvent) => {
1165
- if (e.key !== "Tab") return;
1166
- const el = queryVisibleTarget(step.target!);
1167
- const card = cardRef.current;
1168
- if (!el || !card) return;
1169
- const active = document.activeElement;
1170
- const fieldStops = tabStops(el);
1171
- const cardStops = tabStops(card);
1172
- if (fieldStops.length === 0 || cardStops.length === 0) return;
1173
- let to: HTMLElement | null = null;
1174
- if (active instanceof Node && el.contains(active)) {
1175
- if (!e.shiftKey && active === fieldStops[fieldStops.length - 1]) to = cardStops[0];
1176
- else if (e.shiftKey && active === fieldStops[0]) to = cardStops[cardStops.length - 1];
1177
- } else if (active instanceof Node && card.contains(active)) {
1178
- if (!e.shiftKey && active === cardStops[cardStops.length - 1]) to = fieldStops[0];
1179
- else if (e.shiftKey && (active === cardStops[0] || active === card)) to = fieldStops[fieldStops.length - 1];
1180
- }
1181
- if (!to) return;
1182
- e.preventDefault();
1183
- e.stopPropagation();
1184
- to.focus();
1185
- };
1186
- document.addEventListener("keydown", onTab, true);
1187
- return () => document.removeEventListener("keydown", onTab, true);
1188
- }, [ready, guided, index, step]);
1189
-
1190
- // gate: once satisfied, advance on Enter in the field (unless the control took it, or
1191
- // a textarea without Ctrl/Cmd) or on focus leaving the field to nowhere or to the card.
1192
- // Checked on the next macrotask, after the field's own blur/Enter commit has rendered.
1193
- useEffect(() => {
1194
- if (!ready || !spotted || !gateKey || !step.target) return;
1195
- const el = queryVisibleTarget(step.target) as HTMLElement | null;
1196
- if (!el) return;
1197
- const satisfied = () => !gates.has(gateKey) || gates.get(gateKey) === true;
1198
- let timer = 0;
1199
- // Focus that was in the field when the step settled, or went there since. A focus
1200
- // move the tour made itself (the card taking it on a phone) is not a leave.
1201
- let armed = el.contains(document.activeElement);
1202
- const check = () => {
1203
- window.clearTimeout(timer);
1204
- timer = window.setTimeout(() => {
1205
- if (satisfied()) onNext();
1206
- }, 0);
1207
- };
1208
- const onFocusIn = () => {
1209
- armed = true;
1210
- };
1211
- const onFocusOut = (e: FocusEvent) => {
1212
- const to = e.relatedTarget;
1213
- if (to instanceof Node && el.contains(to)) return;
1214
- const wasArmed = armed;
1215
- armed = false;
1216
- if (!wasArmed) return;
1217
- if (to === null || (to instanceof Node && rootRef.current?.contains(to))) check();
1218
- };
1219
- const onKeyDown = (e: KeyboardEvent) => {
1220
- if (e.key !== "Enter" || !(e.target instanceof Node) || !el.contains(e.target)) return;
1221
- // Heard at the document, after React's handlers: a combobox picking an option has
1222
- // called preventDefault by now.
1223
- if (e.defaultPrevented || isComposing(e)) return;
1224
- if (e.target instanceof HTMLTextAreaElement && !(e.ctrlKey || e.metaKey)) return;
1225
- check();
1226
- };
1227
- el.addEventListener("focusin", onFocusIn);
1228
- el.addEventListener("focusout", onFocusOut);
1229
- document.addEventListener("keydown", onKeyDown);
1230
- return () => {
1231
- window.clearTimeout(timer);
1232
- el.removeEventListener("focusin", onFocusIn);
1233
- el.removeEventListener("focusout", onFocusOut);
1234
- document.removeEventListener("keydown", onKeyDown);
1235
- };
1236
- }, [ready, spotted, gateKey, gates, index, step, onNext]);
1237
-
1238
- // awaitInput: advance once the target's fields hold another value than when the step
1239
- // was armed, checked when focus leaves the target or Enter is pressed in it — on the
1240
- // next macrotask, after the field's own blur/Enter commit has rendered. A value the
1241
- // number pad typed fires no native `change`, so comparing is what catches it.
1242
- useEffect(() => {
1243
- if (!ready || !spotted || !step.awaitInput || !step.target) return;
1244
- const el = queryVisibleTarget(step.target) as HTMLElement | null;
1245
- if (!el) return;
1246
- const read = () => fieldValues(el);
1247
- const before = read();
1248
- let timer = 0;
1249
- let done = false;
1250
- const check = () => {
1251
- window.clearTimeout(timer);
1252
- timer = window.setTimeout(() => {
1253
- if (done || read() === before) return;
1254
- done = true;
1255
- onNext();
1256
- }, 0);
1257
- };
1258
- const onFocusOut = (e: FocusEvent) => {
1259
- if (e.relatedTarget instanceof Node && el.contains(e.relatedTarget)) return;
1260
- check();
1261
- };
1262
- const onKeyDown = (e: KeyboardEvent) => {
1263
- if (e.key === "Enter") check();
1264
- };
1265
- el.addEventListener("focusout", onFocusOut);
1266
- el.addEventListener("keydown", onKeyDown);
1267
- el.addEventListener("change", check);
1268
- return () => {
1269
- window.clearTimeout(timer);
1270
- el.removeEventListener("focusout", onFocusOut);
1271
- el.removeEventListener("keydown", onKeyDown);
1272
- el.removeEventListener("change", check);
1273
- };
1274
- }, [ready, spotted, index, step, onNext]);
1275
-
1276
- /** A press on the locked Next (or Enter / → from the card): no move; the field takes
1277
- * focus and the hint is read again. */
1278
- const gateHint = step.gateHint ?? labels.gateHint;
1279
- const lockedNext = useCallback(() => {
1280
- const el = step.target ? queryVisibleTarget(step.target) : null;
1281
- const control = el ? firstFocusable(el) : null;
1282
- // Quietly, as on arrival: the hint is read with the card in view, not under a list.
1283
- if (control) focusQuietly(control);
1284
- announce(gateHint);
1285
- }, [step.target, announce, gateHint]);
1286
- const tryNext = awaitsRelease ? NOOP : locked ? lockedNext : onNext;
1287
-
1288
- // After a refused save: the first earlier step shown whose field is now empty (§11.4).
1289
- // Computed each render, which the gate subscription above triggers: a field filled
1290
- // again drops the link.
1291
- const backTo = refusal ? firstEmptied(steps, floor, index, gates) : -1;
1292
-
1293
- // Keyboard: Esc skips, Enter and the reading-direction arrow advance (→ in LTR,
1294
- // ← in RTL), the other arrow goes back. On awaitClick steps Enter is ignored (it
1295
- // would fire the target's click AND advance) — the forward arrow stays as an escape
1296
- // hatch. On a locked gate step both are the locked Next.
1297
- //
1298
- // Enter on a focused control belongs to that control. This used to advance from
1299
- // anywhere, so Enter on a focused Skip or Back ran the button's own click AND stepped
1300
- // forward: Back moved nowhere, Skip skipped and then called `next` on a dead tour.
1301
- // The same goes for arrows in a text field a step's `action` might contain.
1302
- useEffect(() => {
1303
- const onKey = (e: KeyboardEvent) => {
1304
- // On an interactive step a key pressed in the target, or in a layer it opened (the
1305
- // number pad's Escape, a menu's arrows), is the page's. The card's and the bare
1306
- // page's (focus on <body>) stay the tour's.
1307
- if (
1308
- interactive &&
1309
- e.target instanceof Node &&
1310
- e.target !== document.body &&
1311
- !rootRef.current?.contains(e.target)
1312
- ) {
1313
- return;
1314
- }
1315
- // Escape is the tour's Escape layer's (above) once the step is shown; while it is
1316
- // still being located there is no layer yet, and the tour takes it here as in 0.49.
1317
- if (e.key === "Escape") {
1318
- if (!ready) onSkip();
1319
- return;
1320
- }
1321
- if (e.key === "Enter") {
1322
- if (step.awaitClick || step.awaitInput || ownsKey(e.target, "Enter")) return;
1323
- e.preventDefault();
1324
- tryNext();
1325
- return;
1326
- }
1327
- if (ownsKey(e.target, e.key)) return;
1328
- // The overlay root carries `dir`; before it paints, the document's answers.
1329
- const delta = horizontalStep(e.key, rootRef.current);
1330
- if (delta === 1) {
1331
- e.preventDefault();
1332
- tryNext();
1333
- } else if (delta === -1) {
1334
- if (!isFirst) onPrev();
1335
- }
1336
- };
1337
- document.addEventListener("keydown", onKey);
1338
- return () => document.removeEventListener("keydown", onKey);
1339
- }, [isFirst, step, interactive, tryNext, onPrev, onSkip, ready]);
1340
-
1341
- if (!ready) return null;
1342
-
1343
- // No scrim, no shields: a field step inside a layer that fills the screen (§11.6.3).
1344
- const bare = interactive && !!current?.fullScreen;
1345
- const pad = step.padding ?? 8;
1346
- const spot: Rect | null = rect
1347
- ? { top: rect.top - pad, left: rect.left - pad, width: rect.width + pad * 2, height: rect.height + pad * 2 }
1348
- : null;
1349
-
1350
- // `aria-modal` promises the page behind is out of reach, and the card's focus trap
1351
- // keeps that promise for the keyboard. The pointer used to get no such treatment: the
1352
- // root is `pointer-events-none` so that the spotlight hole can stay live for
1353
- // `awaitClick`, and the scrim is a box-shadow, which takes no clicks — so every
1354
- // control on the dimmed page stayed clickable. Four shields now tile the viewport
1355
- // around the hole: the page is blocked, the card and the spotlighted target are not.
1356
- // Keeping `aria-modal` (rather than dropping it) is the coherent half: the tour
1357
- // really is modal — focus is trapped and Esc/Skip is the way out.
1358
- return createPortal(
1359
- <div
1360
- ref={rootRef}
1361
- // z-50 on a field step, in its own container right after the layer holding the field
1362
- // (or at the end of <body>): over that layer and the page, under the z-50 layers the
1363
- // field opens next (§11.6). z-[60] on a plain step, over everything.
1364
- className={cn("pointer-events-none fixed inset-0", interactive ? "z-50" : "z-[60]")}
1365
- role="dialog"
1366
- aria-modal={interactive ? undefined : "true"}
1367
- // A stable marker for the overlay, on every step (0.48, keksdose dev#611–613): an
1368
- // app that hides its floating help launcher while a modal is open excepts the
1369
- // tour, which may spotlight that launcher — `[aria-modal="true"]:not([data-tour-overlay])`.
1370
- // keksdose matched the `pointer-events-none` class until now, which is the kit's to change.
1371
- data-tour-overlay=""
1372
- data-tour-interactive={interactive ? "" : undefined}
1373
- data-tour-bare={bare ? "" : undefined}
1374
- aria-label={step.title}
1375
- dir={dir}
1376
- >
1377
- {/* In a full-screen layer (a phone's form sheet) no scrim and no shields: the rest of
1378
- the form stays usable and scrollable, and the ring alone marks the field. */}
1379
- {spot && !bare && <SpotlightShields spot={spot} />}
1380
- {spot ? (
1381
- <div
1382
- className="pointer-events-none fixed rounded-lg transition-all duration-200 ease-out"
1383
- style={{
1384
- top: spot.top,
1385
- left: spot.left,
1386
- width: spot.width,
1387
- height: spot.height,
1388
- // A two-tone frame, not a single translucent ring.
1389
- //
1390
- // The old treatment was `ring-2 ring-white/80` over a 55% scrim, and it
1391
- // "was barely visible" on the app's blue-tinted surfaces. Two reasons,
1392
- // and a single ring can't fix either: at 55% the surround stays bright
1393
- // enough that the un-dimmed hole barely reads AS a hole, and a 80%-white
1394
- // ring sitting on the edge of a light card is white-on-near-white.
1395
- //
1396
- // So: an opaque white band immediately around the target, a dark keyline
1397
- // outside it, then the scrim. Whatever the target's own colour is, one of
1398
- // the two bands is always in contrast with it and the other is always in
1399
- // contrast with the dimmed surround — there is no background that can
1400
- // swallow both. The blurred layer between them softens the step so the
1401
- // frame reads as lighting rather than as a pasted-on rectangle.
1402
- boxShadow: [
1403
- "0 0 0 3px rgba(255,255,255,0.98)",
1404
- "0 0 0 5px rgba(15,23,42,0.92)",
1405
- "0 0 18px 6px rgba(15,23,42,0.45)",
1406
- ...(bare ? [] : ["0 0 0 9999px rgba(15,23,42,0.70)"]),
1407
- ].join(", "),
1408
- }}
1409
- />
1410
- ) : (
1411
- <div className="pointer-events-auto fixed inset-0 bg-black/70" />
1412
- )}
1413
- <TourCard
1414
- cardRef={cardRef}
1415
- step={step}
1416
- index={index}
1417
- position={position}
1418
- total={count}
1419
- labels={labels}
1420
- isFirst={isFirst}
1421
- isLast={isLast}
1422
- rect={spot}
1423
- dir={dir}
1424
- trap={!guided}
1425
- bodyId={bodyId}
1426
- hintId={hintId}
1427
- locked={locked}
1428
- gateHint={gateHint}
1429
- onBack={onPrev}
1430
- onNext={tryNext}
1431
- onLeaveEmpty={onNext}
1432
- onSkip={onSkip}
1433
- awaitsRelease={awaitsRelease}
1434
- docked={spot !== null && docks(step, dockOnPhones)}
1435
- refusal={refusal}
1436
- backTo={backTo >= 0 ? { title: steps[backTo].title, go: () => onGoTo(backTo) } : null}
1437
- />
1438
- <div className="sr-only" aria-live="polite" aria-atomic="true">
1439
- {polite}
1440
- </div>
1441
- </div>,
1442
- (interactive && current?.layer) || document.body,
1443
- );
1444
- }
1445
-
1446
- /** The values of the fields at or inside `el`, as one string to compare (`awaitInput`). */
1447
- function fieldValues(el: Element): string {
1448
- const fields = el.matches("input,textarea,select") ? [el] : Array.from(el.querySelectorAll("input,textarea,select"));
1449
- return fields
1450
- .map((f) =>
1451
- f instanceof HTMLInputElement && (f.type === "checkbox" || f.type === "radio")
1452
- ? String(f.checked)
1453
- : (f as HTMLInputElement).value,
1454
- )
1455
- .join("\u0000");
1456
- }
1457
-
1458
- /** Does the focused element handle `key` itself? Enter on a button or link, and any
1459
- * editing key in a text field or select, is the control's — not the tour's. */
1460
- function ownsKey(target: EventTarget | null, key: string): boolean {
1461
- if (!(target instanceof HTMLElement)) return false;
1462
- if (target.isContentEditable) return true;
1463
- const tag = target.tagName;
1464
- if (tag === "TEXTAREA" || tag === "SELECT") return true;
1465
- if (tag === "INPUT") {
1466
- const type = (target as HTMLInputElement).type;
1467
- // Enter on a checkbox does nothing natively, but ←/→ on a radio moves it.
1468
- return key !== "Enter" || type !== "checkbox";
1469
- }
1470
- if (key !== "Enter") return false;
1471
- return (
1472
- tag === "BUTTON" ||
1473
- (tag === "A" && target.hasAttribute("href")) ||
1474
- target.getAttribute("role") === "button" ||
1475
- target.getAttribute("role") === "link"
1476
- );
1477
- }
1478
-
1479
- /**
1480
- * Transparent pointer blockers tiling the viewport around the spotlight hole: one
1481
- * full-width band above and below, one on each side at the hole's own height. The hole
1482
- * itself stays uncovered, so the target keeps its clicks.
1483
- */
1484
- function SpotlightShields({ spot }: { spot: Rect }) {
1485
- const shield = "pointer-events-auto fixed";
1486
- const bottom = spot.top + spot.height;
1487
- return (
1488
- <>
1489
- <div
1490
- data-tour-shield=""
1491
- className={shield}
1492
- style={{ top: 0, left: 0, right: 0, height: Math.max(0, spot.top) }}
1493
- />
1494
- <div data-tour-shield="" className={shield} style={{ top: bottom, left: 0, right: 0, bottom: 0 }} />
1495
- <div
1496
- data-tour-shield=""
1497
- className={shield}
1498
- style={{ top: spot.top, left: 0, width: Math.max(0, spot.left), height: spot.height }}
1499
- />
1500
- <div
1501
- data-tour-shield=""
1502
- className={shield}
1503
- style={{ top: spot.top, left: spot.left + spot.width, right: 0, height: spot.height }}
1504
- />
1505
- </>
1506
- );
1507
- }
1508
-
1509
- /**
1510
- * Card position (viewport px) for the given placement relative to the padded
1511
- * spotlight `rect`. Omitted placement keeps the original auto behavior
1512
- * (below → above → vertically centered); an explicit side flips to its opposite
1513
- * if it would overflow, then clamps into the viewport. "center" (or no rect)
1514
- * centers on screen.
1515
- */
1516
- function placeCard(
1517
- rect: Rect | null,
1518
- cw: number,
1519
- ch: number,
1520
- vw: number,
1521
- vh: number,
1522
- m: number,
1523
- placement?: TourPlacement,
1524
- dir: Direction = "ltr",
1525
- ): { top: number; left: number } {
1526
- // The logical sides resolve to a physical one here, and only here.
1527
- if (placement === "start") placement = dir === "rtl" ? "right" : "left";
1528
- else if (placement === "end") placement = dir === "rtl" ? "left" : "right";
1529
- if (!rect || placement === "center") {
1530
- return { top: Math.max(m, (vh - ch) / 2), left: Math.max(m, (vw - cw) / 2) };
1531
- }
1532
- const clampX = (x: number) => Math.min(Math.max(m, x), Math.max(m, vw - cw - m));
1533
- const clampY = (y: number) => Math.min(Math.max(m, y), Math.max(m, vh - ch - m));
1534
- const centerX = clampX(rect.left + rect.width / 2 - cw / 2);
1535
- const centerY = clampY(rect.top + rect.height / 2 - ch / 2);
1536
- const belowTop = rect.top + rect.height + m;
1537
- const aboveTop = rect.top - ch - m;
1538
- const rightLeft = rect.left + rect.width + m;
1539
- const leftLeft = rect.left - cw - m;
1540
- const fitsBelow = belowTop + ch <= vh;
1541
- const fitsAbove = aboveTop >= 0;
1542
- const fitsRight = rightLeft + cw <= vw;
1543
- const fitsLeft = leftLeft >= 0;
1544
-
1545
- switch (placement) {
1546
- case "top":
1547
- return { top: fitsAbove ? aboveTop : fitsBelow ? belowTop : clampY(aboveTop), left: centerX };
1548
- case "bottom":
1549
- return { top: fitsBelow ? belowTop : fitsAbove ? aboveTop : clampY(belowTop), left: centerX };
1550
- case "right":
1551
- return { top: centerY, left: fitsRight ? rightLeft : fitsLeft ? leftLeft : clampX(rightLeft) };
1552
- case "left":
1553
- return { top: centerY, left: fitsLeft ? leftLeft : fitsRight ? rightLeft : clampX(leftLeft) };
1554
- default:
1555
- if (fitsBelow) return { top: belowTop, left: centerX };
1556
- if (fitsAbove) return { top: aboveTop, left: centerX };
1557
- return { top: Math.max(m, (vh - ch) / 2), left: centerX };
1558
- }
1559
- }
1560
-
1561
- function TourCard({
1562
- cardRef: ref,
1563
- step,
1564
- index,
1565
- position,
1566
- total,
1567
- labels,
1568
- isFirst,
1569
- isLast,
1570
- rect,
1571
- dir,
1572
- trap,
1573
- bodyId,
1574
- hintId,
1575
- locked,
1576
- gateHint,
1577
- onBack,
1578
- onNext,
1579
- onLeaveEmpty,
1580
- onSkip,
1581
- awaitsRelease,
1582
- docked,
1583
- refusal,
1584
- backTo,
1585
- }: {
1586
- cardRef: RefObject<HTMLDivElement | null>;
1587
- step: TourStep;
1588
- index: number;
1589
- /** 1-based among the steps shown (§11.3). */
1590
- position: number;
1591
- /** How many steps the run shows. */
1592
- total: number;
1593
- labels: TourLabels;
1594
- isFirst: boolean;
1595
- isLast: boolean;
1596
- rect: Rect | null;
1597
- dir: Direction;
1598
- /** The card's own focus trap; off on a guided step, where field + card are one ring. */
1599
- trap: boolean;
1600
- bodyId: string;
1601
- hintId: string;
1602
- /** A gate step whose field is not filled yet (§11.1). */
1603
- locked: boolean;
1604
- gateHint: string;
1605
- onBack: () => void;
1606
- onNext: () => void;
1607
- /** Moves on past an `optional` field left empty. */
1608
- onLeaveEmpty: () => void;
1609
- onSkip: () => void;
1610
- /** An awaitGate step with its target lit: the hint in place of Next. */
1611
- awaitsRelease: boolean;
1612
- /** Pinned to the band's edge away from the field (§11.7). */
1613
- docked: boolean;
1614
- refusal: Refusal | null;
1615
- /** The "Back to …" link after a refused save. */
1616
- backTo: { title: string; go: () => void } | null;
1617
- }) {
1618
- const [style, setStyle] = useState<CSSProperties>({ opacity: 0 });
1619
-
1620
- /**
1621
- * The card holds the focus, because the card is what the tour IS.
1622
- *
1623
- * The overlay above declares `role="dialog" aria-modal="true"` — it always has — and
1624
- * then left focus wherever the page had put it. For a tour that is the most pointed
1625
- * version of the audit's *"Only Modal manages focus"*: the whole component exists to
1626
- * say "look here", and for a keyboard user "here" is the focus ring. They were told
1627
- * the page was hidden, given no way to reach the Next button without Tabbing through
1628
- * it, and left on a control the screen reader would no longer describe.
1629
- *
1630
- * It re-engages on every step, without any bookkeeping here, because `TourOverlay`
1631
- * returns null while it re-locates the next target: the card genuinely unmounts and
1632
- * remounts between steps. That is what keeps focus honest when the BUTTONS change —
1633
- * "Back" does not exist on the first step, so stepping back onto it destroys the
1634
- * control the press came from, and focus would otherwise fall to `<body>`, outside
1635
- * this trap's own listener, where Tab walks straight into the page the overlay claims
1636
- * to have hidden.
1637
- *
1638
- * **The cost, written down:** on an `awaitClick` step the user is asked to click the
1639
- * spotlighted element, and they can no longer Tab to it. ArrowRight still advances
1640
- * (the key handler in `TourOverlay` is on the document and does not care where focus
1641
- * is), which is the escape hatch that step already documents for the case where the
1642
- * target cannot be found. Containment is worth that: an `awaitClick` step is a
1643
- * minority of steps, while focus stranded behind `aria-modal` is every step.
1644
- *
1645
- * A guided field step (`gate`, `awaitInput`, 0.50) is the exception: the field is
1646
- * what the step is about, so the overlay focuses it (or the card, on a touch screen)
1647
- * and runs one Tab ring over field + card itself.
1648
- */
1649
- useFocusTrap(ref, { active: trap });
1650
-
1651
- // Docked (§11.7): the edge it last took, for the hysteresis, and a tick bumped when the
1652
- // band moves under an unmoved field (a pad or keyboard opening).
1653
- const edgeRef = useRef<DockEdge | null>(null);
1654
- const [bandTick, setBandTick] = useState(0);
1655
- const [edge, setEdge] = useState<DockEdge | null>(null);
1656
- useEffect(() => {
1657
- if (!docked) return;
1658
- let last = "";
1659
- const look = () => {
1660
- const target = step.target ? queryVisibleTarget(step.target) : null;
1661
- const band = readBand(target, ref.current);
1662
- const key = `${band.top}:${band.bottom}`;
1663
- if (key === last) return;
1664
- last = key;
1665
- // A field the pad or keyboard now covers is brought back into the free half.
1666
- if (target) {
1667
- const r = target.getBoundingClientRect();
1668
- if (r.top < band.top || r.bottom > band.bottom) {
1669
- edgeRef.current = scrollIntoFreeHalf(target, ref.current, edgeRef.current);
1670
- }
1671
- }
1672
- setBandTick((t) => t + 1);
1673
- };
1674
- const vv = window.visualViewport;
1675
- vv?.addEventListener("resize", look);
1676
- vv?.addEventListener("scroll", look);
1677
- window.addEventListener("resize", look);
1678
- // The follow tick's cadence: it catches a pad opening, which moves nothing.
1679
- const id = window.setInterval(look, 250);
1680
- return () => {
1681
- vv?.removeEventListener("resize", look);
1682
- vv?.removeEventListener("scroll", look);
1683
- window.removeEventListener("resize", look);
1684
- clearInterval(id);
1685
- };
1686
- }, [docked, step.target, ref]);
1687
-
1688
- useLayoutEffect(() => {
1689
- const card = ref.current;
1690
- if (!card) return;
1691
- if (docked) {
1692
- const target = step.target ? queryVisibleTarget(step.target) : null;
1693
- const band = readBand(target, card);
1694
- const next = rect ? dockEdge(rect, band, edgeRef.current, card.offsetHeight) : "bottom";
1695
- edgeRef.current = next;
1696
- setEdge(next);
1697
- setStyle(dockStyle(next, rect, band));
1698
- return;
1699
- }
1700
- setEdge(null);
1701
- setStyle(
1702
- placeCard(
1703
- rect,
1704
- card.offsetWidth,
1705
- card.offsetHeight,
1706
- window.innerWidth,
1707
- window.innerHeight,
1708
- 12,
1709
- step.placement,
1710
- dir,
1711
- ),
1712
- );
1713
- }, [ref, rect, index, step.placement, step.target, dir, docked, bandTick]);
1714
-
1715
- const awaitsTarget = ((step.awaitClick || step.awaitInput) && step.target && rect) || awaitsRelease;
1716
-
1717
- return (
1718
- <div
1719
- ref={ref}
1720
- // Focusable but not tabbable: the trap above focuses the card itself rather than
1721
- // its first button, so a screen reader reads the step's title and body before it
1722
- // reads "Next" — and without this the container cannot take focus at all and the
1723
- // trap silently does nothing.
1724
- tabIndex={-1}
1725
- style={style}
1726
- data-tour-card=""
1727
- data-tour-docked={edge ?? undefined}
1728
- className={cn(
1729
- "pointer-events-auto fixed z-[61] w-80 max-w-[calc(100vw-1.5rem)] rounded-lg border border-subtle bg-surface p-4 shadow-xl outline-none transition-all duration-200 ease-out",
1730
- // Docked, the height is capped: the body scrolls, the title and buttons stay.
1731
- docked && "flex flex-col",
1732
- )}
1733
- >
1734
- <div className="flex flex-wrap items-center gap-x-2 gap-y-1 text-sm font-semibold text-primary">
1735
- <span>{step.title}</span>
1736
- {step.optional && (
1737
- <span className="rounded-full border border-subtle px-1.5 py-px text-xs font-normal text-muted">
1738
- {labels.optional}
1739
- </span>
1740
- )}
1741
- </div>
1742
- <div
1743
- id={bodyId}
1744
- className={cn("mt-1 text-sm leading-relaxed text-secondary", docked && "min-h-0 shrink overflow-y-auto")}
1745
- >
1746
- {step.body}
1747
- </div>
1748
- {step.action && <div className="mt-3">{step.action}</div>}
1749
- <div className="mt-4 space-y-2">
1750
- <div className="flex items-center justify-between gap-2">
1751
- <button type="button" onClick={onSkip} className="text-xs text-placeholder hover:text-secondary">
1752
- {labels.skip}
1753
- </button>
1754
- <div className="flex items-center gap-2">
1755
- <span className="whitespace-nowrap text-xs tabular-nums text-placeholder">
1756
- {labels.step(position, total)}
1757
- </span>
1758
- {!isFirst && (
1759
- <Button variant="secondary" onClick={onBack} className="px-2.5 py-1 text-xs">
1760
- {labels.back}
1761
- </Button>
1762
- )}
1763
- {/* On an awaitClick step the Next button is replaced by a hint on its
1764
- own row below, so it doesn't cram the counter + buttons and wrap.
1765
- Only when the target was actually FOUND, though — `rect` is null
1766
- when the finder gave up, and the click listener early-returns on
1767
- the same absence. Keyed on `step.target` alone this hid the only
1768
- way forward on any step whose anchor happens not to be rendered
1769
- for this user (a guest sees no "add account" button), leaving the
1770
- undocumented ArrowRight key as the sole escape. */}
1771
- {/* "Leave empty" (§11.2): an optional field may stay empty, so the step can
1772
- move on without it. Gone once the field is filled. */}
1773
- {step.optional && locked && !awaitsTarget && (
1774
- <Button variant="secondary" onClick={onLeaveEmpty} className="px-2.5 py-1 text-xs">
1775
- {labels.leaveEmpty}
1776
- </Button>
1777
- )}
1778
- {!awaitsTarget && (
1779
- <Button
1780
- variant="accent"
1781
- onClick={onNext}
1782
- // Locked, not disabled (§11.1): it stays focusable, and a press focuses the
1783
- // field and reads the hint again.
1784
- aria-disabled={locked || undefined}
1785
- aria-describedby={locked ? hintId : undefined}
1786
- className={cn("px-2.5 py-1 text-xs", locked && "opacity-60")}
1787
- >
1788
- {isLast ? labels.done : labels.next}
1789
- </Button>
1790
- )}
1791
- </div>
1792
- </div>
1793
- {awaitsTarget && (
1794
- <div className="text-center text-xs italic text-placeholder">
1795
- {awaitsRelease
1796
- ? (step.awaitGateHint ?? labels.awaitGateHint)
1797
- : step.awaitInput && !step.awaitClick
1798
- ? labels.awaitInputHint
1799
- : labels.awaitClickHint}
1800
- </div>
1801
- )}
1802
- {/* Always mounted on an awaitGate step, so a refusal is read out (assertively)
1803
- the moment it lands. */}
1804
- {awaitsRelease && (
1805
- <div aria-live="assertive" aria-atomic="true" className="space-y-1">
1806
- {refusal && (
1807
- <p data-tour-refused="" className="text-xs text-danger">
1808
- {refusal.reason ?? labels.awaitGateRefused}
1809
- {refusal.seq % 2 === 0 ? "\u200b" : ""}
1810
- </p>
1811
- )}
1812
- {refusal && backTo && (
1813
- <Button variant="link" onClick={backTo.go} className="text-xs">
1814
- {labels.backToStep(backTo.title)}
1815
- </Button>
1816
- )}
1817
- </div>
1818
- )}
1819
- {locked && !awaitsTarget && (
1820
- <div id={hintId} className="text-center text-xs italic text-placeholder">
1821
- {gateHint}
1822
- </div>
1823
- )}
1824
- </div>
1825
- </div>
1826
- );
1827
- }