@eifi1/ui-kit 0.4.1 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (414) hide show
  1. package/LICENSE +32 -0
  2. package/README.md +498 -57
  3. package/dist/chart.d.ts +10 -0
  4. package/dist/chart.js +10 -0
  5. package/dist/chart.js.map +1 -0
  6. package/dist/components/account-settings.d.ts +11 -0
  7. package/dist/components/account-settings.js +19 -12
  8. package/dist/components/account-settings.js.map +1 -1
  9. package/dist/components/alert-banner.d.ts +10 -6
  10. package/dist/components/alert-banner.js +20 -16
  11. package/dist/components/alert-banner.js.map +1 -1
  12. package/dist/components/amount-input.d.ts +30 -4
  13. package/dist/components/amount-input.js +36 -14
  14. package/dist/components/amount-input.js.map +1 -1
  15. package/dist/components/calculator.d.ts +24 -7
  16. package/dist/components/calculator.js +37 -20
  17. package/dist/components/calculator.js.map +1 -1
  18. package/dist/components/chart-zoom.d.ts +156 -0
  19. package/dist/components/chart-zoom.js +262 -0
  20. package/dist/components/chart-zoom.js.map +1 -0
  21. package/dist/components/chart.d.ts +28 -3
  22. package/dist/components/chart.js +71 -32
  23. package/dist/components/chart.js.map +1 -1
  24. package/dist/components/checkbox.d.ts +51 -0
  25. package/dist/components/checkbox.js +123 -0
  26. package/dist/components/checkbox.js.map +1 -0
  27. package/dist/components/chip.d.ts +142 -0
  28. package/dist/components/chip.js +357 -0
  29. package/dist/components/chip.js.map +1 -0
  30. package/dist/components/choice-parts.d.ts +24 -0
  31. package/dist/components/choice-parts.js +18 -0
  32. package/dist/components/choice-parts.js.map +1 -0
  33. package/dist/components/combobox-core.d.ts +52 -9
  34. package/dist/components/combobox-core.js +89 -19
  35. package/dist/components/combobox-core.js.map +1 -1
  36. package/dist/components/combobox.d.ts +43 -33
  37. package/dist/components/combobox.js +409 -340
  38. package/dist/components/combobox.js.map +1 -1
  39. package/dist/components/currency-select.d.ts +48 -8
  40. package/dist/components/currency-select.js +115 -65
  41. package/dist/components/currency-select.js.map +1 -1
  42. package/dist/components/data-table-filter-popover.d.ts +15 -3
  43. package/dist/components/data-table-filter-popover.js +23 -17
  44. package/dist/components/data-table-filter-popover.js.map +1 -1
  45. package/dist/components/data-table-filters.d.ts +1 -1
  46. package/dist/components/data-table-filters.js +3 -2
  47. package/dist/components/data-table-filters.js.map +1 -1
  48. package/dist/components/data-table-labels.d.ts +53 -2
  49. package/dist/components/data-table-labels.js +31 -2
  50. package/dist/components/data-table-labels.js.map +1 -1
  51. package/dist/components/data-table-pagination.d.ts +3 -1
  52. package/dist/components/data-table-pagination.js +16 -10
  53. package/dist/components/data-table-pagination.js.map +1 -1
  54. package/dist/components/data-table-sort.js +1 -0
  55. package/dist/components/data-table-sort.js.map +1 -1
  56. package/dist/components/data-table.d.ts +1 -1
  57. package/dist/components/data-table.js +201 -85
  58. package/dist/components/data-table.js.map +1 -1
  59. package/dist/components/date-picker.d.ts +25 -9
  60. package/dist/components/date-picker.js +244 -94
  61. package/dist/components/date-picker.js.map +1 -1
  62. package/dist/components/dropdown.d.ts +74 -19
  63. package/dist/components/dropdown.js +72 -22
  64. package/dist/components/dropdown.js.map +1 -1
  65. package/dist/components/entity-combobox.d.ts +5 -4
  66. package/dist/components/entity-combobox.js +107 -76
  67. package/dist/components/entity-combobox.js.map +1 -1
  68. package/dist/components/facing-pair.d.ts +36 -0
  69. package/dist/components/facing-pair.js +40 -0
  70. package/dist/components/facing-pair.js.map +1 -0
  71. package/dist/components/field-sync.d.ts +164 -0
  72. package/dist/components/field-sync.js +264 -0
  73. package/dist/components/field-sync.js.map +1 -0
  74. package/dist/components/file-dropzone.d.ts +21 -7
  75. package/dist/components/file-dropzone.js +28 -7
  76. package/dist/components/file-dropzone.js.map +1 -1
  77. package/dist/components/full-bleed-dialog.d.ts +37 -26
  78. package/dist/components/full-bleed-dialog.js +20 -5
  79. package/dist/components/full-bleed-dialog.js.map +1 -1
  80. package/dist/components/grouped-picker.d.ts +21 -10
  81. package/dist/components/grouped-picker.js +66 -52
  82. package/dist/components/grouped-picker.js.map +1 -1
  83. package/dist/components/hover-menu.d.ts +20 -4
  84. package/dist/components/hover-menu.js +15 -4
  85. package/dist/components/hover-menu.js.map +1 -1
  86. package/dist/components/mini-calendar.d.ts +102 -14
  87. package/dist/components/mini-calendar.js +256 -70
  88. package/dist/components/mini-calendar.js.map +1 -1
  89. package/dist/components/modal.d.ts +9 -3
  90. package/dist/components/modal.js +34 -45
  91. package/dist/components/modal.js.map +1 -1
  92. package/dist/components/month-picker.d.ts +79 -0
  93. package/dist/components/month-picker.js +353 -0
  94. package/dist/components/month-picker.js.map +1 -0
  95. package/dist/components/multi-entity-combobox.d.ts +7 -6
  96. package/dist/components/multi-entity-combobox.js +112 -72
  97. package/dist/components/multi-entity-combobox.js.map +1 -1
  98. package/dist/components/multi-select.d.ts +13 -11
  99. package/dist/components/multi-select.js +161 -84
  100. package/dist/components/multi-select.js.map +1 -1
  101. package/dist/components/number-field.d.ts +92 -0
  102. package/dist/components/number-field.js +111 -0
  103. package/dist/components/number-field.js.map +1 -0
  104. package/dist/components/number-input.d.ts +21 -2
  105. package/dist/components/number-input.js +2 -1
  106. package/dist/components/number-input.js.map +1 -1
  107. package/dist/components/numpad-sheet.d.ts +25 -4
  108. package/dist/components/numpad-sheet.js +30 -13
  109. package/dist/components/numpad-sheet.js.map +1 -1
  110. package/dist/components/page-contents.d.ts +90 -0
  111. package/dist/components/page-contents.js +170 -0
  112. package/dist/components/page-contents.js.map +1 -0
  113. package/dist/components/password-strength.d.ts +106 -0
  114. package/dist/components/password-strength.js +132 -0
  115. package/dist/components/password-strength.js.map +1 -0
  116. package/dist/components/picker-sheet.d.ts +23 -15
  117. package/dist/components/picker-sheet.js +34 -14
  118. package/dist/components/picker-sheet.js.map +1 -1
  119. package/dist/components/popover.d.ts +62 -4
  120. package/dist/components/popover.js +55 -2
  121. package/dist/components/popover.js.map +1 -1
  122. package/dist/components/search-field.d.ts +25 -7
  123. package/dist/components/search-field.js +7 -5
  124. package/dist/components/search-field.js.map +1 -1
  125. package/dist/components/series-chart-labels.d.ts +14 -0
  126. package/dist/components/series-chart-labels.js +11 -0
  127. package/dist/components/series-chart-labels.js.map +1 -0
  128. package/dist/components/series-chart.d.ts +207 -0
  129. package/dist/components/series-chart.js +223 -0
  130. package/dist/components/series-chart.js.map +1 -0
  131. package/dist/components/settings-fields.d.ts +14 -4
  132. package/dist/components/settings-fields.js +19 -8
  133. package/dist/components/settings-fields.js.map +1 -1
  134. package/dist/components/signature-pad.d.ts +119 -0
  135. package/dist/components/signature-pad.js +405 -0
  136. package/dist/components/signature-pad.js.map +1 -0
  137. package/dist/components/slider.d.ts +80 -0
  138. package/dist/components/slider.js +155 -0
  139. package/dist/components/slider.js.map +1 -0
  140. package/dist/components/sparkline.d.ts +93 -0
  141. package/dist/components/sparkline.js +205 -0
  142. package/dist/components/sparkline.js.map +1 -0
  143. package/dist/components/stat-tile.d.ts +151 -0
  144. package/dist/components/stat-tile.js +236 -0
  145. package/dist/components/stat-tile.js.map +1 -0
  146. package/dist/components/swipeable-row.d.ts +25 -2
  147. package/dist/components/swipeable-row.js +31 -0
  148. package/dist/components/swipeable-row.js.map +1 -1
  149. package/dist/components/switch.d.ts +60 -0
  150. package/dist/components/switch.js +81 -0
  151. package/dist/components/switch.js.map +1 -0
  152. package/dist/components/time-input.d.ts +58 -0
  153. package/dist/components/time-input.js +50 -0
  154. package/dist/components/time-input.js.map +1 -0
  155. package/dist/components/toggle-group.d.ts +18 -3
  156. package/dist/components/toggle-group.js +10 -6
  157. package/dist/components/toggle-group.js.map +1 -1
  158. package/dist/components/toggle-legend.d.ts +115 -0
  159. package/dist/components/toggle-legend.js +114 -0
  160. package/dist/components/toggle-legend.js.map +1 -0
  161. package/dist/components/tooltip.d.ts +40 -11
  162. package/dist/components/tooltip.js +77 -20
  163. package/dist/components/tooltip.js.map +1 -1
  164. package/dist/components/treemap.d.ts +132 -0
  165. package/dist/components/treemap.js +179 -0
  166. package/dist/components/treemap.js.map +1 -0
  167. package/dist/components/trigger-aria.d.ts +18 -0
  168. package/dist/components/trigger-aria.js +25 -0
  169. package/dist/components/trigger-aria.js.map +1 -0
  170. package/dist/components/ui.d.ts +167 -46
  171. package/dist/components/ui.js +225 -121
  172. package/dist/components/ui.js.map +1 -1
  173. package/dist/components/use-mobile-reveal.js +1 -0
  174. package/dist/components/use-mobile-reveal.js.map +1 -1
  175. package/dist/components/use-table-state.d.ts +1 -1
  176. package/dist/components/use-table-state.js +38 -17
  177. package/dist/components/use-table-state.js.map +1 -1
  178. package/dist/components/user-avatar.d.ts +5 -3
  179. package/dist/components/user-avatar.js +4 -2
  180. package/dist/components/user-avatar.js.map +1 -1
  181. package/dist/components/wizard-stepper.js +3 -2
  182. package/dist/components/wizard-stepper.js.map +1 -1
  183. package/dist/{data-table-filters-aXyf0Xub.d.ts → data-table-filters-DM1auUfH.d.ts} +27 -5
  184. package/dist/data-table.d.ts +7 -0
  185. package/dist/data-table.js +12 -0
  186. package/dist/data-table.js.map +1 -0
  187. package/dist/feedback/feedback-attachment.js +12 -11
  188. package/dist/feedback/feedback-attachment.js.map +1 -1
  189. package/dist/feedback/feedback-dialog.js +2 -1
  190. package/dist/feedback/feedback-dialog.js.map +1 -1
  191. package/dist/feedback/feedback-inbox.d.ts +33 -7
  192. package/dist/feedback/feedback-inbox.js +49 -37
  193. package/dist/feedback/feedback-inbox.js.map +1 -1
  194. package/dist/feedback.d.ts +5 -0
  195. package/dist/feedback.js +5 -0
  196. package/dist/feedback.js.map +1 -0
  197. package/dist/hooks/use-anchored-panel.js +1 -0
  198. package/dist/hooks/use-anchored-panel.js.map +1 -1
  199. package/dist/hooks/use-anchored-rect.js +1 -0
  200. package/dist/hooks/use-anchored-rect.js.map +1 -1
  201. package/dist/hooks/use-announce.d.ts +46 -0
  202. package/dist/hooks/use-announce.js +37 -0
  203. package/dist/hooks/use-announce.js.map +1 -0
  204. package/dist/hooks/use-body-scroll-lock.js +1 -0
  205. package/dist/hooks/use-body-scroll-lock.js.map +1 -1
  206. package/dist/hooks/use-close-transition.js +1 -0
  207. package/dist/hooks/use-close-transition.js.map +1 -1
  208. package/dist/hooks/use-dismiss.js +1 -0
  209. package/dist/hooks/use-dismiss.js.map +1 -1
  210. package/dist/hooks/use-focus-trap.d.ts +16 -0
  211. package/dist/hooks/use-focus-trap.js +67 -0
  212. package/dist/hooks/use-focus-trap.js.map +1 -0
  213. package/dist/hooks/use-media-query.js +1 -0
  214. package/dist/hooks/use-media-query.js.map +1 -1
  215. package/dist/hooks/use-overlay-history.js +27 -1
  216. package/dist/hooks/use-overlay-history.js.map +1 -1
  217. package/dist/hooks/use-row-swipe.js +1 -0
  218. package/dist/hooks/use-row-swipe.js.map +1 -1
  219. package/dist/i18n/defaults.d.ts +31 -0
  220. package/dist/i18n/defaults.js +63 -0
  221. package/dist/i18n/defaults.js.map +1 -0
  222. package/dist/i18n/kit-labels.d.ts +250 -0
  223. package/dist/i18n/kit-labels.js +184 -0
  224. package/dist/i18n/kit-labels.js.map +1 -0
  225. package/dist/index.d.ts +47 -22
  226. package/dist/index.js +28 -0
  227. package/dist/index.js.map +1 -1
  228. package/dist/lib/calc.js +1 -0
  229. package/dist/lib/calc.js.map +1 -1
  230. package/dist/lib/cn.js +1 -0
  231. package/dist/lib/cn.js.map +1 -1
  232. package/dist/lib/dates.js +1 -0
  233. package/dist/lib/dates.js.map +1 -1
  234. package/dist/lib/logger.js +1 -0
  235. package/dist/lib/logger.js.map +1 -1
  236. package/dist/lib/safe-storage.js +1 -0
  237. package/dist/lib/safe-storage.js.map +1 -1
  238. package/dist/search/command-palette.d.ts +11 -1
  239. package/dist/search/command-palette.js +21 -15
  240. package/dist/search/command-palette.js.map +1 -1
  241. package/dist/search.d.ts +2 -0
  242. package/dist/search.js +3 -0
  243. package/dist/search.js.map +1 -0
  244. package/dist/shell/app-shell.d.ts +33 -4
  245. package/dist/shell/app-shell.js +275 -78
  246. package/dist/shell/app-shell.js.map +1 -1
  247. package/dist/shell/option-switcher-menu.js +3 -2
  248. package/dist/shell/option-switcher-menu.js.map +1 -1
  249. package/dist/shell/role-switcher.d.ts +6 -0
  250. package/dist/shell/role-switcher.js +7 -4
  251. package/dist/shell/role-switcher.js.map +1 -1
  252. package/dist/shell/top-bar.d.ts +15 -7
  253. package/dist/shell/top-bar.js +3 -5
  254. package/dist/shell/top-bar.js.map +1 -1
  255. package/dist/shell/topbar-action-menu.js +3 -2
  256. package/dist/shell/topbar-action-menu.js.map +1 -1
  257. package/dist/shell/topbar-controls.d.ts +5 -2
  258. package/dist/shell/topbar-controls.js +20 -15
  259. package/dist/shell/topbar-controls.js.map +1 -1
  260. package/dist/shell.d.ts +13 -0
  261. package/dist/shell.js +8 -0
  262. package/dist/shell.js.map +1 -0
  263. package/dist/theme/chart-palette.d.ts +19 -12
  264. package/dist/theme/chart-palette.js +24 -30
  265. package/dist/theme/chart-palette.js.map +1 -1
  266. package/dist/theme/color.d.ts +78 -0
  267. package/dist/theme/color.js +148 -0
  268. package/dist/theme/color.js.map +1 -0
  269. package/dist/theme/palette-derive.d.ts +140 -0
  270. package/dist/theme/palette-derive.js +376 -0
  271. package/dist/theme/palette-derive.js.map +1 -0
  272. package/dist/theme/palette-presets.d.ts +14 -1
  273. package/dist/theme/palette-presets.js +231 -3
  274. package/dist/theme/palette-presets.js.map +1 -1
  275. package/dist/theme/palette-store.js +1 -0
  276. package/dist/theme/palette-store.js.map +1 -1
  277. package/dist/theme/theme-store.js +1 -0
  278. package/dist/theme/theme-store.js.map +1 -1
  279. package/dist/tour/tour.d.ts +2 -1
  280. package/dist/tour/tour.js +15 -9
  281. package/dist/tour/tour.js.map +1 -1
  282. package/dist/tour.d.ts +2 -0
  283. package/dist/tour.js +3 -0
  284. package/dist/tour.js.map +1 -0
  285. package/dist/wizard/stepper-nav.js +10 -8
  286. package/dist/wizard/stepper-nav.js.map +1 -1
  287. package/dist/wizard/types.d.ts +18 -2
  288. package/dist/wizard/types.js +4 -1
  289. package/dist/wizard/types.js.map +1 -1
  290. package/dist/wizard/use-wizard.js +12 -4
  291. package/dist/wizard/use-wizard.js.map +1 -1
  292. package/dist/wizard/validation.js +1 -0
  293. package/dist/wizard/validation.js.map +1 -1
  294. package/dist/wizard/wizard-context.js +1 -0
  295. package/dist/wizard/wizard-context.js.map +1 -1
  296. package/dist/wizard/wizard-step.js +1 -0
  297. package/dist/wizard/wizard-step.js.map +1 -1
  298. package/dist/wizard/wizard-summary.js +5 -3
  299. package/dist/wizard/wizard-summary.js.map +1 -1
  300. package/dist/wizard.d.ts +8 -0
  301. package/dist/wizard.js +9 -0
  302. package/dist/wizard.js.map +1 -0
  303. package/package.json +66 -13
  304. package/src/chart.ts +22 -0
  305. package/src/components/account-settings.tsx +275 -0
  306. package/src/components/alert-banner.tsx +75 -0
  307. package/src/components/amount-input.tsx +471 -0
  308. package/src/components/calculator.tsx +252 -0
  309. package/src/components/chart-zoom.tsx +499 -0
  310. package/src/components/chart.tsx +363 -0
  311. package/src/components/checkbox.tsx +222 -0
  312. package/src/components/chip.tsx +584 -0
  313. package/src/components/choice-parts.ts +33 -0
  314. package/src/components/combobox-core.tsx +540 -0
  315. package/src/components/combobox.tsx +1026 -0
  316. package/src/components/currency-select.tsx +283 -0
  317. package/src/components/data-table-filter-popover.tsx +252 -0
  318. package/src/components/data-table-filters.ts +176 -0
  319. package/src/components/data-table-labels.ts +190 -0
  320. package/src/components/data-table-pagination.tsx +126 -0
  321. package/src/components/data-table-sort.ts +70 -0
  322. package/src/components/data-table.tsx +1740 -0
  323. package/src/components/date-picker.tsx +656 -0
  324. package/src/components/dropdown.tsx +341 -0
  325. package/src/components/entity-combobox.tsx +215 -0
  326. package/src/components/facing-pair.ts +86 -0
  327. package/src/components/field-sync.tsx +472 -0
  328. package/src/components/file-dropzone.tsx +181 -0
  329. package/src/components/full-bleed-dialog.tsx +179 -0
  330. package/src/components/grouped-picker.tsx +157 -0
  331. package/src/components/hover-menu.tsx +183 -0
  332. package/src/components/mini-calendar.tsx +554 -0
  333. package/src/components/modal.tsx +287 -0
  334. package/src/components/month-picker.tsx +567 -0
  335. package/src/components/multi-entity-combobox.tsx +226 -0
  336. package/src/components/multi-select.tsx +303 -0
  337. package/src/components/number-field.tsx +225 -0
  338. package/src/components/number-input.tsx +211 -0
  339. package/src/components/numpad-sheet.tsx +264 -0
  340. package/src/components/page-contents.tsx +289 -0
  341. package/src/components/password-strength.tsx +258 -0
  342. package/src/components/picker-sheet.tsx +251 -0
  343. package/src/components/popover.tsx +198 -0
  344. package/src/components/search-field.tsx +146 -0
  345. package/src/components/series-chart-labels.ts +26 -0
  346. package/src/components/series-chart.tsx +481 -0
  347. package/src/components/settings-fields.tsx +68 -0
  348. package/src/components/signature-pad.tsx +630 -0
  349. package/src/components/slider.tsx +313 -0
  350. package/src/components/sparkline.tsx +329 -0
  351. package/src/components/stat-tile.tsx +448 -0
  352. package/src/components/swipeable-row.tsx +271 -0
  353. package/src/components/switch.tsx +170 -0
  354. package/src/components/time-input.tsx +107 -0
  355. package/src/components/toggle-group.tsx +153 -0
  356. package/src/components/toggle-legend.tsx +229 -0
  357. package/src/components/tooltip.tsx +477 -0
  358. package/src/components/treemap.tsx +390 -0
  359. package/src/components/trigger-aria.ts +42 -0
  360. package/src/components/ui.tsx +1295 -0
  361. package/src/components/use-mobile-reveal.ts +54 -0
  362. package/src/components/use-table-state.ts +295 -0
  363. package/src/components/user-avatar.tsx +61 -0
  364. package/src/components/wizard-stepper.tsx +37 -0
  365. package/src/data-table.ts +19 -0
  366. package/src/feedback/feedback-attachment.tsx +246 -0
  367. package/src/feedback/feedback-dialog.tsx +209 -0
  368. package/src/feedback/feedback-inbox.tsx +615 -0
  369. package/src/feedback.ts +8 -0
  370. package/src/hooks/use-anchored-panel.ts +169 -0
  371. package/src/hooks/use-anchored-rect.ts +78 -0
  372. package/src/hooks/use-announce.ts +85 -0
  373. package/src/hooks/use-body-scroll-lock.ts +94 -0
  374. package/src/hooks/use-close-transition.ts +99 -0
  375. package/src/hooks/use-dismiss.ts +77 -0
  376. package/src/hooks/use-focus-trap.ts +160 -0
  377. package/src/hooks/use-media-query.ts +23 -0
  378. package/src/hooks/use-overlay-history.ts +345 -0
  379. package/src/hooks/use-row-swipe.ts +212 -0
  380. package/src/i18n/defaults.ts +68 -0
  381. package/src/i18n/kit-labels.tsx +447 -0
  382. package/src/index.ts +169 -0
  383. package/src/lib/calc.ts +309 -0
  384. package/src/lib/cn.ts +5 -0
  385. package/src/lib/dates.ts +187 -0
  386. package/src/lib/logger.ts +73 -0
  387. package/src/lib/safe-storage.ts +37 -0
  388. package/src/search/command-palette.tsx +342 -0
  389. package/src/search.ts +3 -0
  390. package/src/shell/app-shell.tsx +772 -0
  391. package/src/shell/option-switcher-menu.tsx +72 -0
  392. package/src/shell/role-switcher.tsx +46 -0
  393. package/src/shell/top-bar.tsx +39 -0
  394. package/src/shell/topbar-action-menu.tsx +91 -0
  395. package/src/shell/topbar-controls.tsx +229 -0
  396. package/src/shell.ts +10 -0
  397. package/src/theme/chart-palette.ts +145 -0
  398. package/src/theme/color.ts +266 -0
  399. package/src/theme/palette-derive.ts +681 -0
  400. package/src/theme/palette-presets.ts +760 -0
  401. package/src/theme/palette-store.ts +94 -0
  402. package/src/theme/theme-store.ts +145 -0
  403. package/src/tour/tour.tsx +586 -0
  404. package/src/tour.ts +3 -0
  405. package/src/vite-env.d.ts +26 -0
  406. package/src/wizard/stepper-nav.tsx +221 -0
  407. package/src/wizard/types.ts +178 -0
  408. package/src/wizard/use-wizard.ts +345 -0
  409. package/src/wizard/validation.ts +37 -0
  410. package/src/wizard/wizard-context.tsx +29 -0
  411. package/src/wizard/wizard-step.tsx +14 -0
  412. package/src/wizard/wizard-summary.tsx +69 -0
  413. package/src/wizard.ts +14 -0
  414. package/tokens.css +222 -20
@@ -0,0 +1,586 @@
1
+ import {
2
+ createContext,
3
+ useCallback,
4
+ useContext,
5
+ useEffect,
6
+ useLayoutEffect,
7
+ useRef,
8
+ useState,
9
+ } from "react";
10
+ import type { CSSProperties, ReactNode } from "react";
11
+ import { createPortal } from "react-dom";
12
+ import { cn } from "../lib/cn";
13
+ import { useKitLabels } from "../i18n/kit-labels";
14
+ import { Button } from "../components/ui";
15
+ import { useFocusTrap } from "../hooks/use-focus-trap";
16
+
17
+ export type TourPlacement = "top" | "right" | "bottom" | "left" | "center";
18
+
19
+ export interface TourStep {
20
+ /** CSS selector for the element to spotlight. Omit for a centered step
21
+ * (welcome/finish). If the target isn't found/visible, the step centers. */
22
+ target?: string;
23
+ title: string;
24
+ body: ReactNode;
25
+ /** Extra footer content, e.g. a "load sample data" shortcut. */
26
+ action?: ReactNode;
27
+ /** Spotlight padding around the target, px (default 8). */
28
+ padding?: number;
29
+ /** Where the card sits relative to the target. Omit for auto placement
30
+ * (below → above → centered). "center" ignores the target and centers on
31
+ * screen. An explicit side flips to the opposite side if it would overflow,
32
+ * then clamps into the viewport. */
33
+ placement?: TourPlacement;
34
+ /** Advance only when the user clicks the spotlighted target itself (not the
35
+ * card's Next button). Requires `target`: the real control's own handler runs
36
+ * first, then the tour steps forward on a microtask. The overlay stays
37
+ * click-through to the target. */
38
+ awaitClick?: boolean;
39
+ /** Runs before the step is shown — e.g. navigate to a route, open a panel.
40
+ * May be async; the step waits for it, then locates the target. */
41
+ beforeStep?: () => void | Promise<void>;
42
+ }
43
+
44
+ export interface TourLabels {
45
+ next: string;
46
+ back: string;
47
+ skip: string;
48
+ done: string;
49
+ /** Shown in place of the Next button on an `awaitClick` step. */
50
+ awaitClickHint: string;
51
+ /** Step counter, e.g. (2, 7) => "2 / 7". */
52
+ step: (current: number, total: number) => string;
53
+ }
54
+
55
+ export const DEFAULT_TOUR_LABELS: TourLabels = {
56
+ next: "Next",
57
+ back: "Back",
58
+ skip: "Skip",
59
+ done: "Done",
60
+ awaitClickHint: "Click the highlighted element to continue",
61
+ step: (c, t) => `${c} / ${t}`,
62
+ };
63
+
64
+ interface StartOptions {
65
+ /** Stable id of the tour, surfaced as `activeId` so the app can mirror it to
66
+ * the URL (deep-link / evaluation tracking) and record completion. */
67
+ id?: string;
68
+ /** Start at this step index instead of 0 (clamped) — for URL/deep-link resume. */
69
+ startIndex?: number;
70
+ /** Fires synchronously when the tour starts (e.g. enable a mock interceptor). */
71
+ onStart?: () => void;
72
+ onFinish?: () => void;
73
+ onSkip?: () => void;
74
+ }
75
+
76
+ interface TourContextValue {
77
+ active: boolean;
78
+ /** Id of the running tour (from {@link StartOptions.id}), else null. */
79
+ activeId: string | null;
80
+ /** Start a tour with the given steps. */
81
+ start: (steps: TourStep[], opts?: StartOptions) => void;
82
+ /** End the current tour (no callbacks fire). */
83
+ stop: () => void;
84
+ /** Advance one step; past the last step it finishes the tour (fires onFinish). */
85
+ next: () => void;
86
+ /** Go back one step (no-op on the first). */
87
+ prev: () => void;
88
+ /** Jump to a step by index, clamped to range — e.g. for URL/deep-link resume. */
89
+ goToStep: (index: number) => void;
90
+ /** Current step (0-based; 0 while inactive). */
91
+ index: number;
92
+ /** Total steps (0 while inactive). */
93
+ total: number;
94
+ }
95
+
96
+ const TourContext = createContext<TourContextValue | null>(null);
97
+
98
+ export function useTour(): TourContextValue {
99
+ const ctx = useContext(TourContext);
100
+ if (!ctx) throw new Error("useTour must be used within <TourProvider>");
101
+ return ctx;
102
+ }
103
+
104
+ /**
105
+ * The tour engine if it is there, `null` if it is not — for a control that is a
106
+ * DECORATION rather than a participant.
107
+ *
108
+ * {@link useTour}'s throw is correct and stays: a component that runs a tour cannot do
109
+ * its job without the provider, and failing loudly is how that gets fixed. But the
110
+ * throw's blast radius is whatever error boundary is above it, and for a launcher in
111
+ * the app shell that is the whole app.
112
+ *
113
+ * Keksdose feedback dev#524 is what that costs: an `@hb/ui` module was edited while a
114
+ * dev server was running, vite re-evaluated it, and the module's freshly created
115
+ * context object was no longer the one the mounted provider was providing. React's
116
+ * `useContext` then answers `null` for a provider that is, structurally, right there —
117
+ * and the top bar's tour menu took the entire shell down with it. **Build-time module
118
+ * graphs cannot produce that**, so it is a development-only failure; a menu that
119
+ * disappears for a second is the proportionate response to it either way.
120
+ *
121
+ * Only for controls that can honestly render nothing. If a component would show a
122
+ * broken half of itself without the tour, it wants {@link useTour}.
123
+ */
124
+ export function useTourOptional(): TourContextValue | null {
125
+ return useContext(TourContext);
126
+ }
127
+
128
+ /**
129
+ * Provides the guided-tour engine: a dimmed spotlight overlay + step card driven
130
+ * by a list of {@link TourStep}s. Domain-free — the app supplies the steps (copy,
131
+ * selectors, per-step navigation, placement) and the translated {@link TourLabels}.
132
+ * Mount once inside the router; start a tour from anywhere via {@link useTour},
133
+ * which also exposes step control (`next`/`prev`/`goToStep`) and the current
134
+ * `index`/`total` for URL mirroring, `awaitClick` and deep-link resume.
135
+ */
136
+ export function TourProvider({
137
+ children,
138
+ labels,
139
+ }: {
140
+ children: ReactNode;
141
+ labels?: Partial<TourLabels>;
142
+ }) {
143
+ // `labels` over the provider's `tour` over English. Resolved once here and handed
144
+ // down: the step card is portalled, but context crosses portals anyway — this is
145
+ // simply the one place that already owned the merge.
146
+ const merged = useKitLabels("tour", DEFAULT_TOUR_LABELS, labels);
147
+ const [steps, setSteps] = useState<TourStep[] | null>(null);
148
+ const [index, setIndex] = useState(0);
149
+ const [activeId, setActiveId] = useState<string | null>(null);
150
+ const optsRef = useRef<StartOptions>({});
151
+ // Live mirrors so the step-control callbacks can stay stable (identity-safe for
152
+ // consumers) while still reading the current steps/index.
153
+ const stepsRef = useRef<TourStep[] | null>(null);
154
+ stepsRef.current = steps;
155
+ const indexRef = useRef(0);
156
+ indexRef.current = index;
157
+ const active = !!steps && steps.length > 0;
158
+ const total = steps?.length ?? 0;
159
+
160
+ const start = useCallback((s: TourStep[], opts?: StartOptions) => {
161
+ optsRef.current = opts ?? {};
162
+ optsRef.current.onStart?.();
163
+ setIndex(Math.min(Math.max(0, opts?.startIndex ?? 0), Math.max(0, s.length - 1)));
164
+ setActiveId(opts?.id ?? null);
165
+ setSteps(s);
166
+ }, []);
167
+ const stop = useCallback(() => {
168
+ setSteps(null);
169
+ setActiveId(null);
170
+ }, []);
171
+ const finish = useCallback(() => {
172
+ optsRef.current.onFinish?.();
173
+ setSteps(null);
174
+ setActiveId(null);
175
+ }, []);
176
+ const skip = useCallback(() => {
177
+ optsRef.current.onSkip?.();
178
+ setSteps(null);
179
+ setActiveId(null);
180
+ }, []);
181
+
182
+ const goToStep = useCallback((i: number) => {
183
+ const len = stepsRef.current?.length ?? 0;
184
+ if (len === 0) return;
185
+ setIndex(Math.min(Math.max(0, i), len - 1));
186
+ }, []);
187
+ const next = useCallback(() => {
188
+ const len = stepsRef.current?.length ?? 0;
189
+ if (len === 0) return;
190
+ if (indexRef.current >= len - 1) finish();
191
+ else setIndex(indexRef.current + 1);
192
+ }, [finish]);
193
+ const prev = useCallback(() => {
194
+ if (indexRef.current > 0) setIndex(indexRef.current - 1);
195
+ }, []);
196
+
197
+ return (
198
+ <TourContext.Provider value={{ active, activeId, start, stop, next, prev, goToStep, index, total }}>
199
+ {children}
200
+ {active && (
201
+ <TourOverlay
202
+ steps={steps!}
203
+ index={index}
204
+ labels={merged}
205
+ onNext={next}
206
+ onPrev={prev}
207
+ onSkip={skip}
208
+ />
209
+ )}
210
+ </TourContext.Provider>
211
+ );
212
+ }
213
+
214
+ interface Rect {
215
+ top: number;
216
+ left: number;
217
+ width: number;
218
+ height: number;
219
+ }
220
+
221
+ function isVisible(el: Element): boolean {
222
+ // A non-zero box already rules out display:none on the element or any ancestor
223
+ // (an unrendered element measures 0x0). We deliberately do NOT test
224
+ // offsetParent: it is null for position:fixed elements even when fully visible,
225
+ // which made the mobile bottom-nav bar (fixed) un-highlightable on mobile
226
+ // (feedback #313). visibility:hidden keeps a box, so check it explicitly.
227
+ const r = el.getBoundingClientRect();
228
+ if (r.width <= 0 || r.height <= 0) return false;
229
+ const style = getComputedStyle(el);
230
+ return style.visibility !== "hidden" && style.display !== "none";
231
+ }
232
+
233
+ // The first VISIBLE element matching the selector, not merely the first in DOM
234
+ // order. This lets a step target the same control across layouts with one
235
+ // combined selector — e.g. the desktop sidebar link AND the mobile bottom-bar
236
+ // link — where the off-layout copy is present but `display:none` (feedback
237
+ // #313). Returns null while none is visible so the finder keeps retrying.
238
+ function queryVisibleTarget(selector: string): Element | null {
239
+ const els = document.querySelectorAll(selector);
240
+ for (const el of els) {
241
+ if (isVisible(el)) return el;
242
+ }
243
+ return null;
244
+ }
245
+
246
+ function sameRect(a: Rect | null, b: Rect | null): boolean {
247
+ if (a === b) return true;
248
+ if (!a || !b) return false;
249
+ return a.top === b.top && a.left === b.left && a.width === b.width && a.height === b.height;
250
+ }
251
+
252
+ function TourOverlay({
253
+ steps,
254
+ index,
255
+ labels,
256
+ onNext,
257
+ onPrev,
258
+ onSkip,
259
+ }: {
260
+ steps: TourStep[];
261
+ index: number;
262
+ labels: TourLabels;
263
+ onNext: () => void;
264
+ onPrev: () => void;
265
+ onSkip: () => void;
266
+ }) {
267
+ const step = steps[index];
268
+ const isFirst = index === 0;
269
+ const isLast = index === steps.length - 1;
270
+ const [rect, setRect] = useState<Rect | null>(null);
271
+ const [ready, setReady] = useState(false);
272
+
273
+ // Run beforeStep, then locate the target (retrying across route/render lag).
274
+ useEffect(() => {
275
+ let cancelled = false;
276
+ let raf = 0;
277
+ setReady(false);
278
+ setRect(null);
279
+ void (async () => {
280
+ await step.beforeStep?.();
281
+ if (cancelled) return;
282
+ if (!step.target) {
283
+ setReady(true);
284
+ return;
285
+ }
286
+ let tries = 0;
287
+ const find = () => {
288
+ if (cancelled) return;
289
+ const el = queryVisibleTarget(step.target!);
290
+ if (el) {
291
+ el.scrollIntoView({ block: "center", behavior: "smooth" });
292
+ const r = el.getBoundingClientRect();
293
+ setRect({ top: r.top, left: r.left, width: r.width, height: r.height });
294
+ setReady(true);
295
+ return;
296
+ }
297
+ if (tries++ < 45) raf = requestAnimationFrame(find);
298
+ else setReady(true); // give up → render centered
299
+ };
300
+ find();
301
+ })();
302
+ return () => {
303
+ cancelled = true;
304
+ cancelAnimationFrame(raf);
305
+ };
306
+ }, [index, step]);
307
+
308
+ // Follow the target as the page scrolls / reflows.
309
+ useEffect(() => {
310
+ if (!step.target) return;
311
+ const update = () => {
312
+ const el = queryVisibleTarget(step.target!);
313
+ if (el) {
314
+ const r = el.getBoundingClientRect();
315
+ const next = { top: r.top, left: r.left, width: r.width, height: r.height };
316
+ setRect((prev) => (sameRect(prev, next) ? prev : next));
317
+ }
318
+ };
319
+ window.addEventListener("scroll", update, true);
320
+ window.addEventListener("resize", update);
321
+ const id = window.setInterval(update, 250);
322
+ return () => {
323
+ window.removeEventListener("scroll", update, true);
324
+ window.removeEventListener("resize", update);
325
+ clearInterval(id);
326
+ };
327
+ }, [index, step]);
328
+
329
+ // awaitClick: advance when the *real* target is clicked. The overlay is
330
+ // click-through (pointer-events-none except the card) so the element's own
331
+ // handler runs first; we step forward on the next macrotask.
332
+ useEffect(() => {
333
+ if (!ready || !step.awaitClick || !step.target) return;
334
+ const el = queryVisibleTarget(step.target);
335
+ if (!el) return;
336
+ const onClick = () => window.setTimeout(() => onNext(), 0);
337
+ el.addEventListener("click", onClick, { once: true });
338
+ return () => el.removeEventListener("click", onClick);
339
+ }, [ready, index, step, onNext]);
340
+
341
+ // Keyboard: Esc skips, →/Enter advance, ← goes back. On awaitClick steps Enter
342
+ // is ignored (it would fire the target's click AND advance) — → stays as an
343
+ // escape hatch.
344
+ useEffect(() => {
345
+ const onKey = (e: KeyboardEvent) => {
346
+ if (e.key === "Escape") {
347
+ onSkip();
348
+ } else if (e.key === "ArrowRight") {
349
+ e.preventDefault();
350
+ onNext();
351
+ } else if (e.key === "Enter") {
352
+ if (step.awaitClick) return;
353
+ e.preventDefault();
354
+ onNext();
355
+ } else if (e.key === "ArrowLeft") {
356
+ if (!isFirst) onPrev();
357
+ }
358
+ };
359
+ document.addEventListener("keydown", onKey);
360
+ return () => document.removeEventListener("keydown", onKey);
361
+ }, [isFirst, step, onNext, onPrev, onSkip]);
362
+
363
+ if (!ready) return null;
364
+
365
+ const pad = step.padding ?? 8;
366
+ const spot: Rect | null = rect
367
+ ? { top: rect.top - pad, left: rect.left - pad, width: rect.width + pad * 2, height: rect.height + pad * 2 }
368
+ : null;
369
+
370
+ return createPortal(
371
+ <div className="pointer-events-none fixed inset-0 z-[60]" role="dialog" aria-modal="true" aria-label={step.title}>
372
+ {spot ? (
373
+ <div
374
+ className="pointer-events-none fixed rounded-lg transition-all duration-200 ease-out"
375
+ style={{
376
+ top: spot.top,
377
+ left: spot.left,
378
+ width: spot.width,
379
+ height: spot.height,
380
+ // A two-tone frame, not a single translucent ring.
381
+ //
382
+ // The old treatment was `ring-2 ring-white/80` over a 55% scrim, and it
383
+ // "was barely visible" on the app's blue-tinted surfaces. Two reasons,
384
+ // and a single ring can't fix either: at 55% the surround stays bright
385
+ // enough that the un-dimmed hole barely reads AS a hole, and a 80%-white
386
+ // ring sitting on the edge of a light card is white-on-near-white.
387
+ //
388
+ // So: an opaque white band immediately around the target, a dark keyline
389
+ // outside it, then the scrim. Whatever the target's own colour is, one of
390
+ // the two bands is always in contrast with it and the other is always in
391
+ // contrast with the dimmed surround — there is no background that can
392
+ // swallow both. The blurred layer between them softens the step so the
393
+ // frame reads as lighting rather than as a pasted-on rectangle.
394
+ boxShadow: [
395
+ "0 0 0 3px rgba(255,255,255,0.98)",
396
+ "0 0 0 5px rgba(15,23,42,0.92)",
397
+ "0 0 18px 6px rgba(15,23,42,0.45)",
398
+ "0 0 0 9999px rgba(15,23,42,0.70)",
399
+ ].join(", "),
400
+ }}
401
+ />
402
+ ) : (
403
+ <div className="pointer-events-auto fixed inset-0 bg-black/70" />
404
+ )}
405
+ <TourCard
406
+ step={step}
407
+ index={index}
408
+ total={steps.length}
409
+ labels={labels}
410
+ isFirst={isFirst}
411
+ isLast={isLast}
412
+ rect={spot}
413
+ onBack={onPrev}
414
+ onNext={onNext}
415
+ onSkip={onSkip}
416
+ />
417
+ </div>,
418
+ document.body,
419
+ );
420
+ }
421
+
422
+ /**
423
+ * Card position (viewport px) for the given placement relative to the padded
424
+ * spotlight `rect`. Omitted placement keeps the original auto behavior
425
+ * (below → above → vertically centered); an explicit side flips to its opposite
426
+ * if it would overflow, then clamps into the viewport. "center" (or no rect)
427
+ * centers on screen.
428
+ */
429
+ function placeCard(
430
+ rect: Rect | null,
431
+ cw: number,
432
+ ch: number,
433
+ vw: number,
434
+ vh: number,
435
+ m: number,
436
+ placement?: TourPlacement,
437
+ ): { top: number; left: number } {
438
+ if (!rect || placement === "center") {
439
+ return { top: Math.max(m, (vh - ch) / 2), left: Math.max(m, (vw - cw) / 2) };
440
+ }
441
+ const clampX = (x: number) => Math.min(Math.max(m, x), Math.max(m, vw - cw - m));
442
+ const clampY = (y: number) => Math.min(Math.max(m, y), Math.max(m, vh - ch - m));
443
+ const centerX = clampX(rect.left + rect.width / 2 - cw / 2);
444
+ const centerY = clampY(rect.top + rect.height / 2 - ch / 2);
445
+ const belowTop = rect.top + rect.height + m;
446
+ const aboveTop = rect.top - ch - m;
447
+ const rightLeft = rect.left + rect.width + m;
448
+ const leftLeft = rect.left - cw - m;
449
+ const fitsBelow = belowTop + ch <= vh;
450
+ const fitsAbove = aboveTop >= 0;
451
+ const fitsRight = rightLeft + cw <= vw;
452
+ const fitsLeft = leftLeft >= 0;
453
+
454
+ switch (placement) {
455
+ case "top":
456
+ return { top: fitsAbove ? aboveTop : fitsBelow ? belowTop : clampY(aboveTop), left: centerX };
457
+ case "bottom":
458
+ return { top: fitsBelow ? belowTop : fitsAbove ? aboveTop : clampY(belowTop), left: centerX };
459
+ case "right":
460
+ return { top: centerY, left: fitsRight ? rightLeft : fitsLeft ? leftLeft : clampX(rightLeft) };
461
+ case "left":
462
+ return { top: centerY, left: fitsLeft ? leftLeft : fitsRight ? rightLeft : clampX(leftLeft) };
463
+ default:
464
+ if (fitsBelow) return { top: belowTop, left: centerX };
465
+ if (fitsAbove) return { top: aboveTop, left: centerX };
466
+ return { top: Math.max(m, (vh - ch) / 2), left: centerX };
467
+ }
468
+ }
469
+
470
+ function TourCard({
471
+ step,
472
+ index,
473
+ total,
474
+ labels,
475
+ isFirst,
476
+ isLast,
477
+ rect,
478
+ onBack,
479
+ onNext,
480
+ onSkip,
481
+ }: {
482
+ step: TourStep;
483
+ index: number;
484
+ total: number;
485
+ labels: TourLabels;
486
+ isFirst: boolean;
487
+ isLast: boolean;
488
+ rect: Rect | null;
489
+ onBack: () => void;
490
+ onNext: () => void;
491
+ onSkip: () => void;
492
+ }) {
493
+ const ref = useRef<HTMLDivElement>(null);
494
+ const [style, setStyle] = useState<CSSProperties>({ opacity: 0 });
495
+
496
+ /**
497
+ * The card holds the focus, because the card is what the tour IS.
498
+ *
499
+ * The overlay above declares `role="dialog" aria-modal="true"` — it always has — and
500
+ * then left focus wherever the page had put it. For a tour that is the most pointed
501
+ * version of the audit's *"Only Modal manages focus"*: the whole component exists to
502
+ * say "look here", and for a keyboard user "here" is the focus ring. They were told
503
+ * the page was hidden, given no way to reach the Next button without Tabbing through
504
+ * it, and left on a control the screen reader would no longer describe.
505
+ *
506
+ * It re-engages on every step, without any bookkeeping here, because `TourOverlay`
507
+ * returns null while it re-locates the next target: the card genuinely unmounts and
508
+ * remounts between steps. That is what keeps focus honest when the BUTTONS change —
509
+ * "Back" does not exist on the first step, so stepping back onto it destroys the
510
+ * control the press came from, and focus would otherwise fall to `<body>`, outside
511
+ * this trap's own listener, where Tab walks straight into the page the overlay claims
512
+ * to have hidden.
513
+ *
514
+ * **The cost, written down:** on an `awaitClick` step the user is asked to click the
515
+ * spotlighted element, and they can no longer Tab to it. ArrowRight still advances
516
+ * (the key handler in `TourOverlay` is on the document and does not care where focus
517
+ * is), which is the escape hatch that step already documents for the case where the
518
+ * target cannot be found. Containment is worth that: an `awaitClick` step is a
519
+ * minority of steps, while focus stranded behind `aria-modal` is every step.
520
+ */
521
+ useFocusTrap(ref, { active: true });
522
+
523
+ useLayoutEffect(() => {
524
+ const card = ref.current;
525
+ if (!card) return;
526
+ setStyle(
527
+ placeCard(rect, card.offsetWidth, card.offsetHeight, window.innerWidth, window.innerHeight, 12, step.placement),
528
+ );
529
+ }, [rect, index, step.placement]);
530
+
531
+ return (
532
+ <div
533
+ ref={ref}
534
+ // Focusable but not tabbable: the trap above focuses the card itself rather than
535
+ // its first button, so a screen reader reads the step's title and body before it
536
+ // reads "Next" — and without this the container cannot take focus at all and the
537
+ // trap silently does nothing.
538
+ tabIndex={-1}
539
+ style={style}
540
+ className="pointer-events-auto fixed z-[61] w-80 max-w-[calc(100vw-1.5rem)] rounded-lg border border-[var(--border)] bg-[var(--bg-surface)] p-4 shadow-xl outline-none transition-all duration-200 ease-out"
541
+ >
542
+ <div className="text-sm font-semibold text-[var(--text-primary)]">{step.title}</div>
543
+ <div className="mt-1 text-sm leading-relaxed text-[var(--text-secondary)]">{step.body}</div>
544
+ {step.action && <div className="mt-3">{step.action}</div>}
545
+ <div className="mt-4 space-y-2">
546
+ <div className="flex items-center justify-between gap-2">
547
+ <button
548
+ type="button"
549
+ onClick={onSkip}
550
+ className="text-xs text-[var(--text-placeholder)] hover:text-[var(--text-secondary)]"
551
+ >
552
+ {labels.skip}
553
+ </button>
554
+ <div className="flex items-center gap-2">
555
+ <span className="whitespace-nowrap text-xs tabular-nums text-[var(--text-placeholder)]">
556
+ {labels.step(index + 1, total)}
557
+ </span>
558
+ {!isFirst && (
559
+ <Button variant="secondary" onClick={onBack} className="px-2.5 py-1 text-xs">
560
+ {labels.back}
561
+ </Button>
562
+ )}
563
+ {/* On an awaitClick step the Next button is replaced by a hint on its
564
+ own row below, so it doesn't cram the counter + buttons and wrap.
565
+ Only when the target was actually FOUND, though — `rect` is null
566
+ when the finder gave up, and the click listener early-returns on
567
+ the same absence. Keyed on `step.target` alone this hid the only
568
+ way forward on any step whose anchor happens not to be rendered
569
+ for this user (a guest sees no "add account" button), leaving the
570
+ undocumented ArrowRight key as the sole escape. */}
571
+ {!(step.awaitClick && step.target && rect) && (
572
+ <Button variant="brand" onClick={onNext} className={cn("px-2.5 py-1 text-xs")}>
573
+ {isLast ? labels.done : labels.next}
574
+ </Button>
575
+ )}
576
+ </div>
577
+ </div>
578
+ {step.awaitClick && step.target && rect && (
579
+ <div className="text-center text-xs italic text-[var(--text-placeholder)]">
580
+ {labels.awaitClickHint}
581
+ </div>
582
+ )}
583
+ </div>
584
+ </div>
585
+ );
586
+ }
package/src/tour.ts ADDED
@@ -0,0 +1,3 @@
1
+ // `@eifi1/ui-kit/tour` — guided tours.
2
+ // A re-slicing of the main barrel, not a new API.
3
+ export * from "./tour/tour";
@@ -0,0 +1,26 @@
1
+ // Minimal ambient typing for the Vite-injected `import.meta.env` so the package
2
+ // type-checks standalone (consumers provide the real values at build time).
3
+ interface ImportMetaEnv {
4
+ readonly DEV: boolean;
5
+ /** Set by vitest, and by nothing else. `DEV` cannot answer "am I under test" —
6
+ * a test run is neither a dev build nor a production one, and vitest reports
7
+ * `DEV=true` — so anything that should be quiet in a suite has to ask this. */
8
+ readonly VITEST?: boolean;
9
+ }
10
+ interface ImportMeta {
11
+ readonly env: ImportMetaEnv;
12
+ /**
13
+ * Vite's compile-time glob. Declared here rather than by pulling in
14
+ * `vite/client` (which drags every asset-module shim with it) or `@types/node`
15
+ * (which this package deliberately does not depend on — it ships browser code).
16
+ *
17
+ * It is what lets a TEST read the package's own sources: `field-invalid.test.tsx`
18
+ * sweeps the component directory to find a field-shaped control that forgot a
19
+ * prop, which is the kind of guard the consumer app writes with `readFileSync`
20
+ * and cannot be written that way here.
21
+ */
22
+ glob<T = unknown>(
23
+ pattern: string,
24
+ options?: { query?: string; import?: string; eager?: boolean },
25
+ ): Record<string, T>;
26
+ }